Table of Contents
Generate SPM table reports (almost) automatically
ac_spm_list.m function
The file for this function lives in /usr/local/spm8/ac_spm_list.m on uniqua.
From the “help” comments:
%function varargout = ac_spm_list(varargin) % % ADC's version of spm_list.m for hacking to match his will. % Begun 2014.8.20 % Last updated 2015.3.10 by adc % %-------------- % % Easiest way to use this function: % % 1) evaluate a contrast using the "Results" % button in the main SPM GUI window. This will prompt you to select an % SPM.mat file and a contrast, and to specify the contrast title (name), % statistical threshold and cluster threshold ("k"). After completing % these steps, there will be a variable called "xSPM" in the matlab % workspace. Then you can enter one of the commands below on the matlab % command line. % % 2) type this: % % ac_spm_list('CSVList',spm_list('table',xSPM),xSPM); % % %-------------- % % for CSV mode: % % ac_spm_list('CSVList',TabDat,xSPM[,OutFileName]) % % can produce TabDat within ac_spm_list() arg list: % ac_spm_list('CSVList',spm_list('table',xSPM),xSPM[,OutFileName]); % % OutFileName arg. is optional. CSV output file will be written to current % working directory unless full path specified as part of OutFileName. % % If OutFileName omitted, output file will still be written with default % name that has no whitespaces nor parens: % OutFileName = [contrast title]_[p-thresh]_clust[cluster k] % % Alternative to using SPM GUI "Results" button: % Use command: [SPM,xSPM] = spm_getSPM % This is prompt you to enter the data using the same GUI windows, but % without having to use that button.
Links for more info
Development Notes
<2014.8.20>
ADC would like to have a matlab script that generates a file with comma-separated values for an SPM results table, preferably with two extra columns at the end that list 1) Brodmann areas and 2) the most specific level labels from MNI space tool, taldaemon, or somesuch.
ADC made a copy of spm_list.m in uniqua:/usr/local/spm8/ called ac_spm_list.m. It turns out that the end of that function file includes code for a CSV mode, but it won't work unless modified. For example, it will output a file but the file name is specified by an undefined variable (“tempname”). So ADC will hack ac_spm_list.m and try running ac_spm_list('CSVList',TabDat). TabDat var. itself is generated by a standard call to spm_list.m.
Plan for making such a script:
Incorporate parts of ihb_MniSpace.m into ac_spm_list.m
Need to:
- Change main report loop in ihb_MniSpace.m so that it finds the label with the max cluster ratio and prints that label only.
- Change main report loop so that it only prints levels 3 (most specific cortical label) and BA.
- Change code from ihb_MniSpace.m to refer to xSPM directly.
- Need to match clusters as they are identified by ihb_MniSpace.m (sequentially in order given by spm_clusters(xSPM.XYZ) to match order of SPM table (ordered by t-score??)
- Need to check whether the one chosen label is “Unidentified,” and if so check for existence of other more informative labels with cluster ratio above some threshold.
For future:
- Add column that gives ratio of gray/white matter cluster percentages from MSU.m
<2014.8.21>
Did all those things!
Here's the commands that I ran on the matlab command line after using the SPM8 “Results” button:
TabDat = spm_list('table',xSPM); ac_spm_list_TEST('CSVList',TabDat,xSPM);
Then the file is automatically named (contrast - p thresh - cluster num).csv and saved to same folder as the SPM.mat.
<2014.8.28>
Update:
Saved ac_spm_list_TEST.m as ac_spm_list.m
Good syntax to use:
ac_spm_list('CSVList',spm_list('table',xSPM),xSPM);
<2014.9.3>
Changed ac_spm_list.m and ac_ihb_MniSpace.m to correct error that led to too many “Unidentified” labels being included before. Also added extra column at end, so that now see proportion of cluster that falls within listed BA.
<2015.3.10>
Elaborated the top of the “help” comments for ac_spm_list.m (in /usr/local/spm8/). It now includes instructions about the need to evaluate a contrast using the “Results” button in SPM in order to create the xSPM variable in the matlab workspace. The function requires this variable to work.