Skip to content

Commit cee095b

Browse files
[ENH] make reports more silent (#939)
* fix #931 * make reports less verbose * add more silencing options * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * move testing bidspm * silence test that are missing required data * reduce verbosity in tests * fix typo * use root dir to find octache partials * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent f08441a commit cee095b

File tree

17 files changed

+397
-117
lines changed

17 files changed

+397
-117
lines changed

bidspm.m

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
addParameter(args, 'dry_run', false, isLogical);
3636
addParameter(args, 'bids_filter_file', struct([]), isFileOrStruct);
3737
addParameter(args, 'skip_validation', false, isLogical);
38+
addParameter(args, 'boilerplate_only', false, isLogical);
3839
addParameter(args, 'options', struct([]), isFileOrStruct);
3940
addParameter(args, 'verbosity', 2, isPositiveScalar);
4041

@@ -233,17 +234,20 @@ function preprocess(args)
233234
saveOptions(opt);
234235

235236
bidsReport(opt);
237+
boilerplate(opt, ...
238+
'outputPath', fullfile(opt.dir.output, 'reports'), ...
239+
'pipelineType', 'preproc', ...
240+
'verbosity', 0);
241+
if opt.boilerplate_only
242+
return
243+
end
236244
bidsCopyInputFolder(opt);
237245
if opt.dummy_scans > 0
238246
bidsRemoveDummies(opt, ...
239247
'dummyScans', opt.dummy_scans, ...
240248
'force', false);
241249
end
242250

243-
boilerplate(opt, ...
244-
'outputPath', fullfile(opt.dir.output, 'reports'), ...
245-
'pipelineType', 'preproc', ...
246-
'verbosity', opt.verbosity);
247251
if opt.useFieldmaps && ~opt.anatOnly
248252
bidsCreateVDM(opt);
249253
end
@@ -343,7 +347,10 @@ function stats(args)
343347
boilerplate(opt, ...
344348
'outputPath', fullfile(opt.dir.output, 'reports'), ...
345349
'pipelineType', 'stats', ...
346-
'verbosity', opt.verbosity);
350+
'verbosity', 0);
351+
if opt.boilerplate_only
352+
return
353+
end
347354

348355
if opt.glm.roibased.do
349356

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
{
2+
"Name": "default_vislocalizer_vismotion_model",
3+
"BIDSModelVersion": "1.0.0",
4+
"Description": "default BIDS stats model for vislocalizer/vismotion task",
5+
"Input": {
6+
"task": [
7+
"vislocalizer",
8+
"vismotion"
9+
],
10+
"space": ["individual"]
11+
},
12+
"Nodes": [
13+
{
14+
"Level": "Run",
15+
"Name": "run",
16+
"GroupBy": [
17+
"run",
18+
"session",
19+
"subject"
20+
],
21+
"Transformations": {
22+
"Transformer": "",
23+
"Instructions": [
24+
{
25+
"Name": "",
26+
"Inputs": [""]
27+
}
28+
]
29+
},
30+
"Model": {
31+
"X": [
32+
"trial_type.VisMot",
33+
"trial_type.VisStat",
34+
"1",
35+
"trans_?",
36+
"rot_?",
37+
"non_steady_state_outlier*",
38+
[],
39+
"motion_outlier*"
40+
],
41+
"Type": "glm",
42+
"HRF": {
43+
"Variables": [
44+
"trial_type.VisMot",
45+
"trial_type.VisStat"
46+
],
47+
"Model": "spm"
48+
},
49+
"Options": {
50+
"HighPassFilterCutoffHz": 0.008,
51+
"Mask": {
52+
"desc": ["brain"],
53+
"suffix": ["mask"]
54+
}
55+
},
56+
"Software": {
57+
"SPM": {
58+
"SerialCorrelation": "FAST",
59+
"InclusiveMaskingThreshold": 0.8
60+
}
61+
}
62+
},
63+
"Contrasts": [
64+
{
65+
"Name": "",
66+
"ConditionList": [""],
67+
"Weights": [""],
68+
"Test": "t"
69+
}
70+
],
71+
"DummyContrasts": {
72+
"Test": "t",
73+
"Contrasts": [
74+
"trial_type.VisMot",
75+
"trial_type.VisStat"
76+
]
77+
}
78+
},
79+
{
80+
"Level": "Subject",
81+
"Name": "subject",
82+
"GroupBy": [
83+
"subject",
84+
"contrast"
85+
],
86+
"Model": {
87+
"X": [1],
88+
"Type": "glm"
89+
},
90+
"DummyContrasts": {
91+
"Test": "t"
92+
}
93+
},
94+
{
95+
"Level": "Dataset",
96+
"Name": "dataset",
97+
"GroupBy": [""],
98+
"Model": {
99+
"X": [1],
100+
"Type": "glm"
101+
},
102+
"DummyContrasts": {
103+
"Test": "t"
104+
}
105+
}
106+
],
107+
"Edges": [
108+
{
109+
"Source": "run",
110+
"Destination": "subject"
111+
},
112+
{
113+
"Source": "subject",
114+
"Destination": "dataset"
115+
}
116+
]
117+
}

