Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[![Build Status](https://travis-ci.com/cpp-lln-lab/CPP_BIDS_SPM_pipeline.svg?branch=master)](https://travis-ci.com/cpp-lln-lab/CPP_BIDS_SPM_pipeline)
[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors)
[![DOI](https://zenodo.org/badge/208231636.svg)](https://zenodo.org/badge/latestdoi/208231636)


# Instructions for SPM12 Preprocessing Pipeline

Expand Down
40 changes: 30 additions & 10 deletions batch.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
% __ ____ ____ _ _ _
% / _)( _ \( _ \ | | / \ | )
% ( (_ )___/ )___/ | |_ / _ \ | \
% \__)(__) (__) |___||_/ \_||__)
%
% Thank you for using the CPP lap pipeline - version 0.0.3.
%
% Current list of contributors includes
% Mohamed Rezk
% Rémi Gau
% Olivier Collignon
% Ane Gurtubay
% Marco Barilari
%
% Please cite using the following DOI:
% https://doi.org/10.5281/zenodo.3554332
%
% For bug report, suggestions for improvements or contributions see our github repo:
% https://github.com/cpp-lln-lab/CPP_BIDS_SPM_pipeline

clear
clc

Expand All @@ -18,16 +38,16 @@
checkDependencies();

% copy raw folder into derivatives folder
BIDS_copyRawFolder(opt, 1)
% BIDS_copyRawFolder(opt, 1)

% preprocessing
BIDS_STC(opt);
BIDS_SpatialPrepro(opt);
BIDS_Smoothing(6, opt);
% BIDS_STC(opt);
% BIDS_SpatialPrepro(opt);
% BIDS_Smoothing(6, opt);

% subject level Univariate
BIDS_FFX(1, 6, opt);
BIDS_FFX(2, 6, opt);
% BIDS_FFX(1, 6, opt);
% BIDS_FFX(2, 6, opt);

% group level univariate
BIDS_RFX(1, 6, 6)
Expand All @@ -36,9 +56,9 @@
BIDS_Results(6, 6, opt, 0)

% subject level multivariate
isMVPA=1;
BIDS_FFX(1, 6, opt, isMVPA);
BIDS_FFX(2, 6, opt, isMVPA);
make4Dmaps(6,opt)
% isMVPA=1;
% BIDS_FFX(1, 6, opt, isMVPA);
% BIDS_FFX(2, 6, opt, isMVPA);
% make4Dmaps(6,opt)


63 changes: 41 additions & 22 deletions getOption.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
function opt = getOption()
% __ ____ ____ _ _ _
% / _)( _ \( _ \ | | / \ | )
% ( (_ )___/ )___/ | |_ / _ \ | \
% \__)(__) (__) |___||_/ \_||__)
%
% Thank you for using the CPP lap pipeline - version 0.0.3.
%
% Current list of contributors includes
% Mohamed Rezk
% Rémi Gau
% Olivier Collignon
% Ane Gurtubay
% Marco Barilari
%
% Please cite using the following DOI:
% https://doi.org/10.5281/zenodo.3554332
%
% For bug report, suggestions for improvements or contributions see our github repo:
% https://github.com/cpp-lln-lab/CPP_BIDS_SPM_pipeline


% returns a structure that contains the options chosen by the user to run
% slice timing correction, pre-processing, FFX, RFX.

Expand All @@ -9,18 +30,34 @@
% group of subjects to analyze
opt.groups = {''};
% suject to run in each group
opt.subjects = {[1:2]};
opt.subjects = {[]};


% task to analyze
opt.taskName = 'MotionDecoding';
opt.taskName = 'visMotion';


% The directory where the data are located
opt.dataDir = '/Users/mohamed/Desktop/MotionWorkshop/raw';
opt.dataDir = '/Users/mohamed/Desktop/Data/raw';
opt.dataDir = '/home/remi/BIDS/visMotion/derivatives/';


