Regarding making anatomical ROIS in MNI space to use in COSMO MVPA

181 views
Skip to first unread message

Avantika Mathur

unread,
Aug 3, 2019, 6:41:06 PM8/3/19
to CoSMoMVPA
Hi,

I want to use anatomical ROI mask for  in COSMO MVPA. I used WFU PICKATLAS to make ROI masks. When I use these masks in COSMO I get the following error::. It seems the ROI are not in MNI space. Can someone please suggest me the correct method of making ROIS in MNI space from an anatomical atlas like Harvard-Ofxord or AAL? 

>> % Load data in cosmo data structure
ds_ROI=cosmo_fmri_dataset(ds_all,'mask',mask_fn);
Error using cosmo_fmri_dataset>check_datasets_in_same_space (line 480)
.a.fdim mismatch between data and mask

Error in cosmo_fmri_dataset>align_mask_to_ds_space (line 474)
    check_datasets_in_same_space(ds_mask, ds_hdr);

Error in cosmo_fmri_dataset>get_user_ds_mask (line 453)
    ds_mask=align_mask_to_ds_space(ds_mask, ds_hdr);

Error in cosmo_fmri_dataset>convert_to_dataset (line 255)
    mask_ds=get_user_ds_mask(params, ds_hdr_full);

Error in cosmo_fmri_dataset (line 195)
    ds=convert_to_dataset(filename, params);


raffaele tucciarelli

unread,
Aug 5, 2019, 5:40:48 AM8/5/19
to Avantika Mathur, CoSMoMVPA
Hi Avantika,

I guess you checked this already, but are your data in MNI space? Can you load the mask separately as a cosmo structure and have a look at both datasets (e.g. .a.fdim)?
You could also overlap the ROI on your functional data to be sure they are in the same space (and where you would expect the ROI to be).

Raffaele

--
You received this message because you are subscribed to the Google Groups "CoSMoMVPA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cosmomvpa+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/cosmomvpa/7567691b-0581-4fd3-bfaf-74716ad7e2ea%40googlegroups.com.

Nick Oosterhof

unread,
Aug 5, 2019, 2:55:25 PM8/5/19
to raffaele tucciarelli, Avantika Mathur, CoSMoMVPA
On Mon, 5 Aug 2019 at 11:40, raffaele tucciarelli <rtucci...@gmail.com> wrote:
I guess you checked this already, but are your data in MNI space? Can you load the mask separately as a cosmo structure and have a look at both datasets (e.g. .a.fdim)?
You could also overlap the ROI on your functional data to be sure they are in the same space (and where you would expect the ROI to be).

yes, these are good suggestions by Raffaele. Also there might be a difference in .a.vol, in particular the voxel size and/or locations of the voxels. If you could provide us with the output of cosmo_disp(ds) and cosmo_disp(ds_mask) --- where ds and ds_mask are the results of applying cosmo_fmri_dataset to the functional data and the mask --- then this may help in finding out why you get this message. 

Avantika Mathur

unread,
Aug 5, 2019, 3:06:41 PM8/5/19
to Nick Oosterhof, raffaele tucciarelli, CoSMoMVPA
Hi,