src/cli/getOptionsFromCliArgument.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
opt.bidsFilterFile = args.Results.bids_filter_file;
4848
end
4949

50+
opt.boilerplate_only = args.Results.boilerplate_only;
51+
5052
opt = overrideFwhm(opt, args);
5153

5254
opt = overrideSpace(opt, args);

src/defaults/checkOptions.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@
8989
% - ``opt.pipeline.type = 'preproc'`` - Switch it to ``stats`` when running GLMs.
9090
% - ``opt.pipeline.name``
9191
%
92+
% - ``opt.boilerplate_only = false`` - Only creates dataset description reports
93+
% and methods description.
94+
% Overwrites previous versions.
95+
%
9296
% - ``opt.zeropad = 2`` - number of zeros used for padding subject numbers, in case
9397
% subjects should be fetched by their number ``1`` and not their label ``O1'``.
9498
%
@@ -260,6 +264,8 @@
260264
fieldsToSet.pipeline.type = '';
261265
fieldsToSet.pipeline.name = 'bidspm';
262266

267+
fieldsToSet.boilerplate_only = false;
268+
263269
fieldsToSet.useBidsSchema = false;
264270

265271
fieldsToSet.dir = struct('input', '', ...

src/messages/bidspmHelp.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function bidspmHelp()
2121
% 'participant_label', {}, ...
2222
% 'dry_run', false, ...
2323
% 'bids_filter_file', struct([]), ...
24+
% 'boilerplate_only', false, ...
2425
% 'verbosity', 2, ...
2526
% 'space', {'individual', 'IXI549Space'}, ...
2627
% 'options', struct([]), ...
@@ -69,6 +70,11 @@ function bidspmHelp()
6970
% :param bids_filter_file: path to JSON file or structure
7071
% :type bids_filter_file: path
7172
%
73+
% :param boilerplate_only: Only creates dataset description reports
74+
% and methods description.
75+
% Se to ``true`` to overwrites previous versions.
76+
% :type boilerplate_only: logical
77+
%
7278
% :param verbosity: can be ``0``, ``1`` or ``2``. Defaults to ``2``
7379
% :type verbosity: positive integer
7480
%
@@ -97,6 +103,7 @@ function bidspmHelp()
97103
% 'participant_label', {}, ...
98104
% 'dry_run', false, ...
99105
% 'bids_filter_file', struct([]), ...
106+
% 'boilerplate_only', false, ...
100107
% 'verbosity', 2, ...
101108
% 'space', {'individual', 'IXI549Space'}, ...
102109
% 'options', struct([]), ...
@@ -228,6 +235,7 @@ function bidspmHelp()
228235
% 'participant_label', {}, ...
229236
% 'dry_run', false, ...
230237
% 'bids_filter_file', struct([]), ...
238+
% 'boilerplate_only', false, ...
231239
% 'verbosity', 2, ...
232240
% 'space', {'individual', 'IXI549Space'}, ...
233241
% 'options', struct([]), ...,

src/messages/logger.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,23 @@
4646
'id', 'wrongLogLevel');
4747
end
4848

