From f2f37f2d73423d9f9c63c17606f1870b9b7701b3 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 24 Jul 2024 18:42:09 +0200 Subject: [PATCH 1/3] make sure setBatchCoregistration takes bids filter into account --- demos/openneuro/Makefile | 10 ++++-- demos/openneuro/ds000114_preproc_run.m | 36 +++++++++++++++++++ demos/openneuro/ds001168_run.m | 4 ++- .../setBatchCoregistrationFuncToAnat.m | 2 ++ .../test_setBatchCoregistrationFuncToAnat.m | 34 ++++++++++++++++++ 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 demos/openneuro/ds000114_preproc_run.m diff --git a/demos/openneuro/Makefile b/demos/openneuro/Makefile index eb3943f8e..c563da7e8 100644 --- a/demos/openneuro/Makefile +++ b/demos/openneuro/Makefile @@ -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 @@ -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 diff --git a/demos/openneuro/ds000114_preproc_run.m b/demos/openneuro/ds000114_preproc_run.m new file mode 100644 index 000000000..72e9bb91e --- /dev/null +++ b/demos/openneuro/ds000114_preproc_run.m @@ -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); diff --git a/demos/openneuro/ds001168_run.m b/demos/openneuro/ds001168_run.m index c4c554c42..f0bc0a477 100644 --- a/demos/openneuro/ds001168_run.m +++ b/demos/openneuro/ds001168_run.m @@ -38,7 +38,8 @@ 'action', 'preprocess', ... 'task', 'rest', ... 'space', {'IXI549Space'}, ... - 'ignore', {'slicetiming'}, ... + 'skip_validation', true, ... + 'ignore', {'slicetiming', 'fieldmaps'}, ... 'options', opt); %% denoise with GLM @@ -50,5 +51,6 @@ 'action', 'stats', ... 'participant_label', {'01'}, ... 'preproc_dir', preproc_dir, ... + 'skip_validation', true, ... 'model_file', model_file, ... 'keep_residuls', true); diff --git a/src/batches/preproc/setBatchCoregistrationFuncToAnat.m b/src/batches/preproc/setBatchCoregistrationFuncToAnat.m index 3666079de..49be369ff 100644 --- a/src/batches/preproc/setBatchCoregistrationFuncToAnat.m +++ b/src/batches/preproc/setBatchCoregistrationFuncToAnat.m @@ -56,6 +56,8 @@ % OTHER IMAGES : DEPENDENCY FROM REALIGNEMENT + opt.query = opt.bidsFilterFile.bold; + [sessions, nbSessions] = getInfo(BIDS, subLabel, opt, 'Sessions'); runCounter = 1; diff --git a/tests/tests_batches/preproc/test_setBatchCoregistrationFuncToAnat.m b/tests/tests_batches/preproc/test_setBatchCoregistrationFuncToAnat.m index ef5447a20..32e0153e7 100644 --- a/tests/tests_batches/preproc/test_setBatchCoregistrationFuncToAnat.m +++ b/tests/tests_batches/preproc/test_setBatchCoregistrationFuncToAnat.m @@ -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'; From 6f5ae78b3c8e65722b355b6b1cf6b3caae053495 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 24 Jul 2024 18:47:45 +0200 Subject: [PATCH 2/3] minor side fixes --- .circleci/config.yml | 2 -- WIP/write_model_graph.py | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 365220b74..ea3b4d055 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -158,8 +158,6 @@ jobs: --space IXI549Space \ --verbosity 3 - cat /home/circleci/outputs - - store_artifacts: path: /home/circleci/outputs diff --git a/WIP/write_model_graph.py b/WIP/write_model_graph.py index 798f99004..a66c14550 100644 --- a/WIP/write_model_graph.py +++ b/WIP/write_model_graph.py @@ -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", ) From 690bf6dc60228681e498aa0881883e7d64314955 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 24 Jul 2024 18:52:56 +0200 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9bd66b65..84ca5bd38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +* [FIX] ensure that {func}`setBatchCoregistrationFuncToAnat` takes into account bids_filter #1295 by @d-ni374 * [FIX] update {func}`createDefaultStatsModel` to use proper `GroupBy` at the dataset level #1248 by @d-ni374 * [FIX] make {func}`getAcquisitionTime` less brittle #1248 by @d-ni374 * [FIX] fix regular expression in {func}`bidsResults` to identify contrasts #1248 by @d-ni374 and #1275 by @Remi-Gau