I made the ROI using FSL now (as per Jens's suggestion), and still end up with the same error message above.

Opening the mask and dataset gives different dimensions in .a.fdim. My data was preprocessed in SPM and normalized to MNI space. What I load here is single subject con file from SPM. 

As per Raffaele's suggestion I could " overlap the ROI on your functional data to be sure they are in the same space (and where you would expect the ROI to be)". How can I do that?

Thanks in advance for your help.
The following is the structure using cosmo_disp::

>> cosmo_disp(ds_mask)
.a                                                                    
  .vol                                                                
    .mat                                                              
      [ -1         0         0        91                              
         0         1         0      -127                              
         0         0         1       -73                              
         0         0         0         1 ]                            
    .xform                                                            
      'mni_152'                                                        
    .dim                                                              
      [ 182       218       182 ]                                      
  .fdim                                                                
    .labels                                                            
      { 'i'                                                            
        'j'                                                            
        'k' }                                                          
    .values                                                            
      { [ 1         2         3  ...  180       181       182 ]@1x182  
        [ 1         2         3  ...  216       217       218 ]@1x218  
        [ 1         2         3  ...  180       181       182 ]@1x182 }
.sa                                                                    
  struct (empty)                                                      
.samples                                                              
  [ 0         0         0  ...  0         0         0 ]@1x7221032      
.fa                                                                    
  .i                                                                  
    [ 1         2         3  ...  180       181       182 ]@1x7221032  
  .j                                                                  
    [ 1         1         1  ...  218       218       218 ]@1x7221032  
  .k                                                                  
    [ 1         1         1  ...  182       182       182 ]@1x7221032

cosmo_disp(ds1)
.a                                                                  
  .vol                                                              
    .dim                                                            
      [ 73        87        73 ]                                    
    .mat                                                            
      [ -2.5         0         0      92.5                          
           0       2.5         0      -128                          
           0         0       2.5     -74.5                          
           0         0         0         1 ]                        
  .fdim                                                              
    .labels                                                          
      { 'i'                                                          
        'j'                                                          
        'k' }                                                        
    .values                                                          
      { [ 1         2         3  ...  71        72        73 ]@1x73  
        [ 1         2         3  ...  85        86        87 ]@1x87  
        [ 1         2         3  ...  71        72        73 ]@1x73 }
.sa                                                                  
  .labels                                                            
    { 'Rhyming1vsControl'                                            
      'Rhyming2vsControl'                                            
      'Rhyming3vsControl'                                            
               :                                                    
      'Semantic6vsControl'                                          
      'Semantic7vsControl'                                          
      'Semantic8vsControl' }@16x1                                    
  .fname                                                            
    { '/Volume ... 001.nii'                                          
      '/Volume ... 002.nii'                                          
      '/Volume ... 003.nii'                                          
               :                                                    
      '/Volume ... 014.nii'                                          
      '/Volume ... 015.nii'                                          
      '/Volume ... 016.nii' }@16x1                                  
.samples                                                            
  [ NaN       NaN       NaN  ...  NaN       NaN       NaN            
    NaN       NaN       NaN  ...  NaN       NaN       NaN            
    NaN       NaN       NaN  ...  NaN       NaN       NaN            
     :         :         :         :         :         :            
    NaN       NaN       NaN  ...  NaN       NaN       NaN            
    NaN       NaN       NaN  ...  NaN       NaN       NaN            
    NaN       NaN       NaN  ...  NaN       NaN       NaN ]@16x463623
.fa                                                                  
  .i                                                                
    [ 1         2         3  ...  71        72        73 ]@1x463623  
  .j                                                                
    [ 1         1         1  ...  87        87        87 ]@1x463623  
  .k                                                                
    [ 1         1         1  ...  73        73        73 ]@1x463623 

Nick Oosterhof

unread,
Aug 5, 2019, 3:42:49 PM8/5/19
to Avantika Mathur, raffaele tucciarelli, CoSMoMVPA
On Mon, 5 Aug 2019 at 21:06, Avantika Mathur <avantik...@gmail.com> wrote:
I made the ROI using FSL now (as per Jens's suggestion), and still end up with the same error message above.

Opening the mask and dataset gives different dimensions in .a.fdim. My data was preprocessed in SPM and normalized to MNI space. What I load here is single subject con file from SPM. 

As per Raffaele's suggestion I could " overlap the ROI on your functional data to be sure they are in the same space (and where you would expect the ROI to be)". How can I do that?

Thanks in advance for your help.
The following is the structure using cosmo_disp::

>> cosmo_disp(ds_mask)
.a                                                                    
  .vol                                                                
    .mat                                                              
      [ -1         0         0        91                              
         0         1         0      -127                              
         0         0         1       -73                              
         0         0         0         1 ]                            
    .xform                                                            
      'mni_152'                                                        
    .dim                                                              
      [ 182       218       182 ]                                      
  [......]
cosmo_disp(ds1)
.a                                                                  
  .vol                                                              
    .dim                                                            
      [ 73        87        73 ]                                    
    .mat                                                            
      [ -2.5         0         0      92.5                          
           0       2.5         0      -128                          
           0         0       2.5     -74.5                          
           0         0         0         1 ]                        
 

Your functional data has 2.5mm isotropic resolution with 73 x 87 x 73 voxels, but your mask has 1mm isotropic resolution with 182 x 218 x 182 voxels (this is a typical resolution for a T1 anatomical scan). With cosmo_fmri_dataset you can't use a mask that has a different resolution than the functional data (... or a different number of voxels in the spatial dimensions, or voxels at a different location). 

My suggestion is to resample the mask to the same dimensions as the functional data. CoSMoMVPA does not have this functionality. I know that AFNI can do it (3dsample with -master option), and most likely FSL and SPM can do this as well although I'm not familiar enough with these programs to give more detailed advice. 
I hope that helps.


Avantika Mathur

unread,
Aug 5, 2019, 3:53:32 PM8/5/19
to Nick Oosterhof, raffaele tucciarelli, CoSMoMVPA
Thank you for the information Nick. 
I created a functional mask using IMCALC in SPM by multiplying the ROI image with the subject mask img (i1.*i2). It seems my initial ROI were correct, thus ROI can be made using any toolbox. 

Now, using this functional mask, loads the dataset with the specified ROI without any error.

Using cosmo_disp function on the new functional ROI mask gives following results::
I hope I am on right track now.
...............................................................................................................................................
cosmo_disp(ds)
.a                                                                  
  .vol                                                              
    .mat                                                            
      [ -2.5         0         0      92.5                          
           0       2.5         0      -128                          
           0         0       2.5     -74.5                          
           0         0         0         1 ]                        
    .xform                                                          
      'aligned_anat'                                                
    .dim                                                            
      [ 73        87        73 ]                                    
  .fdim                                                              
    .labels                                                          
      { 'i'                                                          
        'j'                                                          
        'k' }                                                        
    .values                                                          
      { [ 1         2         3  ...  71        72        73 ]@1x73  
        [ 1         2         3  ...  85        86        87 ]@1x87  
        [ 1         2         3  ...  71        72        73 ]@1x73 }
.sa                                                                  
  struct (empty)                                                    
.samples                                                            
  [ 0         0         0  ...  0         0         0 ]@1x463623    
.fa                                                                  
  .i                                                                
    [ 1         2         3  ...  71        72        73 ]@1x463623  
  .j                                                                
    [ 1         1         1  ...  87        87        87 ]@1x463623  
  .k                                                                
    [ 1         1         1  ...  73        73        73 ]@1x463623 
Reply all
Reply to author
Forward
0 new messages