Skip to content

Commit

Permalink
[ENH] allow to copy anat only on raw datasets (#1181)
Browse files Browse the repository at this point in the history
* allow to copy anat only on raw datasets

* update changelog
  • Loading branch information
Remi-Gau authored Jan 6, 2024
1 parent cec3422 commit e72be0b
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/IO/getData.m
Original file line number Diff line number Diff line change
Expand Up @@ -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')));
Expand Down
6 changes: 6 additions & 0 deletions src/cli/cliCopy.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 16 additions & 1 deletion src/workflows/bidsCopyInputFolder.m
Original file line number Diff line number Diff line change
Expand Up @@ -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::
%
Expand Down Expand Up @@ -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;
Expand Down
29 changes: 29 additions & 0 deletions tests/tests_cli/test_bidspm_copy_raw.m
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e72be0b

Please sign in to comment.