% ** Connectivity decoding toolkit **
% 
% Example main script for one subject to implement connectivity-based decoding
%
% SYNOPSIS
% In short, the method is
% 1) preprocess the data to obtain region-averaged time courses
%     -> connectivityDecoding_preproc.m
% 2) Denoise the data to remove motion and physio-related artefacts
% 3) filter into subbands
%     -> connectivityDecoding_filter.m
% 4) compute dependency between filtered time-series
%     -> connectivityDecoding_dependency.m
% 5) embed into vector space and classify
%     code not published yet
%
% REFERENCE
% If you use this code please cite
% Jonas Richiardi, Hamdi Eryilmaz, Sophie Schwartz, Patrik Vuilleumier,
% and Dimitri Van De Ville, Decoding Brain States from fMRI Connectivity Graphs,
% NeuroImage 56: 616-626, 2011
%
% Where the preprocessing and connectivity matrix computation is based on
%
% S. Achard, R. Salvador, B. Whitcher, J. Suckling, E. Bullmore, A resilient,
% low frequency, small-world human brain functional network with highly
% connected association cortical hubs. J.of Neuroscience 26(1):63???72
%
% REQUIREMENTS
%   - connectivity decoding toolkit helper functions (cdtkhelper)
%
% VERSION
% 0.2, oct 2010
% Jonas Richiardi + Dimitri Van De Ville, Medical Image Processing Laboratory
% - initial public release, only preprocessing, filtering, and dependency
% computation are supported for the moment
% 0.2.1, April 2012
% - correct for 4th argument in preproc script (maxRegionNidx)

%% 1) preprocess to obtain region-averaged time courses
% 1st arg: mean realigned functional volume
% 2nd arg: structural atlas volume
% 3rd arg: functional atlas volume (will be created)
% 4th arg: maximum number of atlas regions to keep (e.g. 90 for the AAL116)
disp('*** Preprocessing...');
TCS=connectivityDecoding_preproc('fMean.nii', 'sa.nii', 'fa.nii',90);

%% 2) Filter into subbands
disp('*** Filtering...');
TCS_filt=connectivityDecoding_filtering(TCS, 4,3);

%% 3) Compute dependencies
disp('*** Computing dependencies...');
CM=connectivityDecoding_dependency(TCS_filt);

%% 4) Embed into vector space
% not released yet