FSL IO
Class signals error in FSL processing
Create displacements using FSL’s FLIRT and FNIRT tools
Parameters: | fin : filename of initial source image fmat : filename of .mat (flirt) fnonlin : filename of fnirt output finvw : filename of invwarp displacements (invwarp) fdis : filename of fnirtfileutils fdisa : filename of fnirtfileutils (with other parameters) fref : filename of reference image e.g. (FMRIB58_FA_1mm.nii.gz) |
---|
Transform from in_img voxels to ref_img voxels given mat
Parameters: | mat : (4,4) array
in_img : img
ref_img : img
|
---|---|
Returns: | aff : (4,4) array
|
Notes
Thanks to Mark Jenkinson and Jesper Andersson for the correct statements here, apologies for any errors we’ve added.
flirt registers an in image to a ref image. It can produce (with the -omat option) - a 4 x 4 affine matrix giving the mapping from inspace to refspace.
The rest of this note is to specify what inspace and refspace are.
In what follows, a voxtrans for an image is the 4 by 4 affine np.diag([vox_i, vox_j, vox_k, 1]) where vox_i etc are the voxel sizes for the first second and third voxel dimension. vox_i etc are always positive.
If the input image has an affine with a negative determinant, then the mapping from voxel coordinates in the input image to inspace is simply voxtrans for the input image. If the reference image has a negative determinant, the mapping from voxel space in the reference image to refspace is simply voxtrans for the reference image.
A negative determinant for the image affine is the common case, of an image with a x voxel flip. Analyze images don’t store affines and flirt assumes a negative determinant in these cases.
For positive determinant affines, flirt starts inspace and / or refspace with an x voxel flip. The mapping implied for an x voxel flip for image with shape (N_i, N_j, N_k) is:
- [[-1, 0, 0, N_i - 1],
- [ 0, 1, 0, 0], [ 0, 0, 1, 0], [ 0, 0, 0, 1]]
If the input image has an affine with a positive determinant, then mapping from input image voxel coordinates to inspace is np.dot(input_voxtrans, input_x_flip) - where input_x_flip is the matrix above with N_i given by the input image first axis length. Similarly the mapping from reference voxel coordinates to refspace, if the reference image has a positive determinant, is np.dot(ref_voxtrans, ref_x_flip) - where ref_x_flip is the matrix above with N_i given by the reference image first axis length.
Map from in_fname image voxels to ref_fname voxels given matfile
See flirt2aff() docstring for details.
Parameters: | matfile : str
in_fname : str
ref_fname : str
|
---|---|
Returns: | aff : (4,4) array
|
Return True if we can call flirt without error
Relies on the fact that flirt produces text on stdout when called with no arguments
A tine pipeline system to run external tools.
For more advanced pipelining use nipype http://www.nipy.org/nipype
Run flirt on nibabel images, returning affine
Parameters: | in_img : SpatialImage
ref_img : SpatialImage
dof : int, optional
flags : str, optional
|
---|---|
Returns: | in_vox2out_vox : (4,4) ndarray
|
Warp an image using fsl displacements
Parameters: | ffa : filename of nifti to be warped flaff : filename of .mat (flirt) fdis : filename of displacements (fnirtfileutils) fref : filename of reference volume e.g. (FMRIB58_FA_1mm.nii.gz) ffaw : filename for the output warped image |
---|
Warp tracks from native space to the FMRIB58/MNI space
We use here the fsl displacements. Have a look at create_displacements to see an example of how to use these displacements.
Parameters: | fdpy : filename of the .dpy file with the tractography ffa : filename of nifti to be warped fmat : filename of .mat (flirt) fdis : filename of displacements (fnirtfileutils) fdisa : filename of displacements (fnirtfileutils + affine) finv : filename of invwarp displacements (invwarp) fref : filename of reference volume e.g. (FMRIB58_FA_1mm.nii.gz) fdpyw : filename of the warped tractography |
---|
Write FSL FDT bvals and bvecs files
Parameters: | bvals : (N,) sequence
bvecs : (N, 3) array-like
outpath : None or str
prefix : str
|
---|