% specify the model file that contains the contrasts to compute
opt.model.univariate.file = '/home/remi/github/CPP_BIDS_SPM_pipeline/model-visMotionLoc_smdl.json';
opt.model.multivariate.file = '';


% specify the result to compute
opt.result.Steps(1) = struct(...
'Level', 'dataset', ...
'Contrasts', struct(...
'Name', 'VisMot_gt_VisStat', ... % has to match one of the contrast defined in the model json file
'Mask', false, ... % this might need improving if a mask is required
'MC', 'FWE', ... FWE, none, FDR
'p', 0.05, ...
'k', 0, ...
'NIDM', true) );


% Options for slice time correction
% If left unspecified the slice timing will be done using the mid-volume acquisition
% time point as reference.
Expand All @@ -40,26 +77,8 @@
opt.JOBS_dir = fullfile(opt.dataDir, '..', 'derivatives', 'SPM12_CPPL', 'JOBS', opt.taskName);


% specify the model file that contains the contrasts to compute
opt.model.univariate.file = '/Users/mohamed/Documents/GitHub/BIDS_fMRI_scripts/model-motionDecodingUnivariate_smdl.json';
opt.model.multivariate.file = '/Users/mohamed/Documents/GitHub/BIDS_fMRI_scripts/model-motionDecodingMultivariate_smdl.json';


% specify the result to compute
opt.result.Steps(1) = struct(...
'Level', 'dataset', ...
'Contrasts', struct(...
'Name', 'Vis_U', ... % has to match one of the contrast defined in the model json file
'Mask', false, ... % this might need improving if a mask is required
'MC', 'none', ... FWE, none, FDR
'p', 0.05, ...
'k', 0, ...
'NIDM', true) );


% Save the opt variable as a mat file to load directly in the preprocessing
% scripts
save('opt.mat','opt')


end
29 changes: 16 additions & 13 deletions subfun/BIDS_RFX.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function BIDS_RFX(action, mmFunctionalSmoothing, mmConSmoothing, opt, isMVPA)
end

