Skip to content

Commit

Permalink
Merge pull request #620 from cpp-lln-lab/olf
Browse files Browse the repository at this point in the history
[ENH] improve group level analysis
  • Loading branch information
Remi-Gau authored Jun 8, 2022
2 parents 26e1b9c + c558d72 commit bfc901b
Show file tree
Hide file tree
Showing 39 changed files with 1,386 additions and 228 deletions.
35 changes: 29 additions & 6 deletions cpp_spm.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ function cpp_spm(varargin)
addParameter(args, 'preproc_dir', pwd, @isdir);
addParameter(args, 'model_file', struct([]), isFileOrStruct);
addParameter(args, 'roi_based', false, isLogical);
% group level stats only
addParameter(args, 'node_name', '', isChar);

parse(args, varargin{:});

Expand Down Expand Up @@ -244,20 +246,41 @@ function stats(args)
opt = checkOptions(opt);

action = args.Results.action;
analysisLevel = args.Results.analysis_level;
nodeName = args.Results.node_name;

isSubjectLevel = strcmp(analysisLevel, 'subject');
estimate = strcmp(action, 'stats');
contrasts = ismember(action, {'stats', 'contrasts'});
results = ismember(action, {'stats', 'contrasts', 'results'});

if opt.glm.roibased.do

bidsFFX('specify', opt);
bidsRoiBasedGLM(opt);

else
if strcmp(action, 'stats')
bidsFFX('specifyAndEstimate', opt);

if estimate
if isSubjectLevel
bidsFFX('specifyAndEstimate', opt);
else
bidsRFX('RFX', opt, 'nodeName', nodeName);
end
end
if ismember(action, {'stats', 'contrasts'})
bidsFFX('contrasts', opt);

if contrasts
if isSubjectLevel
bidsFFX('contrasts', opt);
else
bidsRFX('contrasts', opt, 'nodeName', nodeName);
end
end
if ismember(action, {'stats', 'contrasts', 'results'})
bidsResults(opt);

if results
bidsResults(opt, 'nodeName', nodeName);
end

end

end
Expand Down
3 changes: 3 additions & 0 deletions demos/MoAE/moae_01_bids_app.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
% Specify how you want your output
% (all the following are on false by default)
opt.results(1).png = true();
opt.results(1).csv = true();
opt.results(1).p = 0.05;
opt.results(1).MC = 'none';
opt.results(1).montage.do = true();
opt.results(1).montage.background = struct('suffix', 'T1w', ...
'desc', 'preproc', ...
Expand Down
8 changes: 4 additions & 4 deletions demos/MoAE/models/model-MoAE_smdl.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
],
"Model": {
"X": [
"trial_type.listening",
"condition.listening",
"trans_?",
"rot_?"
],
"HRF": {
"Variables": [
"trial_type.listening"
"condition.listening"
],
"Model": "spm"
},
Expand All @@ -51,14 +51,14 @@
"DummyContrasts": {
"Test": "t",
"Contrasts": [
"trial_type.listening"
"condition.listening"
]
},
"Contrasts": [
{
"Name": "listening_inf_baseline",
"ConditionList": [
"trial_type.listening"
"condition.listening"
],
"Weights": [
-1
Expand Down
13 changes: 13 additions & 0 deletions docs/list_undocumented.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

files=$(find ../src -name "*.m")
doc_files=$(find ./source -name "*.rst")

echo "${doc_files}"

for file in ${files}; do

this_file=$(basename "${file}")
echo ${this_file}

done
2 changes: 1 addition & 1 deletion lib/bids-matlab
File renamed without changes.
7 changes: 7 additions & 0 deletions src/WIP/miss_hit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

# This folder is where we keep things that are not not in use but could prove useful later

metric "cnest": limit 10
metric "file_length": limit 2000
metric "cyc": limit 50
metric "parameters": limit 20
24 changes: 18 additions & 6 deletions src/batches/stats/setBatchEstimateModel.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function matlabbatch = setBatchEstimateModel(matlabbatch, opt, nodeName, contrastsList)
function matlabbatch = setBatchEstimateModel(matlabbatch, opt, nodeName, contrastsList, groups)
%
% Set up the estimate model batch for run/subject or group level GLM
%
% USAGE::
%
% matlabbatch = setBatchEstimateModel(matlabbatch, opt)
% matlabbatch = setBatchEstimateModel(matlabbatch, opt, nodeName, contrastsList)
% matlabbatch = setBatchEstimateModel(matlabbatch, opt, nodeName, contrastsList, groups)
%
% :param matlabbatch:
% :type matlabbatch: structure
Expand All @@ -31,8 +31,7 @@

printBatchName('estimate subject level fmri model', opt);

spmMatFile = cfg_dep( ...
'fMRI model specification SPM file', ...
spmMatFile = cfg_dep('fMRI model specification SPM file', ...
substruct( ...
'.', 'val', '{}', {1}, ...
'.', 'val', '{}', {1}, ...
Expand All @@ -42,17 +41,26 @@
matlabbatch = returnEstimateModelBatch(matlabbatch, spmMatFile, opt);

% group level
case 4
case 5

if ischar(contrastsList)
contrastsList = cellstr(contrastsList);
end

if ischar(groups)
groups = cellstr(groups);
end

assert(numel(contrastsList) == numel(groups));

printBatchName('estimate group level fmri model', opt);

for j = 1:size(contrastsList)

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

assert(exist(spmMatFile{1}, 'file') == 0);

% no QA at the group level GLM:
% since there is no autocorrelation to check for
Expand All @@ -70,6 +78,10 @@
'after estimation')));
end

otherwise

error('Should have 2 or 5 inputs...');

end

end
Expand Down
Loading

0 comments on commit bfc901b

Please sign in to comment.