Skip to content

Commit 3b19c9b

Browse files
authored
Merge pull request #665 from cpp-lln-lab/olf
[FIX] make sure 2 sample ttest can run more than one contrasts
2 parents 8efdc4c + e9e87a8 commit 3b19c9b

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

src/batches/stats/setBatchGroupLevelContrasts.m

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,17 @@
8585

8686
spmMatFile = fullfile(getRFXdir(opt, nodeName, contrastsList{j}), 'SPM.mat');
8787

88-
matlabbatch = setGroupContrast(matlabbatch, opt, spmMatFile, ...
89-
thisContrast{1}.Name, ...
90-
thisContrast{1}.Weights);
88+
if ~opt.dryRun
89+
assert(exist(spmMatFile, 'file') == 2);
90+
end
91+
92+
for iCon = 1:numel(thisContrast)
93+
consess{iCon}.tcon.name = thisContrast{iCon}.Name;
94+
consess{iCon}.tcon.convec = thisContrast{iCon}.Weights;
95+
consess{iCon}.tcon.sessrep = 'none';
96+
end
97+
98+
matlabbatch = setBatchContrasts(matlabbatch, opt, spmMatFile, consess);
9199

92100
end
93101

src/batches/stats/setBatchGroupLevelResults.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
load(fullfile(result.dir, 'SPM.mat'));
2424
result.nbSubj = SPM.nscan;
2525

26-
result.contrastNb = 1;
27-
2826
result.label = 'group';
2927

3028
result.outputName = defaultOuputNameStruct(opt, result);

src/workflows/stats/bidsResults.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@
374374
if all(ismember(lower(groupBy), {'contrast'}))
375375

376376
result.name = name;
377+
result.contrastNb = 1;
377378
result.dir = getRFXdir(opt, result.nodeName, name);
378379

379380
[matlabbatch, results] = appendToBatch(matlabbatch, opt, results, result);
@@ -389,6 +390,7 @@
389390

390391
thisGroup = availableGroups{iGroup};
391392
result.name = [thisGroup ' - ' name];
393+
result.contrastNb = 1;
392394
result.dir = getRFXdir(opt, result.nodeName, name, thisGroup);
393395

394396
[matlabbatch, results] = appendToBatch(matlabbatch, opt, results, result);
@@ -400,10 +402,14 @@
400402
case 'two_sample_t_test'
401403

402404
thisContrast = opt.model.bm.get_contrasts('Name', result.nodeName);
403-
result.name = [thisContrast{1}.Name ' - ' name];
405+
404406
result.dir = getRFXdir(opt, result.nodeName, name);
405407

406-
[matlabbatch, results] = appendToBatch(matlabbatch, opt, results, result);
408+
for iCon = 1:numel(thisContrast)
409+
result.name = [thisContrast{iCon}.Name ' - ' name];
410+
result.contrastNb = iCon;
411+
[matlabbatch, results] = appendToBatch(matlabbatch, opt, results, result);
412+
end
407413

408414
otherwise
409415
msg = sprintf('Node %s has has model type I cannot handle.\n', result.nodeName);

tests/dummyData/models/model-vislocalizer2sampleTTest_smdl.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@
101101
-1
102102
],
103103
"Test": "t"
104+
},
105+
{
106+
"Name": "ctrl_gt_blind",
107+
"ConditionList": [
108+
"Group.blind",
109+
"Group.ctrl"
110+
],
111+
"Weights": [
112+
-1,
113+
1
114+
],
115+
"Test": "t"
104116
}
105117
]
106118
}

tests/tests_batches/stats/test_setBatchGroupLevelContrasts.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@
88
initTestSuite;
99
end
1010

11+
function test_setBatchGroupLevelContrasts_between_groups()
12+
13+
opt = setOptions('vislocalizer', '', 'pipelineType', 'stats');
14+
15+
opt.model.file = spm_file(opt.model.file, ...
16+
'basename', ...
17+
'model-vislocalizer2sampleTTest_smdl');
18+
opt.model.bm = BidsModel('file', opt.model.file);
19+
20+
matlabbatch = {};
21+
matlabbatch = setBatchGroupLevelContrasts(matlabbatch, opt, 'between_groups');
22+
23+
assertEqual(numel(matlabbatch{1}.spm.stats.con.consess), 2);
24+
assertEqual(matlabbatch{1}.spm.stats.con.consess{1}.tcon.name, 'blind_gt_ctrl');
25+
assertEqual(matlabbatch{1}.spm.stats.con.consess{2}.tcon.name, 'ctrl_gt_blind');
26+
27+
end
28+
1129
function test_setBatchGroupLevelContrasts_within_group()
1230

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

0 commit comments

Comments
 (0)