Skip to content

Commit b31e664

Browse files
authored
[ENH] use contrast number in contrast filename (#1347)
* [ENH] use contrast number in contrast filename * adapt test * fix * add comment * fix * fix
1 parent 72dd1d2 commit b31e664

File tree

8 files changed

+54
-5
lines changed

8 files changed

+54
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525

2626
### Changed
2727

28+
* [ENH] Add SPM's contrast number in filename of each contrasts output filename #1347 by @Remi-Gau
29+
2830
### Deprecated
2931

3032
### Removed

demos/openneuro/models/model-ds000114_desc-testRetestVerbal_smdl.json

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,44 @@
7676
"X": [
7777
1
7878
],
79-
"Type": "glm"
79+
"Type": "glm",
80+
"Software": {
81+
"bidspm": {
82+
"Results": [
83+
{
84+
"name": [
85+
"Task"
86+
],
87+
"p": 0.05,
88+
"MC": "FWE",
89+
"png": true,
90+
"binary": true,
91+
"threshSpm": true,
92+
"nidm": true,
93+
"montage": {
94+
"do": true,
95+
"orientation": "axial",
96+
"slices": [
97+
-26,
98+
-22,
99+
-18,
100+
-14,
101+
-10,
102+
-6,
103+
-2,
104+
2,
105+
6
106+
],
107+
"background": {
108+
"suffix": "T1w",
109+
"desc": "preproc",
110+
"modality": "anat"
111+
}
112+
}
113+
}
114+
]
115+
}
116+
}
80117
},
81118
"DummyContrasts": {
82119
"Test": "t"

docs/source/output/outputs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ bidspm-stats
109109
│   ├── spmT_0001.nii |
110110
│   ├── spmT_*.nii ----------
111111
│   |
112-
│   ├── sub-blnd01_task-taskName_space-space_desc-contrastName_label-0039_p-0pt050_k-10_MC-FWE_montage.png
112+
│   ├── sub-blnd01_task-taskName_space-space_label-0039_desc-contrastName_p-0pt050_k-10_MC-FWE_montage.png
113113
│   |
114114
│   ├── sub-blnd01_task-taskName_space-space_desc-afterEstimation_designmatrix.png
115115
│   ├── sub-blnd01_task-taskName_space-space_desc-beforeEstimation_designmatrix.png

src/stats/results/renameOutputResults.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ function renameOutputResults(opt, result, subLabel)
1616
end
1717

1818
if result.nidm
19+
% TODO currently name of nidm file does not include
20+
% the label of the contrast that was used to generate it.
1921
renameNidm(opt, result, subLabel);
2022
end
2123

2224
if result.png
25+
% TODO currently name of PNG file does not include
26+
% the label of the contrast that was used to generate it.
2327
renamePngCsvResults(opt, result, '.png', subLabel);
2428
end
2529

2630
if result.csv
31+
% TODO currently name of CSV file does not include
32+
% the label of the contrast that was used to generate it.
2733

2834
renamePngCsvResults(opt, result, '.csv', subLabel);
2935

src/stats/results/returnResultNameSpec.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
nameSpec.entities.sub = result.label;
88
nameSpec.entities.task = strjoin(opt.taskName, '');
99
nameSpec.entities.space = result.space{1};
10+
if isfield(result, 'contrastNb')
11+
nameSpec.entities.label = sprintf('%04.0f', result.contrastNb);
12+
end
1013
nameSpec.entities.desc = result.name;
1114
nameSpec.entities.p = convertPvalueToString(result.p);
1215
nameSpec.entities.k = num2str(result.k);

src/workflows/stats/bidsResults.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226

227227
for iBatch = 1:numel(matlabbatch)
228228
batch{1} = struct('spm', matlabbatch{iBatch}.spm);
229-
status = saveAndRunWorkflow(batch, batchName, opt, subLabel);
229+
status = saveAndRunWorkflow(batch, [batchName, '_', num2str(iBatch)], opt, subLabel);
230230

231231
if status && isfield(matlabbatch{iBatch}, 'result')
232232
renameOutputResults(opt, matlabbatch{iBatch}.result, subLabel);

tests/tests_batches/stats/test_setBatchResults.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ function test_setBatchResults_export()
6767
export{1}.png = true;
6868
export{2}.csv = true;
6969
export{3}.tspm.basename = ...
70-
'sub-01_task-test_space-individual_desc-test_p-0pt050_k-0_MC-FDR_spmT';
70+
'sub-01_task-test_space-individual_label-0001_desc-test_p-0pt050_k-0_MC-FDR_spmT';
7171
export{4}.binary.basename = ...
72-
'sub-01_task-test_space-individual_desc-test_p-0pt050_k-0_MC-FDR_mask';
72+
'sub-01_task-test_space-individual_label-0001_desc-test_p-0pt050_k-0_MC-FDR_mask';
7373

7474
export{5}.nidm.modality = 'FMRI';
7575
export{end}.nidm.refspace = 'subject';

tests/tests_slow/tests_workflows/stats/test_bidsResults.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function test_bidsResults_subject_lvl()
4848
assertEqual(matlabbatch{1}.spm.stats.results.conspec, expected);
4949

5050
rootBasename = ['sub-ctrl01_task-vislocalizer_space-IXI549Space', ...
51+
'_label-0003', ...
5152
'_desc-VisMotGtVisStat_p-0pt050_k-5_MC-FWE'];
5253
expected = {struct('png', true), ...
5354
struct('csv', true), ...

0 commit comments

Comments
 (0)