External Email - Use Caution
Hi all,
I have a problem with morphing labels from "fsaverage" to subject space. I am trying to run the following code:
import mne
import numpy as np
import scipy.io as sio
from mne import datasets
from mne.minimum_norm import read_inverse_operator
datasets.fetch_hcp_mmp_parcellation(subjects_dir=subjects_dir,
verbose=True)
datasets.fetch_aparc_sub_parcellation(subjects_dir=subjects_dir,
verbose=True)
label_list =['superiortemporal_9-lh']
labels = mne.read_labels_from_annot('fsaverage', 'aparc_sub', 'lh', subjects_dir=subjects_dir)
for l in label_list:
subj_list = ['p9u']
frequency_band='4Hz8Hz'
for run in range(1, 11):
for subject in subj_list:
this_label = [label for label in labels if label.name == l][0]
inverse_operator = read_inverse_operator(fname_inv + subject +'/'+ subject + '_run' + str(run) + '-'+ frequency_band+'-inv.fif')
src = inverse_operator['src']
morphed_label=this_label.copy().morph('fsaverage', subject, 5, 5, subjects_dir, 1,None)
fname= '/m/nbe/scratch/alex/private/emilia/stc-meg/stc/' + subject +'/'+ subject + '_run' + str(run) + '_'+ frequency_band+'_source_estimate-lh.stc'
stc = mne.read_source_estimate(fname)
label_data= stc.extract_label_time_course(morphed_label,src,mode='mean_flip')
label_mean=np.mean(label_data,axis=0)
sio.savemat(output_path + subject + '_'+frequency_band+'_run' + str(run) +'_'+ this_label.name + '_mean.mat', {'vect':label_mean})
However, when I try to run the command "morphed_label=this_label.copy().morph('fsaverage', subject, 5, 5, subjects_dir, 1,None)" I get the following error:
Traceback (most recent call last):
File "<ipython-input-2-231684f5069e>", line 27, in <module>
morphed_label=this_label.copy().morph('fsaverage', subject, 5, 5, subjects_dir, 1,None)
File "</home/bromane1/.local/lib/python3.6/site-packages/mne/externals/decorator.py:decorator-gen-216>", line 2, in morph
File "/home/bromane1/.local/lib/python3.6/site-packages/mne/utils/_logging.py", line 89, in wrapper
return function(*args, **kwargs)
File "/home/bromane1/.local/lib/python3.6/site-packages/mne/label.py", line 583, in morph
subjects_dir=subjects_dir, warn=False).apply(stc)
File "</home/bromane1/.local/lib/python3.6/site-packages/mne/externals/decorator.py:decorator-gen-280>", line 2, in compute_source_morph
File "/home/bromane1/.local/lib/python3.6/site-packages/mne/utils/_logging.py", line 88, in wrapper
return function(*args, **kwargs)
File "/home/bromane1/.local/lib/python3.6/site-packages/mne/morph.py", line 188, in compute_source_morph
xhemi=xhemi)
File "/home/bromane1/.local/lib/python3.6/site-packages/mne/morph.py", line 865, in _compute_morph_matrix
vertices_to[hemi_to], maps[hemi_from], warn=warn)
File "/home/bromane1/.local/lib/python3.6/site-packages/mne/morph.py", line 1069, in _morph_buffer
data_morphed = maps[nearest, :] * data
File "/share/apps2/anaconda/anaconda3/latest/envs/neuroimaging/lib/python3.6/site-packages/scipy/sparse/csr.py", line 316, in __getitem__
P = extractor(row, self.shape[0]) # [[1,2],j] or [[1,2],1:2]
File "/share/apps2/anaconda/anaconda3/latest/envs/neuroimaging/lib/python3.6/site-packages/scipy/sparse/csr.py", line 270, in extractor
min_indx, max_indx = check_bounds(indices, N)
File "/share/apps2/anaconda/anaconda3/latest/envs/neuroimaging/lib/python3.6/site-packages/scipy/sparse/csr.py", line 256, in check_bounds
raise IndexError('index (%d) out of range' % max_indx)
IndexError: index (160155) out of range
The dataset consists of 48 subjects out of which 4 subjects have this problem. I have checked the Freesurfer reconstruction of these subjects and they look OK. Do you happen to know what could have gone wrong here? Or do you have any ideas on where I should start looking for errors?
Thank you!
- Emilia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20190626/58e0cdf1/attachment.html