49-
format = '\n[%s] bidspm - %s\t\t\t\t%s\n%s\n';
49+
format = '\n[%s] bidspm - %s\t\t\t\t%s\n%s';
5050

5151
logMsg = sprintf(format, ...
5252
datestr(now, 'HH:MM:SS'), ...
5353
logLevel, ...
5454
[filename, ext], ...
5555
msg);
5656

57+
% print file that sent the message
58+
if ismember(logLevel, {'INFO', 'DEBUG'})
59+
if ~strcmp(id, '')
60+
logMsg = sprintf('%s\t\t\t%s', logMsg, id);
61+
end
62+
end
63+
64+
logMsg = [logMsg, '\n'];
65+
5766
if ismember(logLevel, {'ERROR'})
5867
tmpOpt = opt;
5968
tmpOpt.verbosity = 3;

src/parsers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ def common_parser() -> MuhParser:
155155
""",
156156
nargs="+",
157157
)
158+
parser.add_argument(
159+
"--boilerplate_only",
160+
help="""
161+
When set to ``true`` this will only generate figures describing the raw data,
162+
the methods section boilerplate.
163+
""",
164+
action="store_true",
165+
default=False,
166+
)
158167
parser.add_argument(
159168
"--dry_run",
160169
help="""

src/reports/boilerplate.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
% (C) Copyright 2022 bidspm developers
4242

43-
defaultPartialsPath = fullfile(fileparts(mfilename('fullpath')), 'partials');
43+
defaultPartialsPath = fullfile(returnRootDir(), 'src', 'reports', 'partials');
4444

4545
isFolder = @(x) isdir(x);
4646

@@ -161,12 +161,14 @@
161161
output = strjoin(output);
162162
end
163163

164-
%% print to screen
165-
logger('INFO', output, 'options', opt, 'filename', mfilename());
166-
167164
%% print to file
168165
outputFile = printToFile(output, outputPath, pipelineType, modelName);
169166

167+
%% print to screen
168+
logger('INFO', sprintf('methods boilerplate saved at:\n\t%s\n', outputFile), ...
169+
'options', opt, ...
170+
'filename', mfilename());
171+
170172
end
171173

172174
function list = genList(name, elements)

src/workflows/bidsReport.m

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,20 @@ function bidsReport(opt)
2222

2323
opt.pipeline.type = 'preproc';
2424

25+
if ~opt.boilerplate_only && ...
26+
isdir(fullfile(opt.dir.output, 'reports'))
27+
logger('INFO', 'Dataset reports already exist.', ...
28+
'options', opt, ...
29+
'id', mfilename());
30+
return
31+
end
32+
2533
[BIDS, opt] = setUpWorkflow(opt, 'BIDS report');
2634

2735
bids.diagnostic(BIDS, ...
2836
'split_by', {'task'}, ...
29-
'output_path', fullfile(opt.dir.output, 'reports'));
37+
'output_path', fullfile(opt.dir.output, 'reports'), ...
38+
'verbose', false);
3039

3140
for iSub = 1:numel(opt.subjects)
3241

@@ -43,7 +52,7 @@ function bidsReport(opt)
4352
'filter', filter, ...
4453
'output_path', outputDir, ...
4554
'read_nifti', true, ...
46-
'verbose', opt.verbosity > 1);
55+
'verbose', false);
4756
catch
4857
% in case we are dealing with empty files (a la bids-examples, or with
4958
% datalad datasets symlinks)
@@ -56,7 +65,7 @@ function bidsReport(opt)
5665
'filter', filter, ...
5766
'output_path', outputDir, ...
5867
'read_nifti', false, ...
59-
'verbose', opt.verbosity > 1);
68+
'verbose', false);
6069
end
6170

6271
end

0 commit comments

Comments
 (0)