Skip to content

Commit 1dbbd07

Browse files
authored
[DOC] Improve doc example out stats (#1014)
* improve doc example out stats * [DATALAD] Recorded changes * parametrize tests
1 parent 780481a commit 1dbbd07

File tree

4 files changed

+267
-32
lines changed

4 files changed

+267
-32
lines changed

docs/source/output_files.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,160 @@ bidspm-stats
124124
│   └── sub-blnd01_task-taskName_run-*_onsets.tsv --------------------------
125125
...
126126
```
127+
128+
129+
```
130+
outputs/derivatives/bidspm-stats
131+
├── CHANGES
132+
├── dataset_description.json
133+
├── derivatives
134+
│   └── bidspm-groupStats
135+
│   ├── CHANGES
136+
│   ├── dataset_description.json
137+
│   ├── jobs
138+
│   │   └── <taskLabel>
139+
│   │   └── group
140+
│   │   ├── batch_contrasts_rfx_2023-05-06T12-49.json
141+
│   │   ├── batch_contrasts_rfx_2023_05_06T12_49.m
142+
│   │   ├── batch_group_level_model_specification_estimation_2023-05-06T12-49.json
143+
│   │   └── batch_group_level_model_specification_estimation_2023_05_06T12_49.m
144+
│   ├── LICENSE
145+
│   ├── README.md
146+
│   ├── sub-ALL_task-<taskLabel>_space-<spaceLabel>_FWHM-6_conFWHM-0_node-dataset_contrast-<taskLabel>
147+
│   │   ├── beta_0001.nii
148+
│   │   ├── con_0001.nii
149+
│   │   ├── mask.nii
150+
│   │   ├── ResMS.nii
151+
│   │   ├── RPV.nii
152+
│   │   ├── SPM.mat
153+
│   │   ├── spmT_0001.nii
154+
│   │   ├── task-<taskLabel>_space-<spaceLabel>_desc-afterEstimation_designmatrix.png
155+
│   │   └── task-<taskLabel>_space-<spaceLabel>_desc-beforeEstimation_designmatrix.png
156+
│   └── sub-ALL_task-<taskLabel>_space-<spaceLabel>_FWHM-6_conFWHM-6_node-dataset_contrast-<taskLabel>
157+
│   ├── beta_0001.nii
158+
│   ├── con_0001.nii
159+
│   ├── mask.nii
160+
│   ├── ResMS.nii
161+
│   ├── RPV.nii
162+
│   ├── SPM.mat
163+
│   ├── spmT_0001.nii
164+
│   ├── task-<taskLabel>_space-<spaceLabel>_desc-afterEstimation_designmatrix.png
165+
│   └── task-<taskLabel>_space-<spaceLabel>_desc-beforeEstimation_designmatrix.png
166+
├── jobs
167+
│   └── <taskLabel>
168+
│   ├── group
169+
│   │   ├── batch_smooth_con_FWHM-6_task-<taskLabel>_2023-05-06T12-49.json
170+
│   │   └── batch_smooth_con_FWHM_6_task_<taskLabel>_2023_05_06T12_49.m
171+
│   ├── sub-292
172+
│   │   ├── batch_contrasts_ffx_task-<taskLabel>_space-<spaceLabel>_FWHM-6_2023-05-06T12-43.json
173+
│   │   ├── batch_contrasts_ffx_task_<taskLabel>_space_<spaceLabel>_FWHM_6_2023_05_06T12_43.m
174+
│   │   ├── batch_specifyAndEstimate_ffx_task-<taskLabel>_space-<spaceLabel>_FWHM-6_2023-05-06T12-35.json
175+
│   │   └── batch_specifyAndEstimate_ffx_task_<taskLabel>_space_<spaceLabel>_FWHM_6_2023_05_06T12_35.m
176+
│   ├── sub-302
177+
│   └── sub-307
178+
179+
├── LICENSE
180+
├── README.md
181+
├── reports
182+
│   ├── bidspm.bib
183+
│   └── stats_model-default_es_model_citation.md
184+
├── sub-292
185+
│   └── task-<taskLabel>_space-<spaceLabel>_FWHM-6
186+
│   ├── beta_0001.nii
187+
│   ├── beta_0002.nii
188+
│   ├── ...
189+
│   ├── beta_0060.nii
190+
│   ├── con_0001.nii
191+
│   ├── con_0002.nii
192+
│   ├── con_0003.nii
193+
│   ├── con_0004.nii
194+
│   ├── con_0005.nii
195+
│   ├── con_0006.nii
196+
│   ├── mask.nii
197+
│   ├── ResMS.nii
198+
│   ├── RPV.nii
199+
│   ├── s6con_0001.nii
200+
│   ├── s6con_0002.nii
201+
│   ├── s6con_0003.nii
202+
│   ├── s6con_0004.nii
203+
│   ├── s6con_0005.nii
204+
│   ├── s6con_0006.nii
205+
│   ├── SPM.mat
206+
│   ├── spmT_0001.nii
207+
│   ├── spmT_0002.nii
208+
│   ├── spmT_0003.nii
209+
│   ├── spmT_0004.nii
210+
│   ├── spmT_0005.nii
211+
│   ├── spmT_0006.nii
212+
│   ├── sub-292_ses-<sesLabel>_task-<taskLabel>_run-01_desc-confounds_regressors.mat
213+
│   ├── sub-292_ses-<sesLabel>_task-<taskLabel>_run-01_desc-confounds_regressors.tsv
214+
│   ├── sub-292_ses-<sesLabel>_task-<taskLabel>_run-01_onsets.mat
215+
│   ├── sub-292_ses-<sesLabel>_task-<taskLabel>_run-01_onsets.tsv
216+
│   ├── sub-292_task-<taskLabel>_space-<spaceLabel>_desc-afterEstimation_designmatrix.png
217+
│   └── sub-292_task-<taskLabel>_space-<spaceLabel>_desc-beforeEstimation_designmatrix.png
218+
├── sub-302
219+
│   └── task-<taskLabel>_space-<spaceLabel>_FWHM-6
220+
│   ├── beta_0001.nii
221+
│   ├── beta_0002.nii
222+
│   ├── ...
223+
│   ├── beta_0154.nii
224+
│   ├── con_0001.nii
225+
│   ├── con_0002.nii
226+
│   ├── con_0003.nii
227+
│   ├── mask.nii
228+
│   ├── ResMS.nii
229+
│   ├── RPV.nii
230+
│   ├── s6con_0001.nii
231+
│   ├── s6con_0002.nii
232+
│   ├── s6con_0003.nii
233+
│   ├── SPM.mat
234+
│   ├── spmT_0001.nii
235+
│   ├── spmT_0002.nii
236+
│   ├── spmT_0003.nii
237+
│   ├── sub-302_ses-<sesLabel>_task-<taskLabel>_run-01_desc-confounds_regressors.mat
238+
│   ├── sub-302_ses-<sesLabel>_task-<taskLabel>_run-01_desc-confounds_regressors.tsv
239+
│   ├── sub-302_ses-<sesLabel>_task-<taskLabel>_run-01_onsets.mat
240+
│   ├── sub-302_ses-<sesLabel>_task-<taskLabel>_run-01_onsets.tsv
241+
│   ├── sub-302_task-<taskLabel>_space-<spaceLabel>_desc-afterEstimation_designmatrix.png
242+
│   └── sub-302_task-<taskLabel>_space-<spaceLabel>_desc-beforeEstimation_designmatrix.png
243+
└── sub-307
244+
└── task-<taskLabel>_space-<spaceLabel>_FWHM-6
245+
├── beta_0001.nii
246+
├── beta_0002.nii
247+
├── ...
248+
├── beta_0237.nii
249+
├── con_0001.nii
250+
├── con_0002.nii
251+
├── con_0003.nii
252+
├── con_0004.nii
253+
├── con_0005.nii
254+
├── con_0006.nii
255+
├── con_0007.nii
256+
├── con_0008.nii
257+
├── mask.nii
258+
├── ResMS.nii
259+
├── RPV.nii
260+
├── s6con_0001.nii
261+
├── s6con_0002.nii
262+
├── s6con_0003.nii
263+
├── s6con_0004.nii
264+
├── s6con_0005.nii
265+
├── s6con_0006.nii
266+
├── s6con_0007.nii
267+
├── s6con_0008.nii
268+
├── SPM.mat
269+
├── spmT_0001.nii
270+
├── spmT_0002.nii
271+
├── spmT_0003.nii
272+
├── spmT_0004.nii
273+
├── spmT_0005.nii
274+
├── spmT_0006.nii
275+
├── spmT_0007.nii
276+
├── spmT_0008.nii
277+
├── sub-307_ses-<sesLabel>_task-<taskLabel>_run-01_desc-confounds_regressors.mat
278+
├── sub-307_ses-<sesLabel>_task-<taskLabel>_run-01_desc-confounds_regressors.tsv
279+
├── sub-307_ses-<sesLabel>_task-<taskLabel>_run-01_onsets.mat
280+
├── sub-307_ses-<sesLabel>_task-<taskLabel>_run-01_onsets.tsv
281+
├── sub-307_task-<taskLabel>_space-<spaceLabel>_desc-afterEstimation_designmatrix.png
282+
└── sub-307_task-<taskLabel>_space-<spaceLabel>_desc-beforeEstimation_designmatrix.png
283+
```

src/reports/boilerplate_stats.mustache

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ to censor any time points flagged as outlier,
4343
{{/confounds}}.
4444

4545
{{#smoothing}}
46-
Contrast images were computed for the following condition and spatially smoothed
47-
using a 3D gaussian kernel (FWHM = {{fwhm.contrast}} mm).
46+
Contrast images were spatially smoothed using a 3D gaussian kernel (FWHM = {{fwhm.contrast}} mm).
4847
{{/smoothing}}
4948
{{! TODO Table of conditions with duration of each event}}
5049

tests/tests_reports/test_boilerplate.m

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,57 +14,83 @@
1414

1515
function test_boilerplate_spatial_preproc()
1616

17-
% GIVEN
17+
useUnwarp = {true, false};
18+
space = { {'individual'}, ...
19+
{'individual', 'IXI549Space'} };
1820

19-
opt = setOptions('MoAE-preproc');
21+
for iUseUnwarp = 1:2
22+
for iSpace = 1:numel(space)
23+
for fwhm = [0, 6]
24+
for dummy_scans = [0, 4]
2025

21-
filter = opt.bidsFilterFile.bold;
22-
filter.task = opt.taskName;
26+
printTestParameters(mfilename(), ...
27+
dummy_scans, ...
28+
space{iSpace}, ...
29+
useUnwarp{iUseUnwarp}, ...
30+
fwhm);
2331

24-
opt.stc.referenceSlice = 32;
32+
outputPath = tempName();
2533

26-
opt.dummy_scans = 4;
34+
opt = setOptions('MoAE-preproc');
2735

28-
% opt.space = {'individual'};
36+
opt.stc.referenceSlice = 32;
2937

30-
% opt.realign.useUnwarp = false;
38+
opt.dummy_scans = dummy_scans;
39+
opt.space = space{iSpace};
40+
opt.realign.useUnwarp = useUnwarp{iUseUnwarp};
41+
opt.fwhm.func = fwhm;
3142

32-
% opt.fwhm.func = 0;
43+
outputFile = boilerplate(opt, ...
44+
'outputPath', outputPath, ...
45+
'pipelineType', 'preproc', ...
46+
'partialsPath', partialsPath(), ...
47+
'verbosity', 0);
3348

34-
outputFile = boilerplate(opt, ...
35-
'outputPath', pwd, ...
36-
'pipelineType', 'preproc', ...
37-
'partialsPath', partialsPapth(), ...
38-
'verbosity', 0);
49+
assertEqual(exist(outputFile, 'file'), 2);
3950

40-
assertEqual(exist(outputFile, 'file'), 2);
41-
delete(outputFile);
42-
delete('bidspm.bib');
51+
end
52+
53+
end
54+
55+
end
56+
57+
end
4358

4459
end
4560

4661
function test_boilerplate_spatial_subject_glm()
4762

48-
% GIVEN
63+
desginTypes = {'block', 'event'};
64+
65+
for fwhm = [0, 6]
66+
for i = 1:numel(desginTypes)
4967

50-
opt = setOptions('facerep');
68+
outputPath = tempName();
5169

52-
opt.fwhm.contrast = 0;
70+
opt = setOptions('facerep');
5371

54-
opt.designType = 'block';
72+
opt.fwhm.contrast = fwhm;
5573

56-
outputFile = boilerplate(opt, ...
57-
'outputPath', pwd, ...
58-
'pipelineType', 'stats', ...
59-
'partialsPath', partialsPapth(), ...
60-
'verbosity', 0);
74+
opt.designType = desginTypes{i};
6175

62-
assertEqual(exist(outputFile, 'file'), 2);
63-
delete(outputFile);
64-
delete('bidspm.bib');
76+
outputFile = boilerplate(opt, ...
77+
'outputPath', outputPath, ...
78+
'pipelineType', 'stats', ...
79+
'partialsPath', partialsPath(), ...
80+
'verbosity', 0);
81+
82+
assertEqual(exist(outputFile, 'file'), 2);
83+
84+
end
85+
end
6586

6687
end
6788

68-
function value = partialsPapth()
89+
function value = partialsPath()
6990
value = fullfile(returnRootDir(), 'src', 'reports', 'partials');
7091
end
92+
93+
function pth = tempName()
94+
pth = tempname();
95+
mkdir(pth);
96+
end

tests/utils/printTestParameters.m

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
function printTestParameters(varargin)
2+
%
3+
% prints the parameters used for a test
4+
%
5+
% USAGE::
6+
%
7+
% printTestParameters('test_boilerplate', 0, {'individual'}, true, 0)
8+
%
9+
10+
% (C) Copyright 2023 bidspm developers
11+
12+
args = sanitize(varargin{:});
13+
14+
pattern = ['\t%s: ', ...
15+
strjoin(repmat({'%s'}, 1, numel(args) - 1), ' / '), ...
16+
'\n'];
17+
fprintf(1, pattern, args{:});
18+
19+
end
20+
21+
function args = sanitize(varargin)
22+
% turn all inputs into a cellstr
23+
args = {};
24+
for i = 1:numel(varargin)
25+
if iscell(varargin{i})
26+
tmp = sanitize(varargin{i}{:});
27+
tmp = ['{' strjoin(tmp, ', ') '}'];
28+
args{end + 1} = tmp; %#ok<*AGROW>
29+
else
30+
args{end + 1} = stringify(varargin{i});
31+
end
32+
end
33+
end
34+
35+
function out = stringify(in)
36+
if ischar(in)
37+
out = in;
38+
return
39+
end
40+
if isnumeric(in)
41+
out = num2str(in);
42+
return
43+
end
44+
if islogical(in)
45+
if in
46+
out = 'true';
47+
else
48+
out = 'false';
49+
end
50+
return
51+
end
52+
out = in;
53+
end

0 commit comments

Comments
 (0)