Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] ensure that setBatchCoregistrationFuncToAnat takes into account bids_filter #1295

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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: 0 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ jobs:
--space IXI549Space \
--verbosity 3

cat /home/circleci/outputs

- store_artifacts:
path: /home/circleci/outputs

Expand Down
6 changes: 4 additions & 2 deletions WIP/write_model_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

from bids.modeling.statsmodels import BIDSStatsModelsGraph

root_dir = Path("/home/remi/github/cpp-lln-lab/bidspm")

graph = BIDSStatsModelsGraph(
layout=Path("/home/remi/github/cpp-lln-lab/bidspm/demos/MoAE/inputs/raw"),
model="/home/remi/github/cpp-lln-lab/bidspm/demos/openneuro/models/model-narps_desc-U26C_smdl.json",
layout=root_dir / "demos/MoAE/inputs/raw",
model=root_dir / "demos/openneuro/models/model-narps_desc-U26C_smdl.json",
)


Expand Down
10 changes: 8 additions & 2 deletions demos/openneuro/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ data_ds000001:
cd inputs/ds000001-fmriprep && datalad get sub-0[1-5]/func/*MNI*desc-preproc*.nii.gz -J 12
cd inputs/ds000001-fmriprep && datalad get sub-0[1-3]/func/*MNI*desc-*bold.nii.gz -J 12

data_ds000114_raw:
mkdir -p inputs
cd inputs && datalad install ///openneuro/ds000114
cd inputs/ds000114 && datalad get sub-0[1-2]/ses-*/anat/*T1w*.nii.gz -J 12
cd inputs/ds000114 && datalad get sub-0[1-2]/ses-*/func/*linebisection* -J 12

data_ds000114:
mkdir -p inputs
cd inputs && datalad install ///openneuro/ds000114
Expand All @@ -45,11 +51,11 @@ data_ds000224:
cd inputs/ds000224-fmriprep && datalad get sub-MSC0[1-2]/ses-*/func/*glasslexical*MNI*_mask.nii.gz -J 12
cd inputs/ds000224-fmriprep && datalad get sub-MSC0[1-2]/ses-*/func/*glasslexical*MNI*desc-preproc*bold.nii.gz -J 12


data_ds001168:
mkdir -p inputs
cd inputs && datalad install ///openneuro/ds001168
cd inputs/ds001168 && datalad get ds001168/sub-0[12] -J 2
cd inputs/ds001168 && datalad get sub-0[12]/ses*/anat/*T1w* -J 2
cd inputs/ds001168 && datalad get sub-0[12]/ses*/func/*fullbrain*bold* -J 2

data_ds001734:
mkdir -p inputs
Expand Down
36 changes: 36 additions & 0 deletions demos/openneuro/ds000114_preproc_run.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
% (C) Copyright 2023 bidspm developers

clear;
clc;

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

participant_label = {'01'};
TASK = 'linebisection';

root_dir = fileparts(mfilename('fullpath'));
bids_dir = fullfile(root_dir, 'inputs', 'ds000114');
output_dir = fullfile(root_dir, 'outputs', 'ds000114', 'derivatives');
preproc = fullfile(output_dir, 'bidspm-preproc');

bidspm(bids_dir, output_dir, 'subject', ...
'participant_label', participant_label, ...
'action', 'copy', ...
'task', TASK, ...
'skip_validation', true, ...
'verbosity', 3);

bids_filter_file = struct( ...
'bold', struct('modality', 'func', 'suffix', 'bold', 'ses', 'retest'), ...
't1w', struct('modality', 'anat', 'suffix', 'T1w'));
bidspm(bids_dir, output_dir, 'subject', ...
'participant_label', participant_label, ...
'action', 'preprocess', ...
'task', TASK, ...
'space', {'IXI549Space'}, ...
'skip_validation', true, ...
'ignore', {'slicetiming', 'unwarp'}, ...
'bids_filter_file', bids_filter_file, ...
'fwhm', 6, ...
'verbosity', 3);
4 changes: 3 additions & 1 deletion demos/openneuro/ds001168_run.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
'action', 'preprocess', ...
'task', 'rest', ...
'space', {'IXI549Space'}, ...
'ignore', {'slicetiming'}, ...
'skip_validation', true, ...
'ignore', {'slicetiming', 'fieldmaps'}, ...
'options', opt);

%% denoise with GLM
Expand All @@ -50,5 +51,6 @@
'action', 'stats', ...
'participant_label', {'01'}, ...
'preproc_dir', preproc_dir, ...
'skip_validation', true, ...
'model_file', model_file, ...
'keep_residuls', true);
2 changes: 2 additions & 0 deletions src/batches/preproc/setBatchCoregistrationFuncToAnat.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@

% OTHER IMAGES : DEPENDENCY FROM REALIGNEMENT

opt.query = opt.bidsFilterFile.bold;

[sessions, nbSessions] = getInfo(BIDS, subLabel, opt, 'Sessions');

runCounter = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,40 @@ function test_setBatchCoregistrationFuncToAnat_basic()

end

function test_setBatchCoregistrationFuncToAnat_one_session()

subLabel = '01';

opt = setOptions('vismotion', subLabel);

opt.bidsFilterFile.bold.ses = '02';

BIDS = getLayout(opt);

opt.orderBatches.selectAnat = 1;
opt.orderBatches.realign = 2;

matlabbatch = {};
matlabbatch = setBatchCoregistrationFuncToAnat(matlabbatch, BIDS, opt, subLabel);

nbRuns = 2;

meanImageToUse = 'meanuwr';
otherImageToUse = 'uwrfiles';

expectedBatch = returnExpectedBatch(nbRuns, meanImageToUse, otherImageToUse);
assertEqual( ...
matlabbatch{1}.spm.spatial.coreg.estimate.ref, ...
expectedBatch{1}.spm.spatial.coreg.estimate.ref);
assertEqual( ...
matlabbatch{1}.spm.spatial.coreg.estimate.source, ...
expectedBatch{1}.spm.spatial.coreg.estimate.source);
assertEqual( ...
matlabbatch{1}.spm.spatial.coreg.estimate.other, ...
expectedBatch{1}.spm.spatial.coreg.estimate.other);

end

function test_setBatchCoregistrationFuncToAnat_no_unwarp()

subLabel = '01';
Expand Down
Loading