Skip to content

Commit

Permalink
fix models
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Jul 29, 2024
1 parent 3918ad5 commit 71ea4d4
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

* [ENH] add support for one-way ANOVA across groups at the group level #1296 by @Remi-Gau
* [ENH] allow for 2 sample T-Test, within group T-Test and one-way ANOVA to ne more flexible with respect to what praticipants.tsv column to use to allocate subjects in each group #1296 by @Remi-Gau
* [ENH] make `addConfoundsToDesignMatrix` a method of `BidsModel` #1294 by @Remi-Gau
* [ENH] add Apptainer definition #1254 by @Remi-Gau and @monique2208
* [ENH] allow to copy anat only on raw datasets #1181 by @Remi-Gau
Expand All @@ -43,7 +45,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed


* [ENH] align specification of F contrasts on the BIDS stats model: they should now be specified as a 2D matrix and not a 1D vector. #1276 @Remi-Gau
* [DOC] change theme and structure of the documentation #1256 @Remi-Gau
* [REF] Refactor and update CLI in #1096 @Remi-Gau
Expand Down
2 changes: 0 additions & 2 deletions src/batches/stats/setBatchFactorialDesign.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
return
end

[~, opt] = getData(opt, opt.dir.preproc);

printBatchName(sprintf('specify group level fmri model for node "%s"', nodeName), opt);

% now we fetch the contrast for each subject and allocate them in the batch
Expand Down
2 changes: 2 additions & 0 deletions src/workflows/stats/bidsRFX.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@

case 'rfx'

[~, opt] = getData(opt, opt.dir.preproc);

participants = bids.util.tsvread(fullfile(opt.dir.raw, 'participants.tsv'));

matlabbatch = {};
Expand Down
14 changes: 14 additions & 0 deletions tests/data/models/model-vislocalizerSeveralDatasetLevels_smdl.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,19 @@
]
}
}
],
"Edges": [
{
"Source": "run_level",
"Destination": "subject_level"
},
{
"Source": "subject_level",
"Destination": "simple contrast"
},
{
"Source": "subject_level",
"Destination": "complex contrast"
}
]
}
22 changes: 22 additions & 0 deletions tests/data/models/model-vismotionNoOverWrite_smdl.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,27 @@
}
]
}
],
"Edges": [
{
"Source": "run_level",
"Destination": "subject_level"
},
{
"Source": "subject_level",
"Destination": "simple contrast"
},
{
"Source": "subject_level",
"Destination": "complex contrast"
},
{
"Source": "subject_level",
"Destination": "within_group"
},
{
"Source": "subject_level",
"Destination": "between_groups"
}
]
}
14 changes: 14 additions & 0 deletions tests/data/models/model-vismotionSeveralDatasetLevel_smdl.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,19 @@
]
}
}
],
"Edges": [
{
"Source": "run_level",
"Destination": "subject_level"
},
{
"Source": "subject_level",
"Destination": "simple contrast"
},
{
"Source": "subject_level",
"Destination": "complex contrast"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,45 @@
initTestSuite;
end

function test_setBatchFactorialDesign_complex_alone()

markTestAs('slow');

opt = setOptions('vismotion', {'^01'}, 'pipelineType', 'stats');

[~, opt] = getData(opt, opt.dir.preproc);

opt.model.file = spm_file(opt.model.file, ...
'basename', ...
'model-vismotionSeveralDatasetLevel_smdl');

opt.model.bm = BidsModel('file', opt.model.file);

datasetNode = opt.model.bm.get_nodes('Name', 'complex contrast');

matlabbatch = {};
matlabbatch = setBatchFactorialDesign(matlabbatch, opt, datasetNode.Name);

% (1 contrasts) specified at the dataset level * 2
% batches (design specification + figure design matrix)
assertEqual(numel(matlabbatch), 2);

% check that directory name contains:
% desc-Node(dataset).name_contrast_contrastName
[~, dir] = fileparts(matlabbatch{1}.spm.stats.factorial_design.dir{1});
assertEqual(dir, ...
[basedirName 'node-complexContrast_contrast-VisMotGtVisStat']);

end

function test_setBatchFactorialDesign_within_group()

markTestAs('slow');

opt = setOptions('vislocalizer', '', 'pipelineType', 'stats');

[~, opt] = getData(opt, opt.dir.preproc);

opt.model.file = spm_file(opt.model.file, ...
'basename', ...
'model-vislocalizerWithinGroup_smdl');
Expand All @@ -37,6 +70,8 @@ function test_setBatchFactorialDesign_complex()

opt = setOptions('vismotion', {'^01'}, 'pipelineType', 'stats');

[~, opt] = getData(opt, opt.dir.preproc);

opt.model.file = spm_file(opt.model.file, ...
'basename', ...
'model-vismotionSeveralDatasetLevel_smdl');
Expand Down Expand Up @@ -83,6 +118,8 @@ function test_setBatchFactorialDesign_basic()

opt = setOptions('vismotion', {'01' 'ctrl01'}, 'pipelineType', 'stats');

[~, opt] = getData(opt, opt.dir.preproc);

datasetNode = opt.model.bm.get_nodes('Level', 'dataset');

opt.model.bm.Nodes{3}.Model.Options = rmfield(opt.model.bm.Nodes{3}.Model.Options, ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function test_setBatchFactorialDesign_between_3_groups()
opt = setOptions('3_groups', '', 'pipelineType', 'stats');
opt.verbosity = 0;

[~, opt] = getData(opt, opt.dir.preproc);

matlabbatch = {};
[matlabbatch, ~, ~] = setBatchFactorialDesign(matlabbatch, ...
opt, ...
Expand Down
2 changes: 2 additions & 0 deletions tests/tests_workflows/stats/test_bidsRFX_3_groups.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ function test_bidsRFX_one_way_anova_contrast()

opt = setOptions('3_groups', '', 'pipelineType', 'stats');

[~, opt] = getData(opt, opt.dir.preproc);

opt.model.bm = BidsModel('file', opt.model.file);
opt.verbosity = 0;

Expand Down

0 comments on commit 71ea4d4

Please sign in to comment.