|
1 | 1 | function tsvFile = labelActivations(varargin) |
2 | 2 | % |
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. |
4 | 6 | % |
5 | 7 | % USAGE:: |
6 | 8 | % |
7 | | - % tsvFile = labelActivations(csvFile) |
| 9 | + % tsvFile = labelActivations(csvFile, 'atlas', 'Neuromorphometrics') |
8 | 10 | % |
9 | 11 | % :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 |
11 | 17 | % |
12 | 18 | % :returns: - :tsvFile: (path) |
13 | 19 | % |
|
18 | 24 | args = inputParser; |
19 | 25 |
|
20 | 26 | addRequired(args, 'csvFile', @ischar); |
| 27 | + addParameter(args, 'atlas', 'Neuromorphometrics', @ischar); |
21 | 28 |
|
22 | 29 | parse(args, varargin{:}); |
23 | 30 |
|
24 | 31 | 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 |
25 | 42 |
|
26 | 43 | %% renaming headers to have only one row |
27 | 44 | % combine 1rst and 2nd row |
|
61 | 78 | end |
62 | 79 |
|
63 | 80 | %% 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); |
66 | 83 |
|
67 | 84 | 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)]'); |
71 | 88 | end |
72 | 89 |
|
73 | 90 | tsvFile = bids.internal.file_utils(csvFile, 'ext', '.tsv'); |
|
0 commit comments