Contents

Dataset Basics (setting sample attributes)

  1. For CoSMoMVPA's copyright information and license terms, #
  2. see the COPYING file distributed with CoSMoMVPA. #
% Set the targets and the chunks
%
% There are 10 runs with 6 volumes per run. The runs are vertically stacked one
% above the other. The six volumes in each run correspond to the stimuli:
% 'monkey','lemur','mallard','warbler','ladybug','lunamoth', in that order. Add
% numeric targets labels (samples atribute) such that 1 corresponds to 'monkey',
% 2 corresponds to 'lemur', etc. Then add numeric chunks (another samples
% attribute) so that 1 corresponds to run1, 2 corresponds to run2, etc.

config=cosmo_config();
data_path=fullfile(config.tutorial_data_path,'ak6','s01');

Load the dataset 'glm_T_stats_perrun.nii' masked with 'brain_mask.nii'

>@@>

mask_fn = fullfile(data_path, 'brain_mask.nii');
data_fn = fullfile(data_path, 'glm_T_stats_perrun.nii');
ds=cosmo_fmri_dataset(data_fn, 'mask', mask_fn);
% <@@<

set targets

%remember that targets are part of ds.sa and that they are stored in a
%column vector
% >@@>
ds.sa.targets = repmat(1:6, [1, 10])'; %10 times labels 1 to 6, column vector
% <@@<

set chunks

%remember that chunks are part of ds.sa and that they are stored in a
%column vector
% >@@>
chunks = repmat(1:10, [6, 1]);
chunks = chunks(:); %flatten matrix to a column vector
ds.sa.chunks = chunks;
% <@@<

Show the results

print the dataset

fprintf('\nDataset:\n')
cosmo_disp(ds)
Dataset:
.a                                                                        
  .vol                                                                    
    .mat                                                                  
      [ -3         0         0       121                                  
         0         3         0      -114                                  
         0         0         3     -11.1                                  
         0         0         0         1 ]                                
    .xform                                                                
      'scanner_anat'                                                      
    .dim                                                                  
      [ 80        80        43 ]                                          
  .fdim                                                                   
    .labels                                                               
      { 'i'                                                               
        'j'                                                               
        'k' }                                                             
    .values                                                               
      { [ 1         2         3  ...  78        79        80 ]@1x80       
        [ 1         2         3  ...  78        79        80 ]@1x80       
        [ 1         2         3  ...  41        42        43 ]@1x43 }     
.sa                                                                       
  .targets                                                                
    [ 1                                                                   
      2                                                                   
      3                                                                   
      :                                                                   
      4                                                                   
      5                                                                   
      6 ]@60x1                                                            
  .chunks                                                                 
    [  1                                                                  
       1                                                                  
       1                                                                  
       :                                                                  
      10                                                                  
      10                                                                  
      10 ]@60x1                                                           
.samples                                                                  
  [  0.933  0.000495       2.1  ...   0.681     0.626     0.421           
    -0.772     0.117      1.73  ...   0.723     0.892       1.7           
     0.621      1.52     -0.25  ...  -0.341    -0.832    -0.546           
       :        :         :             :         :         :             
     -2.37     -1.92    -0.879  ...   0.784      0.67     0.522           
    -0.261     0.351   -0.0767  ...    2.81      2.27    -0.947           
     -1.29    -0.964    -0.966  ...   0.827     0.833     0.991 ]@60x43822
.fa                                                                       
  .i                                                                      
    [ 35        36        44  ...  46        47        47 ]@1x43822       
  .j                                                                      
    [ 17        17        17  ...  35        35        36 ]@1x43822       
  .k                                                                      
    [ 1         1         1  ...  39        39        39 ]@1x43822        

print the sample attributes

fprintf('\nSample attributes (in full):\n')
cosmo_disp(ds.sa,'edgeitems',Inf); %'edgeitems determine how much of a
                                   % matrix is displayed. Try different values.
Sample attributes (in full):
.targets
  [ 1   
    2   
    3   
    4   
    5   
    6   
    1   
    2   
    3   
    4   
    5   
    6   
    1   
    2   
    3   
    4   
    5   
    6   
    1   
    2   
    3   
    4   
    5   
    6   
    1   
    2   
    3   
    4   
    5   
    6   
    1   
    2   
    3   
    4   
    5   
    6   
    1   
    2   
    3   
    4   
    5   
    6   
    1   
    2   
    3   
    4   
    5   
    6   
    1   
    2   
    3   
    4   
    5   
    6   
    1   
    2   
    3   
    4   
    5   
    6 ] 
.chunks 
  [  1  
     1  
     1  
     1  
     1  
     1  
     2  
     2  
     2  
     2  
     2  
     2  
     3  
     3  
     3  
     3  
     3  
     3  
     4  
     4  
     4  
     4  
     4  
     4  
     5  
     5  
     5  
     5  
     5  
     5  
     6  
     6  
     6  
     6  
     6  
     6  
     7  
     7  
     7  
     7  
     7  
     7  
     8  
     8  
     8  
     8  
     8  
     8  
     9  
     9  
     9  
     9  
     9  
     9  
    10  
    10  
    10  
    10  
    10  
    10 ]

print targets and chunks next to each other

fprintf('\nTargets and chunks attributes (in full):\n')
nsamples=size(ds.samples,1);
fprintf('sample #   target   chunk\n');
index_target_chunks=[(1:nsamples)', ds.sa.targets,ds.sa.chunks];
cosmo_disp(index_target_chunks,'edgeitems',Inf);
Targets and chunks attributes (in full):
sample #   target   chunk
[  1         1         1  
   2         2         1  
   3         3         1  
   4         4         1  
   5         5         1  
   6         6         1  
   7         1         2  
   8         2         2  
   9         3         2  
  10         4         2  
  11         5         2  
  12         6         2  
  13         1         3  
  14         2         3  
  15         3         3  
  16         4         3  
  17         5         3  
  18         6         3  
  19         1         4  
  20         2         4  
  21         3         4  
  22         4         4  
  23         5         4  
  24         6         4  
  25         1         5  
  26         2         5  
  27         3         5  
  28         4         5  
  29         5         5  
  30         6         5  
  31         1         6  
  32         2         6  
  33         3         6  
  34         4         6  
  35         5         6  
  36         6         6  
  37         1         7  
  38         2         7  
  39         3         7  
  40         4         7  
  41         5         7  
  42         6         7  
  43         1         8  
  44         2         8  
  45         3         8  
  46         4         8  
  47         5         8  
  48         6         8  
  49         1         9  
  50         2         9  
  51         3         9  
  52         4         9  
  53         5         9  
  54         6         9  
  55         1        10  
  56         2        10  
  57         3        10  
  58         4        10  
  59         5        10  
  60         6        10 ]