% save the matlabbatch
[~, ~, ~] = mkdir(JOBS_dir);
save(fullfile(JOBS_dir, ...
['jobs_matlabbatch_SPM12_SmoothCon_',...
num2str(mmConSmoothing),'_',...
Expand Down Expand Up @@ -193,6 +194,7 @@ function BIDS_RFX(action, mmFunctionalSmoothing, mmConSmoothing, opt, isMVPA)
fprintf(1,'Create Mean Struct and Mask IMAGES...')

% save the matlabbatch
[~, ~, ~] = mkdir(JOBS_dir);
save(fullfile(JOBS_dir, ...
'jobs_matlabbatch_SPM12_CreateMeanStrucMask.mat'), ...
'matlabbatch')
Expand Down Expand Up @@ -229,7 +231,7 @@ function BIDS_RFX(action, mmFunctionalSmoothing, mmConSmoothing, opt, isMVPA)
% the strrep(Session{j}, 'trial_type.', '') is there to remove
% 'trial_type.' because contrasts against baseline are renamed
% at the subject level
conName = strrep(grpLvlCon{j}, 'trial_type.', '');
conName = rmTrialTypeStr(grpLvlCon{j});

con = con+1;

Expand Down Expand Up @@ -284,11 +286,10 @@ function BIDS_RFX(action, mmFunctionalSmoothing, mmConSmoothing, opt, isMVPA)
fprintf(1,'A DIRECTORY WITH THIS NAME ALREADY EXISTED AND WAS OVERWRITTEN, SORRY \n');
rmdir(fullfile(RFX_FolderName, conName),'s')
end

mkdir(fullfile(RFX_FolderName, conName))

matlabbatch{j}.spm.stats.factorial_design.dir = {...
fullfile(RFX_FolderName,...
grpLvlCon{j}) };
matlabbatch{j}.spm.stats.factorial_design.dir = { fullfile(RFX_FolderName, conName) };

end

% Go to Jobs directory and save the matlabbatch
Expand All @@ -307,10 +308,8 @@ function BIDS_RFX(action, mmFunctionalSmoothing, mmConSmoothing, opt, isMVPA)
matlabbatch = {};

for j = 1:size(grpLvlCon,1)
matlabbatch{j}.spm.stats.fmri_est.spmmat = {...
fullfile(RFX_FolderName,...
grpLvlCon{j},...
'SPM.mat')};
conName = rmTrialTypeStr(grpLvlCon{j});
matlabbatch{j}.spm.stats.fmri_est.spmmat = { fullfile(RFX_FolderName, conName, 'SPM.mat') };
matlabbatch{j}.spm.stats.fmri_est.method.Classical = 1;
end

Expand All @@ -332,10 +331,8 @@ function BIDS_RFX(action, mmFunctionalSmoothing, mmConSmoothing, opt, isMVPA)

% ADD/REMOVE CONTRASTS DEPENDING ON YOUR EXPERIMENT AND YOUR GROUPS
for j = 1:size(grpLvlCon,1)
matlabbatch{j}.spm.stats.con.spmmat = {...
fullfile(RFX_FolderName,...
grpLvlCon{j},...
'SPM.mat')};
conName = rmTrialTypeStr(grpLvlCon{j});
matlabbatch{j}.spm.stats.con.spmmat = {fullfile(RFX_FolderName, conName, 'SPM.mat')};
matlabbatch{j}.spm.stats.con.consess{1}.tcon.name = 'GROUP';
matlabbatch{j}.spm.stats.con.consess{1}.tcon.convec = 1;
matlabbatch{j}.spm.stats.con.consess{1}.tcon.sessrep = 'none';
Expand All @@ -354,3 +351,9 @@ function BIDS_RFX(action, mmFunctionalSmoothing, mmConSmoothing, opt, isMVPA)
end

end



function conName = rmTrialTypeStr(conName)
conName = strrep(conName, 'trial_type.', '');
end
1 change: 1 addition & 0 deletions subfun/checkDependencies.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
function checkDependencies()
% Checks that that the right dependencies are installed. ALso loads the spm defaults.

printCredits()

SPM_main = 'SPM12';
SPM_sub = '7487';
Expand Down
45 changes: 45 additions & 0 deletions subfun/printCredits.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function printCredits()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function will display the credits when the pipeline is run. :-)


version = '0.0.3';

contributors = {...
'Mohamed Rezk',...
'Rémi Gau', ...
'Olivier Collignon',...
'Ane Gurtubay', ...
'Marco Barilari'};

DOI_URL = 'https://doi.org/10.5281/zenodo.3554332';

repoURL = 'https://github.com/cpp-lln-lab/CPP_BIDS_SPM_pipeline';

disp( '____________________________________________________________________________________________');
disp( '____________________________________________________________________________________________');
disp( ' ');
disp( ' __ ____ ____ _ _ _ ');
disp( ' / _)( _ \( _ \ | | / \ | ) ');
disp( '( (_ )___/ )___/ | |_ / _ \ | \ ');
disp( ' \__)(__) (__) |___||_/ \_||__)');
disp( ' ');

splash = 'Thank you for using the CPP lap pipeline - version %s. ';
fprintf(splash, version)
fprintf('\n\n');

fprintf('Current list of contributors includes\n')
for iCont = 1:numel(contributors)
fprintf(' %s\n', contributors{iCont})
end
fprintf('\b\n\n')

fprintf('Please cite using the following DOI: \n %s\n\n', DOI_URL)

fprintf('For bug report, suggestions for improvements or contributions see our github repo: \n %s\n\n', repoURL)


disp( '____________________________________________________________________________________________');
disp( '____________________________________________________________________________________________');

fprintf('\n\n')

end