Skip to content

Commit 51c7010

Browse files
authored
[WIP] improve roi based analysis (#1086)
* try using mni rois in subject folders * deal with unsanitize cofounds * clean * fixes * do not delete GLM folder content before running roi based glm * fix tests
1 parent cf57ca7 commit 51c7010

File tree

15 files changed

+171
-58
lines changed

15 files changed

+171
-58
lines changed

.github/workflows/run_tests_cli.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ on:
66
push:
77
branches:
88
- main
9-
- dev
109
pull_request:
11-
branches: ['*']
10+
branches:
11+
- main
1212

1313
jobs:
1414
tests_cli:

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ concurrency:
2121

2222
on:
2323
push:
24-
branches: ['*']
24+
branches: [main]
2525
pull_request:
26-
branches: ['*']
26+
branches: [main]
2727
schedule:
2828
- cron: 0 0 1,15 * *
2929

.github/workflows/tests_octave.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ concurrency:
2424

2525
on:
2626
push:
27-
branches: ['*']
27+
branches: [main]
2828
pull_request:
29-
branches: ['*']
29+
branches: [main]
3030
schedule:
3131
- cron: 0 0 1,15 * *
3232

.github/workflows/tests_windows.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ concurrency:
2121

2222
on:
2323
push:
24-
branches: ['*']
24+
branches: [main]
2525
pull_request:
26-
branches: ['*']
26+
branches: [main]
2727
schedule:
2828
- cron: 0 0 1,15 * *
2929

.github/workflows/validation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name: validation
33

44
on:
55
push:
6-
branches: ['*']
6+
branches: [main]
77
pull_request:
8-
branches: ['*']
8+
branches: [main]
99

1010
concurrency:
1111
group: ${{ github.workflow }}-${{ github.ref }}

src/batches/stats/setBatchSubjectLevelGLMSpec.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,19 @@
7272
% Create ffxDir if it does not exist
7373
% If it exists, issue a warning that it has been overwritten
7474
ffxDir = getFFXdir(subLabel, opt);
75-
overwriteDir(ffxDir, opt);
75+
if ~opt.glm.roibased.do
76+
overwriteDir(ffxDir, opt);
77+
else
78+
if exist(fullfile(ffxDir, 'SPM.mat'), 'file')
79+
delete(fullfile(ffxDir, 'SPM.mat'));
80+
else
81+
spm_mkdir(ffxDir);
82+
end
83+
end
84+
7685
msg = sprintf(' output dir:\n\t%s', pathToPrint(ffxDir));
7786
logger('INFO', msg, 'options', opt, 'filename', mfilename());
87+
7888
fmri_spec.dir = {ffxDir};
7989

8090
fmri_spec.fact = struct('name', {}, 'levels', {});
@@ -188,7 +198,7 @@
188198
filter = fileFilterForBold(opt, subLabel);
189199

190200
[name, version] = generatedBy(BIDS);
191-
tokens = strsplit(version);
201+
tokens = strsplit(version, '.');
192202
% TODO implement differently for fmriprep >=20.2.4
193203
% https://fmriprep.org/en/stable/changes.html#october-04-2021
194204
skip = opt.stc.skip || ...

src/bids/getROIs.m

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
function [roiList, roiFolder] = getROIs(varargin)
22
%
3-
% Get the rois from :
3+
% Get the rois depending on value of "opt.bidsFilterFile.roi.space":
44
%
5-
% - the group folder when running analysis in MNI space
6-
% - the ``sub-*/roi/sub-subLabel`` folder when in individual space
5+
% - the group folder for space: "MNI" or "IXI549Space"
6+
% - the ``sub-*/roi/sub-subLabel`` folder:
7+
% - when in individual space ('T1w')
8+
% - or another MNI space
79
%
810
% USAGE::
911
%
@@ -64,22 +66,31 @@
6466

6567
else
6668

67-
% we expect ROI files to have BIDS valid names
68-
BIDS_ROI = bids.layout(opt.dir.roi, 'use_schema', false);
69-
7069
if strcmp(subLabel, '')
71-
msg = sprintf('Provide a subject label amongst those:\n%s\n\n', ...
72-
bids.internal.create_unordered_list(bids.query(BIDS_ROI, 'subjects')));
70+
msg = sprintf('Provide a subject label.');
7371
id = 'noSubject';
7472
logger('ERROR', msg, 'filename', mfilename(), 'id', id);
7573
end
7674

75+
% we expect ROI files to have BIDS valid names
76+
clear filter;
77+
filter.sub = {subLabel};
78+
filter.modality = {'roi'};
79+
BIDS_ROI = bids.layout(opt.dir.roi, ...
80+
'use_schema', false, ...
81+
'filter', filter, ...
82+
'verbose', opt.verbosity > 1, ...
83+
'index_dependencies', false);
84+
85+
clear filter;
7786
filter = opt.bidsFilterFile.roi;
7887
filter.sub = regexify(subLabel);
7988

8089
if ~isempty(roiNames)
8190
if iscell(roiNames)
82-
if ~(numel(roiNames) == 1 && ~strcmp(roiNames{1}, ''))
91+
if numel(roiNames) > 1
92+
filter.label = ['(' strjoin(opt.roi.name, '|') '){1}'];
93+
elseif ~(numel(roiNames) == 1 && ~strcmp(roiNames{1}, ''))
8394
else
8495
filter.label = ['(' strjoin(opt.roi.name, '|') '){1}'];
8596
end
@@ -119,7 +130,8 @@
119130
space = {space};
120131
end
121132

122-
if any(~cellfun('isempty', regexp(space, 'MNI'))) || ismember('IXI549Space', space)
133+
if ~strcmp(space{1}, 'MNI') && ~cellfun('isempty', regexp(space, 'MNI'))
134+
elseif ismember(space, {'IXI549Space', 'MNI'})
123135
space = 'MNI';
124136
end
125137

src/infra/checkDependencies.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function checkDependencies(opt)
2828
msg = sprintf(' Using %s %s', a, b);
2929
logger('INFO', msg, 'options', opt, 'filename', mfilename());
3030

31-
if ~strcmp(a, SPM_main) || str2num(b) < 7219
31+
if ~strcmp(a, SPM_main) || str2num(b) < SPM_sub
3232
str = sprintf('%s %s %s.\n%s', ...
3333
'The current version SPM version is less than', SPM_main, SPM_sub, ...
3434
'Update with: spm_update update');

src/stats/subject_level/createAndReturnCounfoundMatFile.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
content = bids.transformers(transformers, content);
4848

4949
[names, R] = createConfounds(content, designMatrix, opt.glm.maxNbVols); %#ok<*ASGLU>
50+
[names, R] = sanitizeConfounds(names, R);
5051

5152
% save the confounds as a matfile
5253
bf = bids.File(tsvFile);

src/stats/subject_level/createConfounds.m

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

9696
tmp(isnan(tmp)) = 0;
9797

98-
R(:, col) = tmp;
98+
R(:, col) = tmp; %#ok<*AGROW>
9999

100100
end
101101

0 commit comments

Comments
 (0)