-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathcliPreprocess.m
More file actions
91 lines (73 loc) · 2.17 KB
/
cliPreprocess.m
File metadata and controls
91 lines (73 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
function cliPreprocess(varargin)
% Preprocess a bids dataset.
%
% Type ``bidspm help`` for more info.
%
% TODO make sure that options defined in JSON or passed as a structure
% overrides any other arguments
% (C) Copyright 2023 bidspm developers
args = inputParserForPreprocess();
try
parse(args, varargin{:});
catch ME
displayArguments(varargin{:});
rethrow(ME);
end
if ~strcmp(args.Results.analysis_level, 'subject')
errorHandling(mfilename(), ...
'noGroupLevelPreproc', ...
'"analysis_level" must be "subject" for preprocessing', ...
false);
end
validate(args);
opt = getOptionsFromCliArgument(args);
opt.pipeline.type = 'preproc';
opt = checkOptions(opt);
saveOptions(opt);
if ~opt.anatOnly && (isempty(opt.taskName) || numel(opt.taskName) > 1)
errorHandling(mfilename(), ...
'onlyOneTaskForPreproc', ...
'A single task must be specified for preprocessing', ...
false);
end
bidsReport(opt);
% TODO adapt boiler plate for anat only
boilerplate(opt, ...
'outputPath', fullfile(opt.dir.output, 'reports'), ...
'pipelineType', 'preprocess', ...
'verbosity', 0);
if opt.boilerplateOnly
return
end
bidsCopyInputFolder(opt);
if ~opt.anatOnly
bidsCheckVoxelSize(opt);
if opt.dummyScans > 0
tmpOpt = opt;
tmpOpt.dir.input = tmpOpt.dir.preproc;
bidsRemoveDummies(tmpOpt, ...
'dummyScans', tmpOpt.dummyScans, ...
'force', false);
end
if opt.useFieldmaps
bidsCreateVDM(opt);
end
if ~opt.stc.skip
bidsSTC(opt);
end
end
bidsSpatialPrepro(opt);
if opt.fwhm.func > 0
opt.query.desc = 'preproc';
if opt.dryRun
msg = ['"dryRun" set to "true", so smoothing will be skipped', ...
' as it requires the output of spatial preprocessing to run.'];
logger('WARNING', msg, ...
'options', opt, ...
'filename', mfilename(), ...
'id', 'skipSmoothingInDryRun');
return
end
bidsSmoothing(opt);
end
end