Advertisement
El_Chaderino

Radar Chart v2 Example for EEG Visualization

Sep 16th, 2024
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.60 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from math import pi
  4.  
  5. # Function to create radar chart
  6. def create_radar_chart(title, data, labels):
  7.     num_vars = len(labels)
  8.  
  9.     # Compute angle for each axis
  10.     angles = np.linspace(0, 2 * np.pi, num_vars, endpoint=False).tolist()
  11.  
  12.     # The radar chart is circular, so complete the loop
  13.     data += data[:1]
  14.     angles += angles[:1]
  15.  
  16.     # Create polar plot
  17.     fig, ax = plt.subplots(figsize=(6, 6), subplot_kw=dict(polar=True))
  18.  
  19.     # Draw the outline of the radar chart
  20.     ax.fill(angles, data, color='blue', alpha=0.25)
  21.     ax.plot(angles, data, color='blue', linewidth=2)
  22.  
  23.     # Fill the background with white
  24.     ax.set_facecolor('white')
  25.  
  26.     # Draw labels on the outer circle
  27.     ax.set_yticklabels([])
  28.     ax.set_xticks(angles[:-1])
  29.     ax.set_xticklabels(labels, size=13)
  30.  
  31.     # Add a title
  32.     ax.set_title(title, size=15, color='blue', y=1.1)
  33.  
  34.     plt.show()
  35.  
  36. # Data for each site (CZ, O1, F3, F4, FZ)
  37. cz_data = [8.90, 2.79, 5.50, 0.51, 8.29, 5.07, 5.73, 0.88, 10.16]
  38. o1_data = [7.08, 7.37, 4.17, 22.97, 7.23, 7.90, 0.92, 10.46]
  39. f3_data = [9.66, 7.63, 1.27, 1.02, 26.77, 9.48, 1.27, 10.46]
  40. f4_data = [6.95, 6.85, 1.01, 0.79, 22.65, 8.85, 1.01, 10.45]
  41. fz_data = [8.90, 2.79, 5.50, 0.51, 8.29, 5.07, 5.73, 0.88, 10.16]
  42.  
  43. # Labels for the parameters
  44. labels = ['Delta 2 Hz EC', 'HiBeta Amp', 'Beta Amp', 'HiBeta/Beta', 'Sum HiBeta+Beta',
  45.           'LoAlpha Amp', 'HiAlpha Amp', 'LoAlpha/HiAlpha', 'Alpha Peak Freq']
  46.  
  47. # Create radar charts for all sites
  48. create_radar_chart("CZ Radar Chart", cz_data, labels)
  49. create_radar_chart("O1 Radar Chart", o1_data, labels)
  50. create_radar_chart("F3 Radar Chart", f3_data, labels)
  51. create_radar_chart("F4 Radar Chart", f4_data, labels)
  52. create_radar_chart("FZ Radar Chart", fz_data, labels)
  53.  
  54. #Key for Understanding the Radar Charts:
  55.  
  56. Radial Axis (0% to 100%): The performance of each parameter relative to a predefined normal range. The closer the value is to the outer boundary (100%), the closer it is to the upper end of the normal range.
  57.  
  58. Parameters: Represent the frequency band or amplitude values like Delta 2 Hz, HiBeta Amplitude, Beta Amplitude, Alpha Peak Frequency, etc.
  59.  
  60. Highlighted Region (Shaded area): Shows the actual performance of the site’s EEG parameters. If this area is smaller or shifted towards the center, it indicates underperformance in those specific parameters.
  61.  
  62. Dashed Circles: Represent the normalized benchmarks or thresholds for performance. Points closer to the center indicate potential underperformance, while points near the outer circle suggest good performance.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement