Snippets by language: MATLAB

Packages Of Snippets

Snippet ID Title
1
Functions to convert a saved affine matrix from FSL flirt (-omat blah.txt) to a mm-coordinates matrix, relating to the NIfTI voxel-world mappings of the source and target image. Conversion in the reverse direction (from world matrix for use with flirt -init blah.txt) is also possible. The code attempts to handle both radiological and neurological examples -- please let me know if you find a case that breaks it! (I haven't tested this with Analyze images; I think it should work, but would urge everyone to use NIfTI in preference anyway)
2
This is the toolbox of consistent group ICA for fMRI.
3
Movements are a major source of artifacts in functional Near-Infrared Spectroscopy (fNIRS). Several algorithms have been developed for motion artifact correction of fNIRS data, including Principal Component Analysis (PCA), targeted Principal Component Analysis (tPCA), Spline Interpolation (SI), and Wavelet Filtering (WF). WF is based on removing wavelets with coefficients deemed to be outliers based on their standardized scores, and it has proven to be effective on both synthetized and real data. However, when the SNR is high, it can lead to a reduction of signal amplitude. This may occur because standardized scores inherently adapt to the noise level, independently of the shape of the distribution of the wavelet coefficients. Higher-order moments of the wavelet coefficient distribution may provide a more diagnostic index of wavelet distribution abnormality than its variance. Here we introduce a new procedure that relies on eliminating wavelets that contribute to generate a large fourth-moment (i.e., kurtosis) of the coefficient distribution to define "outliers" wavelets (kurtosis-based Wavelet Filtering, kbWF).
4
Toolbox to retrieve and deconvolve the hemodynamic response function from resting state BOLD data.

Matlab version, standalone and SPM plugin

Snippets

Snippet ID Title
3
Ged Ridgwayget FLIRT affine matrix from file as written by flirt -omat

Example:
mat = flirtmat_read(fname)
4
Ged Ridgwaysave a 4-by-4 matrix to a file as handled by flirt -init

Example:
flirtmat_write(fname, affinemat)
5
Ged Ridgwayconvert saved flirt matrix to NIfTI world coords matrix

Example:
[worldmat spmvoxmat fslvoxmat] = flirtmat2worldmat(flirtmat, src, trg);
6
Ged Ridgwayconvert NIfTI world (mm) coordinates matrix to flirt

Example:
[flirtmat spmvoxmat fslvoxmat] = worldmat2flirtdmat(worldmat, src, trg);
7
Ged RidgwayResample a NIfTI source image using a flirt -omat matrix

Example:
flirt_resamp('src_flirtmat.txt', 'src.nii', 'trg.nii', 'res.nii')