Contents
Dataset basics
- For CoSMoMVPA's copyright information and license terms, #
- see the COPYING file distributed with CoSMoMVPA. #
config=cosmo_config();
data_path=fullfile(config.tutorial_data_path,'ak6','s01');
fn=fullfile(data_path,'glm_T_stats_perrun.nii');
ds = cosmo_fmri_dataset(fn);
targets=repmat((1:6)',10,1);
ds.sa.targets = targets;
cosmo_check_dataset(ds);
chunks = zeros(60,1);
for i=1:10
idxs=(i-1)*6+(1:6);
chunks(idxs)=i;
end
ds.sa.chunks = chunks;
cosmo_check_dataset(ds);
labels = repmat({ 'monkey';
'lemur';
'mallard';
'warbler';
'ladybug';
'lunamoth'},10,1);
ds.sa.labels = labels;
cosmo_check_dataset(ds);
Overview of the dataset
fprintf('\nOverview of dataset:\n');
cosmo_disp(ds)
Overview of 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
.labels
{ 'monkey'
'lemur'
'mallard'
:
'warbler'
'ladybug'
'lunamoth' }@60x1
.samples
[ 0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
: : : : : :
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0 ]@60x275200
.fa
.i
[ 1 2 3 ... 78 79 80 ]@1x275200
.j
[ 1 1 1 ... 80 80 80 ]@1x275200
.k
[ 1 1 1 ... 43 43 43 ]@1x275200
Apply mask to dataset
fn_mask=fullfile(data_path,'vt_mask.nii');
ds_mask=cosmo_fmri_dataset(fn_mask);
assert(isequal(ds_mask.fa,ds.fa));
mask_indices=find(ds_mask.samples);
ds_masked=cosmo_slice(ds, mask_indices, 2);
cosmo_disp(ds_masked);
.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
.labels
{ 'monkey'
'lemur'
'mallard'
:
'warbler'
'ladybug'
'lunamoth' }@60x1
.samples
[ 0 0 0 ... 0.669 1.78 2.42
0 0 0 ... 1.06 1.61 0.943
0 0 0 ... 1.51 1.75 3.08
: : : : : :
0 0 0 ... 0.491 1.1 1.78
0 0 0 ... 0.687 1.88 2.72
0 0 0 ... 2.86 4.04 4.28 ]@60x400
.fa
.i
[ 51 53 54 ... 28 29 29 ]@1x400
.j
[ 24 24 24 ... 25 25 26 ]@1x400
.k
[ 2 2 2 ... 9 9 9 ]@1x400
Now use cosmo_fmri_dataset with all input parameters
ds_masked_alt=cosmo_fmri_dataset(fn,'mask',fn_mask,...
'targets',targets,...
'chunks',chunks);
ds_masked_alt.sa.labels=labels;
assert(isequal(ds_masked_alt,ds_masked));