[Mne_analysis] Errors when morphing labels

Broman Emilia emilia.broman at aalto.fi
Thu Jun 27 02:42:50 EDT 2019
Search archives:

        External Email - Use Caution        

Hi Eric, 

Thank you for your answer! The morph-function works when I change the grade from 5 to [inv[’src][0][‘vertno’],inv[’src’][1][‘vertno’]]. 

The mne.morph_labels function works as well. However, I have one question about the surf_name parameter. How does the choice of surface (white, pial… ) affect the results? 

Thank you so much for the help!
Emilia 



> On 26 Jun 2019, at 19.00, mne_analysis-request at nmr.mgh.harvard.edu wrote:
> 
> Send Mne_analysis mailing list submissions to
> 	mne_analysis at nmr.mgh.harvard.edu
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
> or, via email, send a message with subject or body 'help' to
> 	mne_analysis-request at nmr.mgh.harvard.edu
> 
> You can reach the person managing the list at
> 	mne_analysis-owner at nmr.mgh.harvard.edu
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Mne_analysis digest..."
> 
> 
> Today's Topics:
> 
>   1. Errors when morphing labels (Broman Emilia)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Wed, 26 Jun 2019 14:11:36 +0000
> From: Broman Emilia <emilia.broman at aalto.fi>
> Subject: [Mne_analysis] Errors when morphing labels
> To: "mne_analysis at nmr.mgh.harvard.edu"
> 	<mne_analysis at nmr.mgh.harvard.edu>
> Message-ID: <8d338e678aed4e3eb63544b956749d87 at aalto.fi>
> Content-Type: text/plain; charset="iso-8859-1"
> 
>        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-0001.html 
> 
> ------------------------------
> 
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
> 
> End of Mne_analysis Digest, Vol 137, Issue 25
> *********************************************




More information about the Mne_analysis mailing list