searchlight with no target model

50 views
Skip to first unread message

Adi Yaniv

unread,
May 30, 2019, 3:30:26 AM5/30/19
to CoSMoMVPA
Hi again :) (i'm really enjoying  using cosmo!)

I used it successfully and managed to preform nice searchlight analysis with a target model. I suspect that my models do not represent the "real life" accurately and would like to preform a searchlight analysis without using a target matrix as a model.
 what i am looking for is running over the whole brain, calculating RDMs - and then  to use  each time only one value from the RDM for mapping.

a quick example: 
my experimental design has 3 conditions: A,B,C, which result in 3*3 dissimilarity matrix.
i would like to compute RDMs for the whole brain, and then get only the value of dissimilarity between A and C (for each voxel, or neighborhood - my data is fMRI data)  - for each subject and then use  cosmo_stack to put all subjects together and transform it back into a vmp map.
then i would like to do the same for the dissimilarity between B and C. 

what would be the best pipeline? 

thanks a lot,
Adi


Nick Oosterhof

unread,
May 30, 2019, 3:37:50 AM5/30/19
to Adi Yaniv, CoSMoMVPA
Greetings,

On Thu, 30 May 2019 at 09:30, Adi Yaniv <adi....@gmail.com> wrote:
Hi again :) (i'm really enjoying  using cosmo!)

great to hear that!
I think cosmo_dissimilarity_matrix_measure is just what you need, together with cosmo_searchlight.
The output will have .samples with 3 (=3*(3-1)/2) rows corresponding to the three pairs.
In the output, .sa.targets1 and .sa.targets2 indicate the pair combination for each corresponding row in .samples


Adi Yaniv

unread,
Jun 3, 2019, 4:42:14 PM6/3/19
to CoSMoMVPA
thanks a lot! it was exactly what i was looking for and it works fine!
hope to see you at OHBM next week :)

Moritz Wurm

unread,
Jun 12, 2019, 9:20:14 AM6/12/19
to cosm...@googlegroups.com
Dear Cosmo community,

Has anyone experience with extracting confusion matrices from time
generalization data?

I am running a time generalization MVPA with 80 x 80 time bins. To get
the confusion matrices I use measure_args.output = 'winner_predictions'.
However, I cannot unflatten it (as I would do it with
measure_args.output = 'accuracy' ):

K>> cosmo_unflatten(ds_res)
Error using cosmo_isfield>single_isfield (line 115)
Struct does not have field .a.fdim

Error in cosmo_isfield (line 71)
            tf(k)=single_isfield(s,name{k},raise);

Error in cosmo_unflatten (line 134)
            cosmo_isfield(ds,{'a.fdim','samples','fa'},true);


If I choose dimension 1, I also get an error:

K>> cosmo_unflatten(ds_res,1)
Error using cosmo_unflatten>unflatten_features (line 200)
Duplicate features at #1 and #2

Error in cosmo_unflatten (line 150)
    [arr, dim_labels,dim_values]=unflatten_features(samples, ...



If I simply apply cosmo_confusion_matrix(ds), I get a single matrix
only. My workaround is a loop:

for i=1:length(ds_res.a.sdim.values{1})
            for j=1:length(ds_res.a.sdim.values{2})
                    cond_idx = find(ds_res.sa.train_time==i &
ds_res.sa.test_time==j);
                    ds=cosmo_slice(ds_res,cond_idx);
                    MAT(i,j,:,:)=cosmo_confusion_matrix(ds);
             end
end

Unfortunately, this is extremely slow. So I am wondering: is there a
better/faster way to do it?
I'd be very thankful for your suggestions!

Best wishes,
Moritz


Nick Oosterhof

unread,
Jun 15, 2019, 5:55:51 AM6/15/19
to Moritz Wurm, CoSMoMVPA
Hi Moritz,

It's a bit hard to tell what's going wrong here. Using dim=1 seems the right approach.
What is the output of cosmo_disp(rs_res)?

best,
Nick 

Moritz Wurm

unread,
Jun 18, 2019, 3:54:59 AM6/18/19
to Nick Oosterhof, CoSMoMVPA
Hi Nick
Thanks for your response and sorry for the late reply.

Find below the output of cosmo_disp(rs_res). However, I noticed that it works when I compute correlation matrices instead of confusion matrices, which might be more useful for my purposes anyway. So this is not an urgent issue anymore.

Thanks!
Best,
Moritz

.samples                                 
  [ NaN                                  
    NaN                                  
    NaN                                  
     :                                   
      4                                  
      4                                  
      4 ]@2764800x1                      
.sa                                      
  .targets                               
    [ 1                                  
      1                                  
      1                                  
      :                                  
      4                                  
      4                                  
      4 ]@2764800x1                      
  .test_time                             
    [  1                                 
       1                                 
       1                                 
       :                                 
      80                                 
      80                                 
      80 ]@2764800x1                     
  .train_time                            
    [  1                                 
       1                                 
       1                                 
       :                                 
      80                                 
      80                                 
      80 ]@2764800x1                     
  .transpose_ids                         
    [  1                                 
       2                                 
       3                                 
       :                                 
      78                                 
      79                                 
      80 ]@2764800x1                     
  .trialinfo                             
    [ 3                                  
      3                                  
      3                                  
      :                                  
      6                                  
      6                                  
      6 ]@2764800x1                      
.a                                       
  .sdim                                  
    .labels                              
      { 'train_time'  'test_time' }      
    .values                              
      { [ 0.0145         [ 0.0145        
          0.0345           0.0345        
          0.0545           0.0545        
             :                :          
            1.55             1.55        
            1.57             1.57        
            1.59 ]@80x1      1.59 ]@80x1 }


and this is the dataset when I use correlation matrices instead of confusion matrices:

.samples                                                       
  [  0.634                                                     
     0.306                                                     
     0.629                                                     
       :                                                       
     0.107                                                     
     0.127                                                     
    -0.226 ]@230400x1                                          
.sa                                                            
  .half1                                                       
    [ 1                                                        
      2                                                        
      3                                                        
      :                                                        
      6                                                        
      7                                                        
      8 ]@230400x1                                             
  .half2                                                       
    [ 1                                                        
      1                                                        
      1                                                        
      :                                                        
      8                                                        
      8                                                        
      8 ]@230400x1                                             
  .test_time                                                   
    [  1                                                       
       1                                                       
       1                                                       
       :                                                       
      45                                                       
      45                                                       
      45 ]@230400x1                                            
  .train_time                                                  
    [  1                                                       
       1                                                       
       1                                                       
       :                                                       
      80                                                       
      80                                                       
      80 ]@230400x1                                            
.a                                                             
  .sdim                                                        
    .labels                                                    
      { 'half1'  'half2'  'train_time'  'test_time' }          
    .values                                                    
      { [ 1        [ 1        [ 0.0145         [ 0.0145        
          2          2          0.0345           0.0345        
          3          3          0.0545           0.0545        
          :          :             :                :          
          6          6            1.55            0.854        
          7          7            1.57            0.874        
          8 ]@8x1    8 ]@8x1      1.59 ]@80x1     0.894 ]@45x1 }
Reply all
Reply to author
Forward
0 new messages