Skip to content

Commit

Permalink
Merge pull request #461 from cpp-lln-lab/remi-get_task_and_space_from…
Browse files Browse the repository at this point in the history
…_model

[ENH] use BIDS stats model to select input task, space and override options
  • Loading branch information
Remi-Gau authored Jan 4, 2022
2 parents 27c5a6b + c116c8d commit 150602f
Show file tree
Hide file tree
Showing 81 changed files with 506 additions and 459 deletions.
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ authors:
orcid: "https://orcid.org/0000-0002-0174-9326"
affiliation: "Université de Montréal"

- family-names: "Cerpelloni"
- family-names: "Cerpelloni"
given-names: "Filippo"
orcid: "https://orcid.org/0000-0001-8070-5753"
affiliation: "Université catholique de Louvain"
Expand Down
8 changes: 2 additions & 6 deletions demos/MoAE/moae_01_preproc.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
clear;
clc;

download_data = true;
clean = true;
download_data = false;
clean = false;

try
run ../../initCppSpm.m;
Expand All @@ -20,12 +20,8 @@

reportBIDS(opt);

opt.pipeline.type = 'preproc';

bidsCopyInputFolder(opt);

bidsSTC(opt);

bidsSpatialPrepro(opt);

anatomicalQA(opt);
Expand Down
2 changes: 2 additions & 0 deletions demos/MoAE/moae_03_create_roi_extract_data.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
subLabel = '01';

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

%% Get the con image to extract data
% we can do this by using the "label-XXXX"
Expand Down
6 changes: 4 additions & 2 deletions demos/MoAE/moae_04_slice_display.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
subLabel = '01';

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

use_schema = false;
BIDS_ROI = bids.layout(opt.dir.roi, use_schema);
Expand Down Expand Up @@ -78,8 +80,8 @@

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

%% Display the layers
Expand Down
59 changes: 0 additions & 59 deletions demos/MoAE/moae_create_roi_extract_data.m

This file was deleted.

1 change: 0 additions & 1 deletion demos/MoAE/moae_get_option_fmriprep_preproc.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
opt.space = {'MNI152NLin2009cAsym'};

opt.query.desc = {'preproc', 'confounds'};
% opt.query.space = opt.space;

%% DO NOT TOUCH
opt = checkOptions(opt);
Expand Down
4 changes: 0 additions & 4 deletions demos/MoAE/moae_get_option_stats.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
opt.dir.roi = fullfile(opt.dir.derivatives, 'cpp_spm-roi');
opt.dir.stats = fullfile(opt.dir.derivatives, 'cpp_spm-stats');

opt.pipeline.type = 'stats';

opt.space = {'IXI549Space'};

opt.model.file = fullfile(fileparts(mfilename('fullpath')), ...
'models', 'model-MoAE_smdl.json');
% to add the hrf temporal derivative = [1 0]
Expand Down
3 changes: 2 additions & 1 deletion demos/MoAE/models/model-MoAE_smdl.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"BIDSModelVersion": "1.0.0",
"Description": "contrasts to compute for the FIL MoAE dataset",
"Input": {
"task": "auditory"
"task": "auditory",
"space": "IXI549Space"
},
"Nodes": [
{
Expand Down
1 change: 1 addition & 0 deletions demos/face_repetition/face_rep_03_roi_analysis.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
end

opt = face_rep_get_option_results();
opt.taskName = {'facerepetition'};

opt.roi.atlas = 'wang';
opt.roi.name = {'V1v', 'V1d'};
Expand Down
2 changes: 0 additions & 2 deletions demos/face_repetition/face_rep_get_option.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
opt.dir.raw = fullfile(fileparts(mfilename('fullpath')), 'outputs', 'raw');
opt.dir.derivatives = fullfile(opt.dir.raw, '..', 'derivatives');

opt.pipeline.type = 'preproc';

%% DO NOT TOUCH
opt = checkOptions(opt);
saveOptions(opt);
Expand Down
5 changes: 0 additions & 5 deletions demos/face_repetition/face_rep_get_option_results.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@

opt = [];

opt.taskName = 'facerepetition';
opt.verbosity = 1;

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

opt.pipeline.type = 'stats';

opt.space = {'IXI549Space'};

opt.model.file = fullfile( ...
fileparts(mfilename('fullpath')), ...
'models', ...
Expand Down
2 changes: 0 additions & 2 deletions demos/face_repetition/face_rep_resolution.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

for iResolution = 2:1:3

opt.pipeline.type = 'preproc';
opt.pipeline.name = ['cpp_spm-res' num2str(iResolution)];

% set the final output resolution
Expand Down Expand Up @@ -70,7 +69,6 @@

bidsSmoothing(FWHM, opt);

opt.pipeline.type = 'stats';
opt.pipeline.name = ['cpp_spm-stats-res' num2str(iResolution)];
opt = checkOptions(opt);

Expand Down
5 changes: 3 additions & 2 deletions demos/face_repetition/models/model-faceRepetition_smdl.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"BIDSModelVersion": "1.0.0",
"Description": "model for face repetition to check resampling effects",
"Input": {
"task": "facerepetition"
"task": "facerepetition",
"space": "IXI549Space"
},
"Nodes": [
{
Expand Down Expand Up @@ -82,4 +83,4 @@
]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@
]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@
]
}
]
}
}
8 changes: 8 additions & 0 deletions docs/source/_static/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Making figures for the doc

