diff --git a/CHANGELOG.md b/CHANGELOG.md index 139737b85..0cd576223 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +* [ENH] allow to copy anat only on raw datasets #1181 by @Remi-Gau * [ENH] add option to concatenate runs at subject level to facilite running PPI analysis #1133 by @Remi-Gau * [ENH] allow to run substeps of substeps of the bayesian model selection #1145 by @Remi-Gau * [ENH] add quality control for GLM using the MACS toolbox to give a goodness of fit several other information criteria (AIC, BIC) #1135 by @Remi-Gau diff --git a/src/IO/getData.m b/src/IO/getData.m index f347963f7..79301dcd5 100644 --- a/src/IO/getData.m +++ b/src/IO/getData.m @@ -97,7 +97,7 @@ if isfield(opt, 'taskName') && ~any(ismember(opt.taskName, bids.query(BIDS, 'tasks'))) msg = sprintf(['The task %s that you have asked for ', ... - 'does not exist in this data set.\n', ... + 'does not exist in this dataset.\n', ... 'List of tasks present in this dataset:\n%s'], ... strjoin(opt.taskName), ... bids.internal.create_unordered_list(bids.query(BIDS, 'tasks'))); diff --git a/src/cli/cliCopy.m b/src/cli/cliCopy.m index 8727f15e1..20337b80a 100644 --- a/src/cli/cliCopy.m +++ b/src/cli/cliCopy.m @@ -20,6 +20,12 @@ function cliCopy(varargin) opt.query.desc = {'preproc', 'brain'}; opt.query.suffix = {'T1w', 'bold', 'mask'}; + if opt.anatOnly + opt.query.suffix = {'T1w', 'mask'}; + end + if isempty(opt.taskName) + opt = rmfield(opt, 'taskName'); + end opt.query.space = opt.space; bidsFilterFile = getBidsFilterFile(args); diff --git a/src/workflows/bidsCopyInputFolder.m b/src/workflows/bidsCopyInputFolder.m index 3fda568b1..6a729d23a 100644 --- a/src/workflows/bidsCopyInputFolder.m +++ b/src/workflows/bidsCopyInputFolder.m @@ -3,7 +3,7 @@ function bidsCopyInputFolder(varargin) % Copies data from the ``opt.dir.input`` folder to the ``opt.dir.output`` folder % % Then it will search the derivatives directory for any zipped ``*.gz`` image - % and uncompress the files for the task of interest. + % and uncompress the files of interest. % % USAGE:: % @@ -56,6 +56,21 @@ function bidsCopyInputFolder(varargin) [BIDS, opt] = getData(opt, opt.dir.input); + skip_derivative_entities = false; + if ~isfield(BIDS.description, 'DatasetType') || ... + (isfield(BIDS.description, 'DatasetType') && ... + strcmp(BIDS.description.DatasetType, 'raw')) + skip_derivative_entities = true; + end + if skip_derivative_entities + entities_to_skip = {'hemi', 'space', 'seg', 'res', 'den', 'label', 'desc'}; + for i = 1:numel(entities_to_skip) + if isfield(opt.query, entities_to_skip{i}) + opt.query = rmfield(opt.query, entities_to_skip{i}); + end + end + end + for iModality = 1:numel(opt.query.modality) skip_dependencies = false; diff --git a/tests/tests_cli/test_bidspm_copy_raw.m b/tests/tests_cli/test_bidspm_copy_raw.m new file mode 100644 index 000000000..1b8babe95 --- /dev/null +++ b/tests/tests_cli/test_bidspm_copy_raw.m @@ -0,0 +1,29 @@ +function test_suite = test_bidspm_copy_raw %#ok<*STOUT> + + % (C) Copyright 2023 bidspm developers + + try % assignment of 'localfunctions' is necessary in Matlab >= 2016 + test_functions = localfunctions(); %#ok<*NASGU> + catch % no problem; early Matlab versions can use initTestSuite fine + end + initTestSuite; +end + +function test_copy_anat_only() + + inputPath = fullfile(getMoaeDir(), 'inputs', 'raw'); + + outputPath = tempName(); + + bidspm(inputPath, outputPath, 'subject', ... + 'action', 'copy', ... + 'anat_only', true, ... + 'verbosity', 0); + + BIDS = bids.layout(fullfile(outputPath, 'derivatives', 'bidspm-preproc'), ... + 'verbose', false, ... + 'use_schema', false); + + assertEqual(numel(bids.query(BIDS, 'data')), 1); + +end