With SPM being one of the tools I found most frequently used as a neuroimaging analysis tool, NeuroElf offers a way to import an existing line of analysis (models and results of single subject, first-level regressions) into the format used by both BrainVoyager QX and NeuroElf to simplify data extraction and visualization.
To be able to use this functionality, you should have concluded the first-level modeling stage of your study, so that for each subject you have
importrfxglmfromspms - import SPM beta maps to a BrainVoyager GLM file FORMAT: glm = importrfxglmfromspms(spms, opts) Input fields: spms list of SPM.mat filenames to use for import opts options for the import .bbox bounding box to use (in BVS notation) .cond 1xC structure with fields (default: auto detect) .bvname condition name for the BV file .color 1x3 RGB color for condition .spmname SPM based name (or pattern) .filename output GLM filename (otherwise unsaved) .imeth interpolation 'cubic', 'lanczos3', {'linear'}, 'nearest' .impvtc pattern for VTCs (default: '', e.g. '#_run%02d.vtc') .mmaskfac mean-masking factor, default 0.5 results in masking out voxels where constant < 0.25 of its mean overall value (per subject) .pbar either xprogress or xfigure:XProgress object .res resolution (default: floor of SPM resolution) .subjids subject identifiers (default: auto detect) .trans either {'none'}, 'psc' PSC-transform uses estimated mean (constant) as 100! .vweight variance-based weighting (false, uses SPM.xX.Bcov) Output fields: glm GLM object (saved if .filename is given) Note: if VTC import is desired, the VTC filename pattern (.impvtc) must contain one or two occurrences of the hash mark (which will be replaced by the subject ID) and one occurrence %d or %XXd for the Sess number; other arguments (bbox, imeth, res) will be passed on
Preferably, the spms
argument should contain absolute pathnames.
The bounding box must be given in BrainVoyager notation, so that the three dimensions have values between 0 and 256, the axes order is the same as with the Talairach/MNI convention, but the direction of each axis is reversed when compared to Talairach/MNI notation. If left empty, this will be automatically determined.
A multi-element struct with fields bvname
(target name appearing in the output GLM), color
(RGB color used for beta/time-course plotting UIs), and spmname
(source regressor name as it appears in the SPM.xX.name field) identifying the conditions to import into the GLM. If left empty, all conditions will be automatically selected in the order in which they appear in the first SPM.mat file.
If given the resulting GLM file will be saved under this filename. Additionally, a relative path in the .impvtc
option will be prepended with any absolute path in this field.
Interpolation method; determines the amount of additional smoothing that occurs when importing the data. For unsmoothed (or very little smoothed) data, a larger interpolation kernel (either cubic or lanczos3, which is sinc with a window size of 3) is suggested; otherwise linear interpolation should be sufficient.
If given must contain at least one hash mark (#
), which will be replaced with the subject identifier, as well as one format suitable for sprintf
to add the session number into the filename. The subject identifier (hash mark) may occur multiple times, which can be used to store output files into separate folders for different subjects.
Mean-based masking factor. All voxels for which the mean (average beta estimate for the all-1 regressors) is lower than this fraction of the global mean thereof will be set to 0; this works as a post-hoc relative global signal intensity mask. The default value is set to 0.25.
In case you wish to call this from a script or to integrate into a UI, a progress bar object can be passed into the function.
VTC/GLM resolution (supported values: 1, 2, or 3). The default is to auto-detect the resolution from the data (avoiding further smoothing and/or information loss).
List of subject identifiers, must be the same size as the spms
argument and contain one unique string per subject. If left empty, an auto-detection is attempted.
If set to 'psc
' the function will scale each beta by the term (100 / All_1s_beta)
for each session, which is virtually identical with a percent change transformation on time-courses.
If set to true
the sum of betas coming from the same condition but across different sessions of the same subject will be weighted by the square root of the inverse of the corresponding value in the inverse design matrix (found in SPM.xX.Bcov), which is an estimate for the variance produced by a regressor (after filtering). Otherwise (which is the default), betas of the same condition across sessions will be added and divided by the number of betas for that condition (unweighted mean).
Next to a command-line- or scripting-only mode, this function comes with its own UI to allow flexible configuration of the settings:
To invoke this mode, the first argument must be the string 'ui
':
% use UI mode for GLM import glm = importrfxglmfromspms('ui');
This list of instructions is meant to cover the majority of cases, but certain conditions, such as multiple groups in completely different locations or different sub-folder depths, might make it necessary to import several separate GLMs which can be combined later, given that the number and names of conditions across subjects match!
properties
button (third button from the top next to the top right listbox) allows to rename a subject identifierproperties
button allows to apply a search-and-replace (regular expression) operation to the selected identifiersminus
button (last button next to the top right listbox)plus
button (second-to-last button next to the top right listbox)move-up
and move-down
buttons (first and second button from the top next to the top right listbox)properties
buttoncolorpicker
button (this opens the colorpicker tool for all configured conditions)move-up
and move-down
buttons after selecting the desired items to move.trans
option).vweight
option).imeth
option).bbox
and .res
options)Import…
Should an unrecoverable error occur (e.g. an SPM.mat file is not found or invalid), you will be notified.
In case you select the import-VTC feature, the GLM file will contain references to the newly created files, which will allow to inspect time courses quickly from the NeuroElf main UI. Also, this allows to easily create an MDM file by using the GLM::CreateMDM
function.
The VTC import feature is “tried” (using error handling) for each session separately, and if the import fails on one session (corrupt or missing file, etc.), this study will not be added to the GLM at the end, but this does not lead to an unrecoverable error!