Making DAGs (directed acyclic graphs) with makefile and
[makefile2graph](https://github.com/lindenb/makefile2graph).

```
make -Bnd | make2graph | dot -Tpng -o out.png
```
36 changes: 36 additions & 0 deletions docs/source/_static/bidsSegmentSkullstrip/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.PHONY: all sub-01_T1w.nii setBatchSegmentation.m setBatSkullstripping.m bidsRename.m

all: sub-01_space-individual_label-GM_probseg.nii

# Rename
sub-01_space-individual_label-GM_probseg.nii: bidsRename.m c1sub-01_T1w.nii

sub-01_space-individual_label-WM_probseg.nii: bidsRename.m c2sub-01_T1w.nii

sub-01_space-individual_label-CSF_probseg.nii: bidsRename.m c3sub-01_T1w.nii

sub-01_from-IXI549Space_to-T1w_mode-image_xfm.nii: bidsRename.m iysub-01_T1w.nii

sub-01_from-T1w_to-IXI549Space_mode-image_xfm.nii: bidsRename.m ysub-01_T1w.nii


# Skullstripping
sub-01_space-individual_desc-skullstripped_T1w.nii: setBatSkullstripping.m msub-01_T1w.nii c1sub-01_T1w.nii c2sub-01_T1w.nii c3sub-01_T1w.nii

sub-01_space-individual_label-brain_mask.nii: setBatSkullstripping.m msub-01_T1w.nii c1sub-01_T1w.nii c2sub-01_T1w.nii c3sub-01_T1w.nii


# Segmentation
msub-01_T1w.nii: setBatchSegmentation.m sub-01_T1w.nii

c1sub-01_T1w.nii: setBatchSegmentation.m sub-01_T1w.nii

c2sub-01_T1w.nii: setBatchSegmentation.m sub-01_T1w.nii

c3sub-01_T1w.nii: setBatchSegmentation.m sub-01_T1w.nii

sub-01_label-T1w_segparam: setBatchSegmentation.m sub-01_T1w.nii

ysub-01_T1w.nii: setBatchSegmentation.m sub-01_T1w.nii

iysub-01_T1w.nii: setBatchSegmentation.m sub-01_T1w.nii
59 changes: 59 additions & 0 deletions lib/utils/iqr_method.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
function [I] = iqr_method(a, out)
%
% Returns a logical vector that flags outliers as 1s based
% on the IQR (interquantile range) methods described in Wilcox 2012 p 96-97.
%
% Uses Carling's modification of the boxplot rule.
%
% An observation Xi is declared an outlier if:
%
% Xi<M-k(q2-q1) or Xi>M+k(q2-q1)
%
% where:
% - M is the sample median
% - k = (17.63n - 23.64) / (7.74n - 3.71),
% - where n is the sample size.
%
% INPUT a is a vector of data
% out determines the thresholding 1 bilateral 2 unilateral
%
% OUTPUTS: I = logical vector with 1s for outliers
% value = IQR, the inter-quartile range
%
% Cyril Pernet - spmup - adapted from Corr_toolbox
% https://github.com/CPernet/spmup
% ----------------------------------------
% (C) Copyright 2016 Cyril Pernet

if nargin == 1
out = 1;
end

a = a(:);
n = length(a);

% inter-quartile range
j = floor(n / 4 + 5 / 12);

y = sort(a);

g = (n / 4) - j + (5 / 12);

q1 = (1 - g) .* y(j) + g .* y(j + 1);

k = n - j + 1;
q2 = (1 - g) .* y(k) + g .* y(k - 1);

value = q2 - q1;

% outliers
M = median(a);
k = (17.63 * n - 23.64) / (7.74 * n - 3.71);
if out == 1
I = a < (M - k * value) | a > (M + k * value);
else
I = a > (M + k * value); % only reject data with a too high value
end
I = I + isnan(a);

end
Loading

0 comments on commit 150602f

Please sign in to comment.