Skip to content

Commit 2c39d6f

Browse files
authored
Merge pull request #717 from Remi-Gau/AAL_labelling
[ENH] add possibility to use AAL for labelling of activations
2 parents afeeebb + 9827dc4 commit 2c39d6f

File tree

11 files changed

+96
-30
lines changed

11 files changed

+96
-30
lines changed

demos/MoAE/moae_01_bids_app.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@
9898
opt.results(1).montage.slices = -4:2:16;
9999
opt.results(1).nidm = true();
100100

101+
opt.results(2).nodeName = 'run_level';
102+
opt.results(2).name = {'listening_inf_baseline'};
103+
opt.results(2).p = 0.01;
104+
opt.results(2).k = 10;
105+
opt.results(2).MC = 'none';
106+
opt.results(2).csv = true;
107+
opt.results(2).atlas = 'AAL';
108+
101109
cpp_spm(bids_dir, output_dir, 'subject', ...
102110
'participant_label', {subject_label}, ...
103111
'action', 'stats', ...

src/defaults/checkOptions.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@
204204

205205
% validate content of opt.results
206206

207-
defaultContrast = defaultResultsStructure();
207+
defaultResults = defaultResultsStructure();
208208

209-
fields = fieldnames(defaultContrast);
209+
fields = fieldnames(defaultResults);
210210

211211
if ~isfield(opt, 'results')
212-
opt.results = defaultContrast;
212+
opt.results = defaultResults;
213213
return
214214
end
215215

@@ -226,12 +226,12 @@
226226
end
227227

228228
% add missing fields
229-
thisResult = setFields(thisResult, defaultContrast);
229+
thisResult = setFields(thisResult, defaultResults);
230230

231231
% fill in empty fields
232232
for i = 1:numel(fields)
233233
if isempty(thisResult.(fields{i}))
234-
thisResult.(fields{i}) = defaultContrast.(fields{i});
234+
thisResult.(fields{i}) = defaultResults.(fields{i});
235235
end
236236
end
237237

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
function contrast = defaultResultsStructure()
1+
function result = defaultResultsStructure()
22
%
33
% (C) Copyright 2019 CPP_SPM developers
44

5-
contrast = defaultContrastsStructure;
5+
result = defaultContrastsStructure;
66

7-
contrast.png = true();
7+
result.png = true();
88

9-
contrast.csv = true();
9+
result.csv = true();
10+
result.atlas = 'Neuromorphometrics';
1011

11-
contrast.threshSpm = false();
12+
result.threshSpm = false();
1213

13-
contrast.binary = false();
14+
result.binary = false();
1415

15-
contrast.montage = struct('do', false(), ...
16-
'slices', [], ...
17-
'orientation', 'axial', ...
18-
'background', fullfile(spm('dir'), ...
19-
'canonical', ...
20-
'avg152T1.nii'));
16+
result.montage = struct('do', false(), ...
17+
'slices', [], ...
18+
'orientation', 'axial', ...
19+
'background', fullfile(spm('dir'), ...
20+
'canonical', ...
21+
'avg152T1.nii'));
2122

22-
contrast.nidm = true();
23+
result.nidm = true();
2324

2425
end

src/utils/labelActivations.m

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
function tsvFile = labelActivations(varargin)
22
%
3-
% Adds MNI labels to a csv output file from SPM
3+
% Adds MNI labels to a csv output file from SPM and saves it as SPM.
4+
%
5+
% Can choose which atlas to use.
46
%
57
% USAGE::
68
%
7-
% tsvFile = labelActivations(csvFile)
9+
% tsvFile = labelActivations(csvFile, 'atlas', 'Neuromorphometrics')
810
%
911
% :param csvFile:
10-
% :type csvFile: path
12+
% :type csvFile: path
13+
%
14+
% :param atlas: Any of ``{'Neuromorphometrics', 'AAL'}``.
15+
% Defaults to ``'Neuromorphometrics'``
16+
% :type atlas: char
1117
%
1218
% :returns: - :tsvFile: (path)
1319
%
@@ -18,10 +24,21 @@
1824
args = inputParser;
1925

2026
addRequired(args, 'csvFile', @ischar);
27+
addParameter(args, 'atlas', 'Neuromorphometrics', @ischar);
2128

2229
parse(args, varargin{:});
2330

2431
csvFile = args.Results.csvFile;
32+
atlas = args.Results.atlas;
33+
34+
atlasName = 'Neuromorphometrics';
35+
if ~strcmp(atlas, 'Neuromorphometrics')
36+
copyAtlasToSpmDir(atlas, 'verbose', false);
37+
switch atlas
38+
case 'AAL'
39+
atlasName = 'AAL3v1_1mm';
40+
end
41+
end
2542

2643
%% renaming headers to have only one row
2744
% combine 1rst and 2nd row
@@ -61,13 +78,13 @@
6178
end
6279

6380
%% add MNI label
64-
% L = spm_atlas('list');
65-
xA = spm_atlas('load', 'Neuromorphometrics');
81+
spm_atlas('list', 'installed', '-refresh');
82+
xA = spm_atlas('load', atlasName);
6683

6784
for i = 1:numel(newCSV.x)
68-
newCSV.neuromorphometric_label{i} = spm_atlas('query', xA, [newCSV.x(i), ...
69-
newCSV.y(i), ...
70-
newCSV.z(i)]');
85+
newCSV.([atlas '_label']){i} = spm_atlas('query', xA, [newCSV.x(i), ...
86+
newCSV.y(i), ...
87+
newCSV.z(i)]');
7188
end
7289

7390
tsvFile = bids.internal.file_utils(csvFile, 'ext', '.tsv');

src/workflows/stats/bidsResults.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ function renameOutputResults(results)
586586

587587
for iFile = 1:size(csvFiles, 1)
588588
source = deblank(csvFiles(iFile, :));
589-
labelActivations(source);
589+
labelActivations(source, 'atlas', result.atlas);
590590
end
591591

592592
end

tests/dummyData/tsv_files/moae_results_table.tsv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set_p set_c cluster_p_FWE_corr_ cluster_p_FDR_corr_ cluster_equivk cluster_p_unc_ peak_p_FWE_corr_ peak_p_FDR_corr_ peak_T peak_equivZ peak_p_unc_ x y z neuromorphometric_label
1+
set_p set_c cluster_p_FWE_corr_ cluster_p_FDR_corr_ cluster_equivk cluster_p_unc_ peak_p_FWE_corr_ peak_p_FDR_corr_ peak_T peak_equivZ peak_p_unc_ x y z Neuromorphometrics_label
22
0.000 4 0.000 0.000 218 0.000 0.000 0.000 12.15 Inf 0.000 57 -22 11 Right PT planum temporale
33
n/a n/a n/a n/a n/a n/a 0.000 0.000 11.38 Inf 0.000 66 -13 -4 Right STG superior temporal gyrus
44
n/a n/a n/a n/a n/a n/a 0.000 0.003 7.02 6.05 0.000 60 -37 5 Right MTG middle temporal gyrus
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set_p set_c cluster_p_FWE_corr_ cluster_p_FDR_corr_ cluster_equivk cluster_p_unc_ peak_p_FWE_corr_ peak_p_FDR_corr_ peak_T peak_equivZ peak_p_unc_ x y z AAL_label
2+
0.000 4 0.000 0.000 218 0.000 0.000 0.000 12.15 Inf 0.000 57 -22 11 Temporal_Sup_R
3+
n/a n/a n/a n/a n/a n/a 0.000 0.000 11.38 Inf 0.000 66 -13 -4 Temporal_Sup_R
4+
n/a n/a n/a n/a n/a n/a 0.000 0.003 7.02 6.05 0.000 60 -37 5 Temporal_Mid_R
5+
n/a n/a 0.000 0.000 401 0.000 0.000 0.000 12.11 Inf 0.000 -63 -28 11 Temporal_Sup_L
6+
n/a n/a n/a n/a n/a n/a 0.000 0.000 11.31 Inf 0.000 -45 -34 11 Temporal_Sup_L
7+
n/a n/a n/a n/a n/a n/a 0.000 0.000 10.10 7.84 0.000 -66 -10 -1 Temporal_Mid_L
8+
n/a n/a 0.001 0.016 5 0.012 0.005 0.161 5.86 5.24 0.000 69 -25 -4 Temporal_Mid_R
9+
n/a n/a 0.015 0.219 1 0.219 0.032 0.684 5.40 4.90 0.000 51 5 -7 Insula_R
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set_p set_c cluster_p_FWE_corr_ cluster_p_FDR_corr_ cluster_equivk cluster_p_unc_ peak_p_FWE_corr_ peak_p_FDR_corr_ peak_T peak_equivZ peak_p_unc_ x y z Neuromorphometrics_label
2+
0.000 4 0.000 0.000 218 0.000 0.000 0.000 12.15 Inf 0.000 57 -22 11 Right PT planum temporale
3+
n/a n/a n/a n/a n/a n/a 0.000 0.000 11.38 Inf 0.000 66 -13 -4 Right STG superior temporal gyrus
4+
n/a n/a n/a n/a n/a n/a 0.000 0.003 7.02 6.05 0.000 60 -37 5 Right MTG middle temporal gyrus
5+
n/a n/a 0.000 0.000 401 0.000 0.000 0.000 12.11 Inf 0.000 -63 -28 11 Left PT planum temporale
6+
n/a n/a n/a n/a n/a n/a 0.000 0.000 11.31 Inf 0.000 -45 -34 11 Left PT planum temporale
7+
n/a n/a n/a n/a n/a n/a 0.000 0.000 10.10 7.84 0.000 -66 -10 -1 Left STG superior temporal gyrus
8+
n/a n/a 0.001 0.016 5 0.012 0.005 0.161 5.86 5.24 0.000 69 -25 -4 Right MTG middle temporal gyrus
9+
n/a n/a 0.015 0.219 1 0.219 0.032 0.684 5.40 4.90 0.000 51 5 -7 Right PP planum polare

tests/tests_defaults/test_defaultResultsStructure.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function test_defaultResultsStructure_basic()
2424
expected.png = true();
2525

2626
expected.csv = true();
27+
expected.atlas = 'Neuromorphometrics';
2728

2829
expected.threshSpm = false();
2930

0 commit comments

Comments
 (0)