Advertisement
El_Chaderino

clinical q html chart and graph generator v1

Mar 11th, 2024 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 14.45 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>EEG Data Visualization and Interpretation</title>
  7.     <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
  8. </head>
  9. <body>
  10.  
  11. <textarea id="dataInput" rows="10" cols="50" placeholder="Paste EEG data here..."></textarea>
  12. <button onclick="generateChart()">Generate Chart</button>
  13.  
  14. <div style="width:600px; margin-top:20px;">
  15.     <canvas id="eegChart"></canvas>
  16. </div>
  17.  
  18. <div id="interpretation" style="margin-top:20px;"></div>
  19.  
  20. <script>
  21. function parseData(data) {
  22.     const lines = data.split('\n');
  23.     const parsedData = lines.map(line => {
  24.         const parts = line.split('\t').map(part => part.trim());
  25.         return {
  26.             label: parts[0],
  27.             value: parseFloat(parts[1]),
  28.             ratio: parseFloat(parts[2])
  29.         };
  30.     });
  31.     return parsedData.filter(d => !isNaN(d.value)); // Filter out non-numerical entries
  32. }
  33.  
  34. function interpretData(parsedData) {
  35.     let interpretation = "";
  36.     parsedData.forEach(d => {
  37.         switch(d.label) {
  38.             // Interpretations for CZ
  39.             case "CZ Theta (3-7 Hz) increase during Eyes Closed":
  40.                 if (d.value > 0) {
  41.                     interpretation += "Indicates a visual processing problem, poor retention of information, or short-term memory issues.<br>";
  42.                 }
  43.                 break;
  44.             case "CZ Theta (3-7 Hz) decrease during Eyes Open":
  45.                 if (d.value > 0) {
  46.                     interpretation += "Suggests foggy thinking.<br>";
  47.                 }
  48.                 break;
  49.             case "CZ Theta/Beta ratio (3-7 Hz / 16-25 Hz) above 2.2":
  50.                 if (d.value > 2.2) {
  51.                     interpretation += "May indicate attention deficit issues (CADD).<br>";
  52.                 }
  53.                 break;
  54.             case "CZ Theta/Beta ratio (3-7 Hz / 16-25 Hz) above 2.2 during Up Training (UT)":
  55.                 if (d.value > 2.2) {
  56.                     interpretation += "May suggest CADD if ratio drops. If ratio is above 3.0, it may indicate ADHD.<br>";
  57.                 }
  58.                 break;
  59.             case "CZ Delta (1.5-2.5 Hz) increase during Eyes Closed above 9.0":
  60.                 if (d.value > 9.0) {
  61.                     interpretation += "May suggest cognitive deficits such as concentration problems, forgetfulness, and comprehension issues.<br>";
  62.                 }
  63.                 break;
  64.             case "CZ Theta/Beta ratio (3-7 Hz / 16-25 Hz) above 2.2 and percentage change > 15%":
  65.                 if (d.value > 2.2) {
  66.                     interpretation += "May indicate attention-related issues.<br>";
  67.                 }
  68.                 break;
  69.             case "CZ Total amplitude (Theta + Alpha + Beta) above a specific range (e.g., 70)":
  70.                 if (d.value > 70) {
  71.                     interpretation += "May suggest excessive brainwave activity.<br>";
  72.                 }
  73.                 break;
  74.             case "CZ Total amplitude at CZ above 60":
  75.                 if (d.value > 60) {
  76.                     interpretation += "May indicate developmental delay, autistic spectrum behavior, or marked cognitive deficits.<br>";
  77.                 }
  78.                 break;
  79.             case "CZ Increase Eyes Open to Eyes Closed Alpha difference by more than 30% (8-12 Hz)":
  80.                 if (d.value > 30) {
  81.                     interpretation += "To improve visual processing and memory.<br>";
  82.                 }
  83.                 break;
  84.             case "CZ Decrease Eyes Open Theta/Beta ratio (3-7 Hz / 16-25 Hz) to below 2.2":
  85.                 if (d.value < 2.2) {
  86.                    interpretation += "To reduce inattention.<br>";
  87.                 }
  88.                 break;
  89.             case "CZ Train Eyes Open Theta/Beta ratio to under 2.2":
  90.                 if (d.value < 2.2) {
  91.                    interpretation += "For improved reading comprehension and retention.<br>";
  92.                 }
  93.                 break;
  94.             case "CZ Consider ADD and reading difficulties if CZ Eyes Open Theta/Beta is above 2.2 and CZ Eyes Open T/B is below 2.2":
  95.                 // No specific interpretation provided
  96.                 interpretation += "<br>";
  97.                 break;
  98.             case "CZ Consider ADHD if CZ Eyes Open Theta/Beta is above 2.2 and CZ Eyes Open T/B is above 3.0":
  99.                 // No specific interpretation provided
  100.                 interpretation += "<br>";
  101.                 break;
  102.             case "CZ Theta (3-7 Hz) range":
  103.                 interpretation += "Indicates a relaxed or meditative state.<br>";
  104.                 break;
  105.             case "CZ Alpha (8-12 Hz) range":
  106.                 interpretation += "Associated with a calm and focused state of mind.<br>";
  107.                 break;
  108.             case "CZ Beta (16-25 Hz) range":
  109.                 interpretation += "Related to active thinking, problem-solving, and concentration.<br>";
  110.                 break;
  111.             case "CZ High Beta (28-40 Hz) range":
  112.                 interpretation += "May indicate heightened alertness or anxiety.<br>";
  113.                 break;
  114.  
  115.             // Interpretations for O1
  116.             case "O1 Increase in Eyes Closed Alpha (8-12 Hz) of less than 50% or negative change, along with similar pattern at CZ":
  117.                 if (d.value < 50) {
  118.                    interpretation += "May suggest traumatic stress.<br>";
  119.                 }
  120.                 break;
  121.             case "O1 Percentage change of Alpha (8-12 Hz) greater than 25% during Eyes Open":
  122.                 if (d.value > 25) {
  123.                     interpretation += "May indicate foggy thinking.<br>";
  124.                 }
  125.                 break;
  126.             case "O1 Theta/Beta ratio (3-7 Hz / 16-25 Hz) during Eyes Open below 1.8":
  127.                 if (d.value < 1.8) {
  128.                    interpretation += "May indicate poor stress tolerance, racing thoughts, and anxiety.<br>";
  129.                 }
  130.                 break;
  131.             case "O1 Theta/Beta ratio (3-7 Hz / 16-25 Hz) during Eyes Open above 3.0":
  132.                 if (d.value > 3.0) {
  133.                     interpretation += "May be associated with cognitive deficiencies or Asperger's patterns. Consider examining F4/F3 Beta as well.<br>";
  134.                 }
  135.                 break;
  136.             case "O1 Theta/Beta ratio (3-7 Hz / 16-25 Hz) during both Eyes Closed and Eyes Open around or below 1.5":
  137.                 if (d.value <= 1.5) {
  138.                    interpretation += "May indicate sleep disturbance.<br>";
  139.                 }
  140.                 break;
  141.             case "O1 Theta/Beta ratio (3-7 Hz / 16-25 Hz) during Eyes Open below 1.8 and a percentage change greater than 3.0":
  142.                 if (d.value < 1.8 && d.ratio > 3.0) {
  143.                     interpretation += "May be associated with cognitive deficiencies or Asperger's patterns.<br>";
  144.                 }
  145.                 break;
  146.             case "O1 Increase O1 Eyes Open Theta/Beta ratio (3-7 Hz / 16-25 Hz) to between 1.8-2.2":
  147.                 if (d.value >= 1.8 && d.value <= 2.2) {
  148.                    interpretation += "To address stress tolerance, racing thoughts, and anxiety.<br>";
  149.                 }
  150.                 break;
  151.             case "O1 Decrease O1 Eyes Open Theta/Beta ratio to below 1.8":
  152.                 if (d.value < 1.8) {
  153.                    interpretation += "To address self-medicating behaviors and depression.<br>";
  154.                 }
  155.                 break;
  156.             case "O1 Balance O1 Eyes Closed and Eyes Open Theta/Beta ratio to 1.5":
  157.                 if (d.value === 1.5) {
  158.                     interpretation += "To improve sleep disturbance.<br>";
  159.                 }
  160.                 break;
  161.             case "O1 Increase Peak Alpha Frequency Eyes Open at O1 (8-12 Hz)":
  162.                 // No specific interpretation provided
  163.                 interpretation += "<br>";
  164.                 break;
  165.             case "O1 Theta (3-7 Hz) range":
  166.                 interpretation += "Associated with deep relaxation and daydreaming.<br>";
  167.                 break;
  168.             case "O1 Alpha (8-12 Hz) range":
  169.                 interpretation += "Linked to a relaxed and calm state of mind.<br>";
  170.                 break;
  171.             case "O1 SMR (12-15 Hz) range":
  172.                 interpretation += "Associated with focused attention and sensorimotor integration.<br>";
  173.                 break;
  174.  
  175.             // Interpretations for F3 and F4
  176.             case "F3 and F4 Theta/Beta ratio (3-7 Hz / 16-25 Hz) above 2.2":
  177.                 if (d.value > 2.2) {
  178.                     interpretation += "May suggest cognitive deficiencies, impulse control issues, or emotional volatility.<br>";
  179.                 }
  180.                 break;
  181.             case "F3 and F4 Negative percentage difference between Theta/Beta ratio (3-7 Hz / 16-25 Hz)":
  182.                 if (d.value > 20) {
  183.                     interpretation += "May indicate emotional volatility, anger management problems, or emotional impulse control issues.<br>";
  184.                 }
  185.                 break;
  186.             case "F3 and F4 Alpha (8-12 Hz) increase during Eyes Closed at F4":
  187.                 // No specific interpretation provided
  188.                 interpretation += "<br>";
  189.                 break;
  190.             case "F3 and F4 Beta (16-25 Hz) difference between F4 and F3":
  191.                 // No specific interpretation provided
  192.                 interpretation += "<br>";
  193.                 break;
  194.             case "F3 and F4 Alpha (8-12 Hz) difference between F3 and F4":
  195.                 // No specific interpretation provided
  196.                 interpretation += "<br>";
  197.                 break;
  198.             case "F3 and F4 Theta/Beta ratio (3-7 Hz / 16-25 Hz) above 2.2 and percentage change greater than 15%":
  199.                 if (d.value > 2.2) {
  200.                     interpretation += "May suggest cognitive deficiencies, impulse control issues, or emotional volatility.<br>";
  201.                 }
  202.                 break;
  203.             case "F3 and F4 Difference between Theta/Beta ratio (3-7 Hz / 16-25 Hz) at F3 and F4 above a specific threshold (e.g., 20%)":
  204.                 // No specific interpretation provided
  205.                 interpretation += "<br>";
  206.                 break;
  207.             case "F3 and F4 Alpha (8-12 Hz) increase during Eyes Closed at F3 or F4 within a specific range (e.g., 1.2-1.6)":
  208.                 // No specific interpretation provided
  209.                 interpretation += "<br>";
  210.                 break;
  211.             case "F3 and F4 Lower Theta/Beta ratio at F3 or F4 (3-7 Hz / 16-25 Hz) to below 2.2":
  212.                 if (d.value < 2.2) {
  213.                    interpretation += "To address cognitive deficiencies, impulse control, and emotional volatility.<br>";
  214.                 }
  215.                 break;
  216.             case "F3 and F4 Train Alpha Eyes Closed at F4 (8-12 Hz) to between 1.2-1.6":
  217.                 // No specific interpretation provided
  218.                 interpretation += "<br>";
  219.                 break;
  220.             case "F3 and F4 Reduce F3/F4 Theta and Beta percentage difference":
  221.                 // No specific interpretation provided
  222.                 interpretation += "<br>";
  223.                 break;
  224.  
  225.             // Interpretations for FZ
  226.             case "FZ HiBeta/Beta ratio (28-40 Hz / 16-25 Hz) below 0.45":
  227.                 if (d.value < 0.45) {
  228.                    interpretation += "May indicate excessive passivity.<br>";
  229.                 }
  230.                 break;
  231.             case "FZ HiBeta/Beta ratio (28-40 Hz / 16-25 Hz) above 0.55":
  232.                 if (d.value > 0.55) {
  233.                     interpretation += "May be associated with stubborn behavior, obsessive-compulsive tendencies, perseveration in autistic spectrum behaviors, or anxiety.<br>";
  234.                 }
  235.                 break;
  236.             case "FZ Sum of HiBeta + Beta above 15":
  237.                 if (d.value > 15) {
  238.                     interpretation += "May indicate perseverative behavior.<br>";
  239.                 }
  240.                 break;
  241.             case "FZ LoAlpha/HiAlpha ratio (8-9 Hz / 11-12 Hz) below 1.5":
  242.                 if (d.value < 1.5) {
  243.                    interpretation += "May suggest cognitive inefficiency, age-related deficits in memory and cognitive processing, or sleep disorders.<br>";
  244.                 }
  245.                 break;
  246.             case "FZ Train HiBeta/Beta ratio at FZ (28-40 Hz / 16-25 Hz) to between 0.45-0.55":
  247.                 // No specific interpretation provided
  248.                 interpretation += "<br>";
  249.                 break;
  250.             case "FZ Decrease Sum of HiBeta + Beta at FZ to below 15":
  251.                 // No specific interpretation provided
  252.                 interpretation += "<br>";
  253.                 break;
  254.             case "FZ Lower LoAlpha/HiAlpha ratio at FZ (8-9 Hz / 11-12 Hz) to below 1.5":
  255.                 // No specific interpretation provided
  256.                 interpretation += "<br>";
  257.                 break;
  258.             case "FZ Alpha (8-12 Hz) range":
  259.                 interpretation += "Associated with relaxation, creativity, and mental imagery.<br>";
  260.                 break;
  261.             case "FZ HiAlpha (11-12 Hz) range":
  262.                 interpretation += "Associated with focused attention and sensorimotor integration.<br>";
  263.                 break;
  264.         }
  265.     });
  266.  
  267.     // Check if interpretation is not empty before returning
  268.     return interpretation.trim() !== "" ? interpretation : "No flagged interpretations.";
  269. }
  270.  
  271. function generateChart() {
  272.     const dataInput = document.getElementById('dataInput').value;
  273.     const parsedData = parseData(dataInput);
  274.  
  275.     // Generate chart
  276.     const ctx = document.getElementById('eegChart').getContext('2d');
  277.     const labels = parsedData.map(d => d.label);
  278.     const values = parsedData.map(d => d.value);
  279.     const chart = new Chart(ctx, {
  280.         type: 'bar',
  281.         data: {
  282.             labels: labels,
  283.             datasets: [{
  284.                 label: 'EEG Data',
  285.                 data: values,
  286.                 backgroundColor: 'rgba(54, 162, 235, 0.2)',
  287.                 borderColor: 'rgba(54, 162, 235, 1)',
  288.                 borderWidth: 1
  289.             }]
  290.         },
  291.         options: {
  292.             scales: {
  293.                 y: {
  294.                     beginAtZero: true
  295.                 }
  296.             }
  297.         }
  298.     });
  299.  
  300.     // Display interpretations
  301.     const interpretationDiv = document.getElementById('interpretation');
  302.     interpretationDiv.innerHTML = interpretData(parsedData);
  303. }
  304. </script>
  305.  
  306. </body>
  307. </html>
  308.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement