Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. from __future__ import print_function
  2. import mne
  3.  
  4. data_path = mne.datasets.sample.data_path()
  5. subjects_dir = data_path + '/subjects'
  6. subject = 'sample'
  7. fname_inv = data_path + '/MEG/sample/sample_audvis-meg-oct-6-meg-inv.fif'
  8.  
  9. # Read the source space. Normally, you would use mne.read_source_spaces for
  10. # this, but the sample data does not include a '-src.fif' file. Therefore, in
  11. # this example, we take it from the inverse operator.
  12. inverse_operator = mne.minimum_norm.read_inverse_operator(fname_inv)
  13. src = inverse_operator['src'] # get the source space
  14.  
  15. # Read a label
  16. aparc_label_name = 'bankssts-lh'
  17. label = mne.read_labels_from_annot(subject, parc='aparc',
  18. subjects_dir=subjects_dir,
  19. regexp=aparc_label_name)[0]
  20.  
  21. # The source space contains a distance matrix that measures the distance (in
  22. # meters) from each vertex to each other vertex.
  23. hemi = 0 # Left hemisphere
  24. dist = src[hemi]['dist']
  25.  
  26. # Reduce the distance matrix to only the vertices present in the label
  27. label_dist = dist[label.vertices, :][:, label.vertices]
  28.  
  29. # How big is the label? Here, defined as the maximum distance between two
  30. # vertices in the label.
  31. print('Size of the label:', label_dist.max(), 'm')
  32.  
  33. # Or in milimeters
  34. print('Size of the label:', label_dist.max() * 1000, 'mm')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement