Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- def plot_1020_electrodes():
- fig, ax = plt.subplots(figsize=(8, 8))
- ax.set_aspect('equal')
- ax.axis('off')
- # Set up electrode locations
- electrode_locations = {
- 'CZ': (0, 0),
- 'O1': (-2.11, -3.04),
- 'F3': (-2, 2),
- 'F4': (2, 2),
- 'FZ': (0, 2)
- }
- # Plot modified head outline
- head_outline = plt.Circle((0, 0), radius=4, edgecolor='black', facecolor='white', linewidth=1.5)
- ax.add_artist(head_outline)
- # Plot electrode spots and text
- electrode_texts = {}
- for electrode, (x, y) in electrode_locations.items():
- ax.plot(x, y, 'o', markersize=10, markerfacecolor='white', markeredgecolor='black', markeredgewidth=1.5)
- electrode_texts[electrode] = ax.text(x, y, electrode, ha='center', va='center', fontsize=10, color='blue')
- # Add electrode areas and information
- areas = {
- 'CZ': {
- 'Clinical Q': 'Vertex',
- '10-20 System': 'CZ',
- 'Brodmann Area': 'Areas 4 and 6',
- 'Function': 'Motor cortex, supplementary motor area',
- 'Functional Info': 'The motor cortex in CZ area controls voluntary movements and is involved in motor planning and coordination.',
- 'Mental Health Issues': 'Imbalances in this area may be associated with motor-related disorders or difficulties in motor control.'
- },
- 'O1': {
- 'Clinical Q': 'Left Occipital',
- '10-20 System': 'O1',
- 'Brodmann Area': 'Area 17',
- 'Function': 'Primary visual cortex',
- 'Functional Info': 'The primary visual cortex in O1 area processes visual information received from the eyes.',
- 'Mental Health Issues': 'Disruptions in this area can affect visual perception and may be related to visual processing disorders or visual hallucinations.'
- },
- 'F3': {
- 'Clinical Q': 'Left Frontal',
- '10-20 System': 'F3',
- 'Brodmann Area': 'Area 6',
- 'Function': 'Motor cortex, language production',
- 'Functional Info': 'The motor cortex in F3 area controls voluntary movements, including those involved in language production.',
- 'Mental Health Issues': 'Imbalances in this area may contribute to difficulties in speech production or language-related disorders.'
- },
- 'F4': {
- 'Clinical Q': 'Right Frontal',
- '10-20 System': 'F4',
- 'Brodmann Area': 'Area 6',
- 'Function': 'Motor cortex, language production',
- 'Functional Info': 'The motor cortex in F4 area controls voluntary movements, including those involved in language production.',
- 'Mental Health Issues': 'Imbalances in this area may contribute to difficulties in speech production or language-related disorders.'
- },
- 'FZ': {
- 'Clinical Q': 'Midline Frontal',
- '10-20 System': 'FZ',
- 'Brodmann Area': 'Areas 9 and 10',
- 'Function': 'Prefrontal cortex, attention, emotional processing',
- 'Functional Info': 'The prefrontal cortex in FZ area plays a role in executive functions, attention, and emotional processing.',
- 'Mental Health Issues': 'Imbalances in this area may impact attention, impulse control, decision-making, and emotional regulation.'
- }
- }
- info_texts = []
- def on_click(event):
- for electrode, (x, y) in electrode_locations.items():
- if x - 0.5 < event.xdata < x + 0.5 and y - 0.5 < event.ydata < y + 0.5:
- if electrode in info_texts:
- info_texts.remove(electrode)
- plt.close(electrode)
- else:
- info = areas[electrode]
- clinical_q = info['Clinical Q']
- system_1020 = info['10-20 System']
- brodmann_area = info['Brodmann Area']
- function = info['Function']
- functional_info = info['Functional Info']
- mental_health_issues = info['Mental Health Issues']
- function_text = f"Clinical Q: {clinical_q}\n10-20 System: {system_1020}\nBrodmann Area: {brodmann_area}\nFunction: {function}"
- functional_info_text = f"\n\nFunctional Information:\n{functional_info}"
- mental_health_issues_text = f"\n\nMental Health Issues:\n{mental_health_issues}"
- info_texts.append(electrode)
- fig2, ax2 = plt.subplots(figsize=(6, 4))
- ax2.set_title(electrode)
- ax2.text(0.5, 0.5, function_text + functional_info_text + mental_health_issues_text,
- ha='center', va='center', fontsize=10, color='blue', wrap=True)
- ax2.axis('off')
- plt.show(block=False)
- fig.canvas.draw_idle()
- fig.canvas.mpl_connect('button_press_event', on_click)
- plt.show()
- # Call the function to display the modified 10/20 electrode diagram
- plot_1020_electrodes()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement