Advertisement
El_Chaderino

Clinical Q expanded overlay

Dec 17th, 2023
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 12.69 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4.  
  5. def plot_1020_electrodes():
  6.     fig, ax = plt.subplots(figsize=(8, 8))
  7.     ax.set_aspect('equal')
  8.     ax.axis('off')
  9.  
  10.     # Set up electrode locations
  11.     electrode_locations = {
  12.         'CZ': (0, 0),
  13.         'O1': (-2.11, -3.04),
  14.         'F3': (-2, 2),
  15.         'F4': (2, 2),
  16.         'FZ': (0, 2),
  17.         'PZ': (0, -2),
  18.         'C3': (-1, 0),
  19.         'C4': (1, 0),
  20.         'P3': (-1, -2),
  21.         'P4': (1, -2),
  22.         'OZ': (0, -3),
  23.         'T5': (-2, -1),
  24.         'T6': (2, -1),
  25.         'PO7': (-2.5, -1.5),
  26.         'PO8': (2.5, -1.5),
  27.         'FP1': (-2, 3),
  28.         'FP2': (2, 3),
  29.         'AFZ': (0, 3),
  30.         'CPZ': (0, -1)
  31.     }
  32.  
  33.     # Plot modified head outline
  34.     head_outline = plt.Circle((0, 0), radius=4, edgecolor='black', facecolor='white', linewidth=1.5)
  35.     ax.add_artist(head_outline)
  36.  
  37.     # Plot electrode spots and text
  38.     electrode_texts = {}
  39.     for electrode, (x, y) in electrode_locations.items():
  40.         ax.plot(x, y, 'o', markersize=10, markerfacecolor='white', markeredgecolor='white', markeredgewidth=1.5)
  41.         electrode_texts[electrode] = ax.text(x, y, electrode, ha='center', va='center', fontsize=16, color='blue')
  42.  
  43.     # Electrode area information
  44.     areas = {
  45.         'CZ': {
  46.             'Clinical Q': 'Vertex',
  47.             '10-20 System': 'CZ',
  48.             'Brodmann Area': 'Areas 4 and 6',
  49.             'Function': 'Motor cortex, supplementary motor area',
  50.             'Functional Info': 'Areas 4 and 6 in the vertex region are involved in motor control and supplementary motor functions.',
  51.             'Mental Health Issues': 'Disruptions in this area may affect motor coordination, movement disorders, and be associated with motor-related mental health issues.'
  52.         },
  53.         'O1': {
  54.             'Clinical Q': 'Left Occipital',
  55.             '10-20 System': 'O1',
  56.             'Brodmann Area': 'Area 17',
  57.             'Function': 'Primary visual cortex',
  58.             'Functional Info': 'Area 17 in the left occipital lobe is involved in primary visual processing.',
  59.             'Mental Health Issues': 'Imbalances in this area may impact visual perception, visual processing, and be associated with visual-related mental health issues.'
  60.         },
  61.         'F3': {
  62.             'Clinical Q': 'Left Frontal',
  63.             '10-20 System': 'F3',
  64.             'Brodmann Area': 'Area 6',
  65.             'Function': 'Motor cortex, language production',
  66.             'Functional Info': 'Area 6 in the left frontal lobe is involved in motor control and language production.',
  67.             'Mental Health Issues': 'Disruptions in this area may affect motor coordination, language production, and be associated with motor and language-related mental health issues.'
  68.         },
  69.         'F4': {
  70.             'Clinical Q': 'Right Frontal',
  71.             '10-20 System': 'F4',
  72.             'Brodmann Area': 'Area 6',
  73.             'Function': 'Motor cortex, language production',
  74.             'Functional Info': 'Area 6 in the right frontal lobe is involved in motor control and language production.',
  75.             'Mental Health Issues': 'Disruptions in this area may affect motor coordination, language production, and be associated with motor and language-related mental health issues.'
  76.         },
  77.         'FZ': {
  78.             'Clinical Q': 'Midline Frontal',
  79.             '10-20 System': 'FZ',
  80.             'Brodmann Area': 'Areas 9 and 10',
  81.             'Function': 'Prefrontal cortex, attention, emotional processing',
  82.             'Functional Info': 'Areas 9 and 10 in the midline frontal region are involved in prefrontal cortex functions, attention, and emotional processing.',
  83.             'Mental Health Issues': 'Imbalances in this area may impact attention, emotional processing, and be associated with prefrontal cortex-related mental health issues.'
  84.         },
  85.         'PZ': {
  86.             'Clinical Q': 'Midline Parietal',
  87.             '10-20 System': 'PZ',
  88.             'Brodmann Area': 'Areas 5 and 7',
  89.             'Function': 'Somatosensory cortex, spatial awareness',
  90.             'Functional Info': 'Areas 5 and 7 in the midline parietal region are involved in somatosensory processing and spatial awareness.',
  91.             'Mental Health Issues': 'Disruptions in this area may affect somatosensory processing, spatial awareness, and be associated with somatosensory-related mental health issues.'
  92.         },
  93.         'C3': {
  94.             'Clinical Q': 'Left Central',
  95.             '10-20 System': 'C3',
  96.             'Brodmann Area': 'Areas 3 and 4',
  97.             'Function': 'Motor cortex, sensorimotor integration',
  98.             'Functional Info': 'Areas 3 and 4 in the left central region are involved in motor control and sensorimotor integration.',
  99.             'Mental Health Issues': 'Disruptions in this area may affect motor coordination, movement disorders, and be associated with sensorimotor processing deficits.'
  100.         },
  101.         'C4': {
  102.             'Clinical Q': 'Right Central',
  103.             '10-20 System': 'C4',
  104.             'Brodmann Area': 'Areas 3 and 4',
  105.             'Function': 'Motor cortex, sensorimotor integration',
  106.             'Functional Info': 'Areas 3 and 4 in the right central region are involved in motor control and sensorimotor integration.',
  107.             'Mental Health Issues': 'Disruptions in this area may affect motor coordination, movement disorders, and be associated with sensorimotor processing deficits.'
  108.         },
  109.         'P3': {
  110.             'Clinical Q': 'Left Parietal',
  111.             '10-20 System': 'P3',
  112.             'Brodmann Area': 'Areas 5 and 7',
  113.             'Function': 'Somatosensory cortex, spatial awareness',
  114.             'Functional Info': 'Areas 5 and 7 in the left parietal region are involved in somatosensory processing and spatial awareness.',
  115.             'Mental Health Issues': 'Disruptions in this area may affect somatosensory processing, spatial awareness, and be associated with somatosensory-related mental health issues.'
  116.         },
  117.         'P4': {
  118.             'Clinical Q': 'Right Parietal',
  119.             '10-20 System': 'P4',
  120.             'Brodmann Area': 'Areas 5 and 7',
  121.             'Function': 'Somatosensory cortex, spatial awareness',
  122.             'Functional Info': 'Areas 5 and 7 in the right parietal region are involved in somatosensory processing and spatial awareness.',
  123.             'Mental Health Issues': 'Disruptions in this area may affect somatosensory processing, spatial awareness, and be associated with somatosensory-related mental health issues.'
  124.         },
  125.         'OZ': {
  126.             'Clinical Q': 'Midline Occipital',
  127.             '10-20 System': 'OZ',
  128.             'Brodmann Area': 'Areas 17 and 18',
  129.             'Function': 'Visual cortex, visual processing',
  130.             'Functional Info': 'Areas 17 and 18 in the midline occipital region are involved in visual processing and visual cortex functions.',
  131.             'Mental Health Issues': 'Imbalances in this area may impact visual perception, visual processing, and be associated with visual-related mental health issues.'
  132.         },
  133.         'T5': {
  134.             'Clinical Q': 'Left Temporal',
  135.             '10-20 System': 'T5',
  136.             'Brodmann Area': 'Areas 21 and 22',
  137.             'Function': 'Auditory cortex, language processing',
  138.             'Functional Info': 'Areas 21 and 22 in the left temporal lobe are involved in auditory processing and language-related functions.',
  139.             'Mental Health Issues': 'Disruptions in this area may affect auditory perception, language processing, and be associated with language-related mental health issues.'
  140.         },
  141.         'T6': {
  142.             'Clinical Q': 'Right Temporal',
  143.             '10-20 System': 'T6',
  144.             'Brodmann Area': 'Areas 21 and 22',
  145.             'Function': 'Auditory cortex, language processing',
  146.             'Functional Info': 'Areas 21 and 22 in the right temporal lobe are involved in auditory processing and language-related functions.',
  147.             'Mental Health Issues': 'Disruptions in this area may affect auditory perception, language processing, and be associated with language-related mental health issues.'
  148.         },
  149.         'PO7': {
  150.             'Clinical Q': 'Left Occipital Parietal',
  151.             '10-20 System': 'PO7',
  152.             'Brodmann Area': 'Areas 19 and 39',
  153.             'Function': 'Visual association cortex, language processing',
  154.             'Functional Info': 'Areas 19 and 39 in the left occipital parietal region are involved in visual association and language-related functions.',
  155.             'Mental Health Issues': 'Imbalances in this area may impact visual association, language processing, and be associated with visual and language-related mental health issues.'
  156.         },
  157.         'PO8': {
  158.             'Clinical Q': 'Right Occipital Parietal',
  159.             '10-20 System': 'PO8',
  160.             'Brodmann Area': 'Areas 19 and 39',
  161.             'Function': 'Visual association cortex, language processing',
  162.             'Functional Info': 'Areas 19 and 39 in the right occipital parietal region are involved in visual association and language-related functions.',
  163.             'Mental Health Issues': 'Imbalances in this area may impact visual association, language processing, and be associated with visual and language-related mental health issues.'
  164.         },
  165.         'FP1': {
  166.             'Clinical Q': 'Left Frontopolar',
  167.             '10-20 System': 'FP1',
  168.             'Brodmann Area': 'Areas 9 and 10',
  169.             'Function': 'Prefrontal cortex, attention, emotional processing',
  170.             'Functional Info': 'Areas 9 and 10 in the left frontopolar region are involved in prefrontal cortex functions, attention, and emotional processing.',
  171.             'Mental Health Issues': 'Imbalances in this area may impact attention, emotional processing, and be associated with prefrontal cortex-related mental health issues.'
  172.         },
  173.         'FP2': {
  174.             'Clinical Q': 'Right Frontopolar',
  175.             '10-20 System': 'FP2',
  176.             'Brodmann Area': 'Areas 9 and 10',
  177.             'Function': 'Prefrontal cortex, attention, emotional processing',
  178.             'Functional Info': 'Areas 9 and 10 in the right frontopolar region are involved in prefrontal cortex functions, attention, and emotional processing.',
  179.             'Mental Health Issues': 'Imbalances in this area may impact attention, emotional processing, and be associated with prefrontal cortex-related mental health issues.'
  180.         },
  181.         'AFZ': {
  182.             'Clinical Q': 'Midline Frontopolar',
  183.             '10-20 System': 'AFZ',
  184.             'Brodmann Area': 'Areas 9 and 10',
  185.             'Function': 'Prefrontal cortex, attention, emotional processing',
  186.             'Functional Info': 'Areas 9 and 10 in the midline frontopolar region are involved in prefrontal cortex functions, attention, and emotional processing.',
  187.             'Mental Health Issues': 'Imbalances in this area may impact attention, emotional processing, and be associated with prefrontal cortex-related mental health issues.'
  188.         },
  189.         'CPZ': {
  190.             'Clinical Q': 'Midline Centroparietal',
  191.             '10-20 System': 'CPZ',
  192.             'Brodmann Area': 'Areas 5 and 7',
  193.             'Function': 'Somatosensory cortex, spatial awareness',
  194.             'Functional Info': 'Areas 5 and 7 in the midline centroparietal region are involved in somatosensory processing and spatial awareness.',
  195.             'Mental Health Issues': 'Disruptions in this area may affect somatosensory processing, spatial awareness, and be associated with somatosensory-related mental health issues.'
  196.         }
  197.     }
  198.  
  199.     # Function to handle click events
  200.     def on_click(event):
  201.         for electrode_text in electrode_texts.values():
  202.             if electrode_text.contains(event)[0]:
  203.                 electrode = electrode_text.get_text()
  204.                 if electrode in areas:
  205.                     area_info = areas[electrode]
  206.                     info_text = f"10-20 System: {area_info['10-20 System']}\n\n" \
  207.                                 f"Clinical Q: {area_info['Clinical Q']}\n\n" \
  208.                                 f"Brodmann Area: {area_info['Brodmann Area']}\n\n" \
  209.                                 f"Function: {area_info['Function']}\n\n" \
  210.                                 f"Functional Info: {area_info['Functional Info']}\n\n" \
  211.                                 f"Mental Health Issues: {area_info['Mental Health Issues']}"
  212.                     plt.figure()
  213.                     plt.text(0.5, 0.5, info_text, horizontalalignment='center', verticalalignment='center',
  214.                              fontsize=12)
  215.                     plt.axis('off')
  216.                     plt.show()
  217.                 break
  218.  
  219.     fig.canvas.mpl_connect('button_press_event', on_click)
  220.     plt.show()
  221.  
  222.  
  223. plot_1020_electrodes()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement