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
12 changes: 11 additions & 1 deletion cpp_spm.m
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,22 @@ function cpp_spm(varargin)
% stats
opt.dir.preproc = args.Results.preproc_dir;
opt.model.file = args.Results.model_file;
opt.glm.roibased.do = args.Results.roi_based;

opt = overrideRoiBased(opt, args);

end

end

function opt = overrideRoiBased(opt, args)
if isfield(opt, 'glm') && isfield(opt.glm, 'roibased') && ...
isfield(opt.glm.roibased, 'do') && opt.glm.roibased.do ~= args.Results.roi_based
overrideWarning('roi_based', convertToString(args.Results.roi_based), ...
'glm.roibased.do', convertToString(opt.glm.roibased.do));
end
opt.glm.roibased.do = args.Results.roi_based;
end

function opt = overrideDryRun(opt, args)
if isfield(opt, 'dryRun') && args.Results.dry_run ~= opt.dryRun
overrideWarning('dry_run', convertToString(args.Results.dry_run), ...
Expand Down
4 changes: 2 additions & 2 deletions demos/MoAE/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $(stats):
$(MATLAB) $(ARG) -r "run('moae_01_bids_app.m');exit;"

$(roi): $(stats) moae_03_create_roi_extract_data.m
$(MATLAB) $(ARG) -r "run('moae_03_create_roi_extract_data.m');exit;"
$(MATLAB) $(ARG) -r "run('moae_02_create_roi_extract_data.m');exit;"

# Octave related recipes
octave_all: octave_roi
Expand All @@ -42,4 +42,4 @@ octave_stats: moae_01_bids_app.m
octave $(OCTFLAGS) --eval "run('moae_01_bids_app.m');exit;"

octave_roi: moae_03_create_roi_extract_data.m
octave $(OCTFLAGS) --eval "run('moae_03_create_roi_extract_data.m');exit;"
octave $(OCTFLAGS) --eval "run('moae_02_create_roi_extract_data.m');exit;"
5 changes: 2 additions & 3 deletions demos/MoAE/moae_01_bids_app.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
% **Preprocessing**
%
% - copies the necessary data from the raw to the derivative folder,
% - runs slice time correction
% - runs spatial preprocessing
%
% those are otherwise handled by the workflows:
%
% - ``bidsCopyInputFolder.m``
% - ``bidsSTC.m``
% - ``bidsSpatialPrepro.m``
%
% **stats**
Expand Down Expand Up @@ -51,7 +49,7 @@

%% Dopwnload the dataset
download_data = false;
clean = true;
clean = false;
download_moae_ds(download_data, clean);

%% PREPROC
Expand Down Expand Up @@ -92,6 +90,7 @@
opt.results(1).csv = true();
opt.results(1).p = 0.05;
opt.results(1).MC = 'FWE';
opt.results(1).binary = true();
opt.results(1).montage.do = true();
opt.results(1).montage.background = struct('suffix', 'T1w', ...
'desc', 'preproc', ...
Expand Down
8 changes: 7 additions & 1 deletion demos/MoAE/moae_02_create_roi_extract_data.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@

subLabel = '01';

opt = moae_get_option_stats();
opt.dir.derivatives = fullfile(fileparts(mfilename('fullpath')), 'outputs', 'derivatives');
opt.dir.roi = fullfile(opt.dir.derivatives, 'cpp_spm-roi');
opt.dir.stats = fullfile(opt.dir.derivatives, 'outputs', 'cpp_spm-stats');

opt.model.file = fullfile(fileparts(mfilename('fullpath')), ...
'models', 'model-MoAE_smdl.json');
opt.pipeline.type = 'stats';

opt = checkOptions(opt);

%% Get the con image to extract data
Expand Down
31 changes: 28 additions & 3 deletions demos/MoAE/moae_03_slice_display.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,40 @@
% (C) Copyright 2021 Remi Gau

clear;
close all;
clc;

addpath(fullfile(pwd, '..', '..'));
cpp_spm();

this_dir = fileparts(mfilename('fullpath'));

subLabel = '01';

opt = moae_get_option_stats();
opt.pipeline.type = 'stats';

opt.dir.raw = fullfile(this_dir, 'inputs', 'raw');
opt.dir.derivatives = fullfile(this_dir, 'outputs', 'derivatives');
opt.dir.preproc = fullfile(opt.dir.derivatives, 'cpp_spm-preproc');

opt.dir.roi = fullfile(opt.dir.derivatives, 'cpp_spm-roi');
opt.dir.stats = fullfile(opt.dir.derivatives, 'cpp_spm-stats');

opt.model.file = fullfile(this_dir, 'models', 'model-MoAE_smdl.json');

% Specify the result to compute
opt.results(1).nodeName = 'run_level';

opt.results(1).name = 'listening';
% MONTAGE FIGURE OPTIONS
opt.results(1).montage.do = true();
opt.results(1).montage.slices = -4:2:16; % in mm
% axial is default 'sagittal', 'coronal'
opt.results(1).montage.orientation = 'axial';
% will use the MNI T1 template by default but the underlay image can be changed.
opt.results(1).montage.background = ...
fullfile(spm('dir'), 'canonical', 'avg152T1.nii');

opt = checkOptions(opt);

use_schema = false;
Expand Down Expand Up @@ -85,10 +110,10 @@
settings = sd_config_settings('init');

% we reuse the details for the SPM montage
settings.slice.orientation = opt.results(1).Output.montage.orientation;
settings.slice.orientation = opt.results(1).montage.orientation;
settings.slice.disp_slices = -15:3:18;
settings.fig_specs.n.slice_column = 4;
settings.fig_specs.title = opt.results(1).Contrasts(1).Name;
settings.fig_specs.title = opt.results(1).name;

%% Display the layers
[settings, p] = sd_display(layers, settings);
16 changes: 12 additions & 4 deletions demos/MoAE/moae_denoise_with_glm.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% This script will run the subject level GLM to denoise the data:
% with no condition in the design matric and only motion confounds.
% with no condition in the design matrix and only motion confounds.
%
% The residuals correspond to the time series of denoised data.
%
Expand All @@ -11,8 +11,16 @@
addpath(fullfile(pwd, '..', '..'));
cpp_spm();

opt = moae_get_option_stats();
opt.model.file = fullfile(pwd, 'models', 'model-denoiseOnly_smdl.json');
bids_dir = fullfile(fileparts(mfilename('fullpath')), 'inputs', 'raw');
output_dir = fullfile(bids_dir, '..', '..', 'outputs', 'derivatives');
preproc_dir = fullfile(output_dir, 'cpp_spm-preproc');

model_file = fullfile(pwd, 'models', 'model-denoiseOnly_smdl.json');

opt.glm.keepResiduals = true;

bidsFFX('specifyAndEstimate', opt);
cpp_spm(bids_dir, output_dir, 'subject', ...
'action', 'stats', ...
'preproc_dir', preproc_dir, ...
'model_file', model_file, ...
'options', opt);
1 change: 1 addition & 0 deletions demos/MoAE/moae_fmriprep.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@
'action', 'stats', ...
'preproc_dir', preproc_dir, ...
'model_file', model_file, ...
'space', {'MNI152NLin6Asym'}, ...
'fwhm', 8, ...
'options', opt);
65 changes: 0 additions & 65 deletions demos/MoAE/moae_get_option_stats.m

This file was deleted.

3 changes: 0 additions & 3 deletions demos/MoAE/models/model-MoAEfmriprep_smdl.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
"Input": {
"task": [
"auditory"
],
"space": [
"MNI152NLin6Asym"
]
},
"Nodes": [
Expand Down
6 changes: 3 additions & 3 deletions demos/MoAE/models/model-denoiseOnly_smdl.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"Nodes": [
{
"Level": "Run",
"Name": "run_level",
"Name": "denoise",
"GroupBy": [
"run",
"subject"
],
"Model": {
"X": [
"trans_?",
"rot_?"
"trans_*",
"rot_*"
],
"Type": "glm",
"Options": {
Expand Down
15 changes: 6 additions & 9 deletions demos/face_repetition/face_rep_02_stats.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,26 @@
addpath(fullfile(pwd, '..', '..'));
cpp_spm();

bids_dir = fullfile(fileparts(mfilename('fullpath')), 'outputs', 'raw');
output_dir = fullfile(bids_dir, '..', 'derivatives');
this_dir = fileparts(mfilename('fullpath'));

bids_dir = fullfile(this_dir, 'outputs', 'raw');
output_dir = fullfile(this_dir, 'outputs', 'derivatives');
preproc_dir = fullfile(output_dir, 'cpp_spm-preproc');

model_file = fullfile(fileparts(mfilename('fullpath')), ...
'models', ...
'model-faceRepetition_smdl.json');
model_file = fullfile(this_dir, 'models', 'model-faceRepetition_smdl.json');

subject_label = '01';

% Specify the result to show

% 1rst result to show
results = defaultResultsStructure();
results.nodeName = 'run_level';

results.nodeName = 'run_level';
results.name = 'faces_gt_baseline_1';

% Specify how you want your output
% (all the following are on false by default)
results.png = true();
results.csv = true();
results.threshSpm = true();
results.binary = true();
results.montage.do = true();
Expand All @@ -73,7 +71,6 @@
results = defaultResultsStructure();
results.nodeName = 'run_level';
results.name = 'motion';
results.png = true();

opt.results(2) = results;

Expand Down
24 changes: 11 additions & 13 deletions demos/face_repetition/face_rep_02_stats_parametric.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,21 @@
clear;
clc;

downloadData = false;

addpath(fullfile(pwd, '..', '..'));

cpp_spm();

%% Gets data and converts it to BIDS
if downloadData
download_face_rep_ds(downloadData);
end
this_dir = fileparts(mfilename('fullpath'));

opt = face_rep_get_option_results();
bids_dir = fullfile(this_dir, 'outputs', 'raw');
output_dir = fullfile(this_dir, 'outputs', 'derivatives');
preproc_dir = fullfile(output_dir, 'cpp_spm-preproc');

opt.model.file = spm_file(opt.model.file, 'basename', 'model-faceRepetitionParametric_smdl');
opt.model.bm = BidsModel('file', opt.model.file);
model_file = fullfile(this_dir, 'models', 'model-faceRepetitionParametric_smdl.json');

bidsFFX('specifyAndEstimate', opt);
% bidsFFX('contrasts', opt);
subject_label = '01';

% bidsResults(opt);
cpp_spm(bids_dir, output_dir, 'subject', ...
'action', 'stats', ...
'participant_label', {subject_label}, ...
'preproc_dir', preproc_dir, ...
'model_file', model_file);
30 changes: 24 additions & 6 deletions demos/face_repetition/face_rep_03_roi_analysis.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,36 @@
addpath(fullfile(pwd, '..', '..'));
cpp_spm();

opt = face_rep_get_option_results();
this_dir = fileparts(mfilename('fullpath'));

%% Create roi

opt.dir.derivatives = fullfile(this_dir, 'outputs', 'derivatives');
opt.dir.preproc = fullfile(opt.dir.derivatives, 'cpp_spm-preproc');
opt.dir.roi = fullfile(opt.dir.derivatives, 'cpp_spm-roi');

opt.roi.atlas = 'wang';
opt.roi.name = {'V1v', 'V1d'};
opt.roi.space = {'individual'};

bidsCreateROI(opt);

opt.fwhm.func = 0;
opt.glm.roibased.do = true;
opt.space = {'individual'};
%% run GLM

bids_dir = fullfile(this_dir, 'outputs', 'raw');
output_dir = fullfile(this_dir, 'outputs', 'derivatives');
preproc_dir = fullfile(opt.dir.derivatives, 'cpp_spm-preproc');

opt.bidsFilterFile.roi.space = 'individual';

bidsFFX('specify', opt);
bidsRoiBasedGLM(opt);
model_file = fullfile(this_dir, 'models', 'model-faceRepetition_smdl.json');

cpp_spm(bids_dir, output_dir, 'subject', ...
'action', 'stats', ...
'participant_label', {'01'}, ...
'preproc_dir', preproc_dir, ...
'model_file', model_file, ...
'roi_based', true, ...
'space', {'individual'}, ...
'options', opt, ...
'fwhm', 0);
Loading