diff --git a/CHANGELOG.md b/CHANGELOG.md index 55646185..b188374a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +* [ENH] Add SPM's contrast number in filename of each contrasts output filename #1347 by @Remi-Gau + ### Deprecated ### Removed diff --git a/demos/openneuro/models/model-ds000114_desc-testRetestVerbal_smdl.json b/demos/openneuro/models/model-ds000114_desc-testRetestVerbal_smdl.json index 78ce9678..02d1bf66 100644 --- a/demos/openneuro/models/model-ds000114_desc-testRetestVerbal_smdl.json +++ b/demos/openneuro/models/model-ds000114_desc-testRetestVerbal_smdl.json @@ -76,7 +76,44 @@ "X": [ 1 ], - "Type": "glm" + "Type": "glm", + "Software": { + "bidspm": { + "Results": [ + { + "name": [ + "Task" + ], + "p": 0.05, + "MC": "FWE", + "png": true, + "binary": true, + "threshSpm": true, + "nidm": true, + "montage": { + "do": true, + "orientation": "axial", + "slices": [ + -26, + -22, + -18, + -14, + -10, + -6, + -2, + 2, + 6 + ], + "background": { + "suffix": "T1w", + "desc": "preproc", + "modality": "anat" + } + } + } + ] + } + } }, "DummyContrasts": { "Test": "t" diff --git a/docs/source/output/outputs.md b/docs/source/output/outputs.md index 017170af..5d00830b 100644 --- a/docs/source/output/outputs.md +++ b/docs/source/output/outputs.md @@ -109,7 +109,7 @@ bidspm-stats │   ├── spmT_0001.nii | │   ├── spmT_*.nii ---------- │   | -│   ├── sub-blnd01_task-taskName_space-space_desc-contrastName_label-0039_p-0pt050_k-10_MC-FWE_montage.png +│   ├── sub-blnd01_task-taskName_space-space_label-0039_desc-contrastName_p-0pt050_k-10_MC-FWE_montage.png │   | │   ├── sub-blnd01_task-taskName_space-space_desc-afterEstimation_designmatrix.png │   ├── sub-blnd01_task-taskName_space-space_desc-beforeEstimation_designmatrix.png diff --git a/src/stats/results/renameOutputResults.m b/src/stats/results/renameOutputResults.m index 3706d1f4..e7ebb0d5 100644 --- a/src/stats/results/renameOutputResults.m +++ b/src/stats/results/renameOutputResults.m @@ -16,14 +16,20 @@ function renameOutputResults(opt, result, subLabel) end if result.nidm + % TODO currently name of nidm file does not include + % the label of the contrast that was used to generate it. renameNidm(opt, result, subLabel); end if result.png + % TODO currently name of PNG file does not include + % the label of the contrast that was used to generate it. renamePngCsvResults(opt, result, '.png', subLabel); end if result.csv + % TODO currently name of CSV file does not include + % the label of the contrast that was used to generate it. renamePngCsvResults(opt, result, '.csv', subLabel); diff --git a/src/stats/results/returnResultNameSpec.m b/src/stats/results/returnResultNameSpec.m index 684666f2..f2a829ab 100644 --- a/src/stats/results/returnResultNameSpec.m +++ b/src/stats/results/returnResultNameSpec.m @@ -7,6 +7,9 @@ nameSpec.entities.sub = result.label; nameSpec.entities.task = strjoin(opt.taskName, ''); nameSpec.entities.space = result.space{1}; + if isfield(result, 'contrastNb') + nameSpec.entities.label = sprintf('%04.0f', result.contrastNb); + end nameSpec.entities.desc = result.name; nameSpec.entities.p = convertPvalueToString(result.p); nameSpec.entities.k = num2str(result.k); diff --git a/src/workflows/stats/bidsResults.m b/src/workflows/stats/bidsResults.m index d675a115..e766fbec 100644 --- a/src/workflows/stats/bidsResults.m +++ b/src/workflows/stats/bidsResults.m @@ -226,7 +226,7 @@ for iBatch = 1:numel(matlabbatch) batch{1} = struct('spm', matlabbatch{iBatch}.spm); - status = saveAndRunWorkflow(batch, batchName, opt, subLabel); + status = saveAndRunWorkflow(batch, [batchName, '_', num2str(iBatch)], opt, subLabel); if status && isfield(matlabbatch{iBatch}, 'result') renameOutputResults(opt, matlabbatch{iBatch}.result, subLabel); diff --git a/tests/tests_batches/stats/test_setBatchResults.m b/tests/tests_batches/stats/test_setBatchResults.m index 0deb8937..df862b52 100644 --- a/tests/tests_batches/stats/test_setBatchResults.m +++ b/tests/tests_batches/stats/test_setBatchResults.m @@ -67,9 +67,9 @@ function test_setBatchResults_export() export{1}.png = true; export{2}.csv = true; export{3}.tspm.basename = ... - 'sub-01_task-test_space-individual_desc-test_p-0pt050_k-0_MC-FDR_spmT'; + 'sub-01_task-test_space-individual_label-0001_desc-test_p-0pt050_k-0_MC-FDR_spmT'; export{4}.binary.basename = ... - 'sub-01_task-test_space-individual_desc-test_p-0pt050_k-0_MC-FDR_mask'; + 'sub-01_task-test_space-individual_label-0001_desc-test_p-0pt050_k-0_MC-FDR_mask'; export{5}.nidm.modality = 'FMRI'; export{end}.nidm.refspace = 'subject'; diff --git a/tests/tests_slow/tests_workflows/stats/test_bidsResults.m b/tests/tests_slow/tests_workflows/stats/test_bidsResults.m index 2a7dfdc4..6f060f5e 100644 --- a/tests/tests_slow/tests_workflows/stats/test_bidsResults.m +++ b/tests/tests_slow/tests_workflows/stats/test_bidsResults.m @@ -48,6 +48,7 @@ function test_bidsResults_subject_lvl() assertEqual(matlabbatch{1}.spm.stats.results.conspec, expected); rootBasename = ['sub-ctrl01_task-vislocalizer_space-IXI549Space', ... + '_label-0003', ... '_desc-VisMotGtVisStat_p-0pt050_k-5_MC-FWE']; expected = {struct('png', true), ... struct('csv', true), ...