run operations on datasets skl

%% Dataset Basics
% Run operations on datasets
%
% #   For CoSMoMVPA's copyright information and license terms,   #
% #   see the COPYING file distributed with CoSMoMVPA.           #

%% Load data and set targets
% Load data as before setting targets and chunks appropriately

config=cosmo_config();
data_path=fullfile(config.tutorial_data_path,'ak6','s01');
mask_fn = fullfile(data_path, 'vt_mask.nii');
data_fn = fullfile(data_path, 'glm_T_stats_perrun.nii');
ds=cosmo_fmri_dataset(data_fn, 'mask', mask_fn);

% set ds.sa.targets (trial conditions) to the 60x1 column vector:
% [ 1 2 3 4 5 6 1 2 3 ... 5 6 ]'
%%%% >>> Your code here <<< %%%%

% set ds.sa.chunks (acquistion run number) to the 60x1 column vector:
% [ 1 1 1 1 1 1 2 2 2 ... 10 10 ]'
%%%% >>> Your code here <<< %%%%

% set the labels
labels = repmat({   'monkey';
                    'lemur';
                    'mallard';
                    'warbler';
                    'ladybug';
                    'lunamoth'},10,1);
ds.sa.labels = labels;

% This particular ROI has a few constant features due to
% not-so-agressive masking, so remove constant features
ds=cosmo_remove_useless_data(ds);




%% Various slicing operations on the samples

% only get data in chunks 1 and 2.
% Make a logical mask indicating where .ds.chunks less than or equal to 2
% and store the result in a variable 'chunks12_msk'.
% Then use cosmo_slice to select these samples and assign it to a variable
% 'ds_chunks12'
% (hint: you can use cosmo_match or just '<=')
%%%% >>> Your code here <<< %%%%

% As above, but only select data with targets equal to 1 or 3.
% (corresponding to {'monkey','mallard'})
%%%% >>> Your code here <<< %%%%

%% Get sample indices for primates and bugs
% Get the sample indices that correspond to primates and bugs,
% and assign the result to variables 'primate_idx' and 'bug_idx'

%%%% >>> Your code here <<< %%%%



% Slice the dataset
% use the indices in 'primate_idx' and 'bug_idx' as input to cosmo_slice,
% and store the result in 'primate_ds' and 'bug_ds', respectively.

%%%% >>> Your code here <<< %%%%

%% Subtract mean pattern
% Find the mean pattern for primates and bugs and subtract the bug pattern from
% the primate pattern

%%%% >>> Your code here <<< %%%%

%% Store and visualize the results
% Finally save the result as a dataset with the original header.
% Just replace ds.samples with the result and remove the sample attributes.
% Then convert back to nifti and save it using the cosmo_map2fmri function.

%%%% >>> Your code here <<< %%%%

%% Plot results
figure
%... using cosmo_plot_slices

%%%% >>> Your code here <<< %%%%

% ... using AFNI, FSL, or Matlab's imagesc
figure

%%%% >>> Your code here <<< %%%%