fsl flirt code example

Example 1: fsl flirt

#!/bin/sh

# Use FSL flirt to register label masks 
# with nearest neighbor interpolation. 
# because the label values should never be interpolated.
# This example assumes: 
# an existing 0.5mm standard brain (MNI152_T1_0.5mm_brain)
# an existing flirt matrix from 1 mm to 0.5 mm (stand1stand0.5.mat)

 flirt -in atlas -datatype int -ref MNI152_T1_0.5mm_brain \
 -interp nearestneighbour \
 -init stand1stand0.5.mat -applyxfm -out atlas_0.5mm

Example 2: fsl flirt

#!/bin/sh

: <<COMMENTBLOCK

Purpose:    Run flirt to reslice an image into a new space
Input:     	img = image to be resliced, 
            ref = a reference image (we will reslice INTO this new space)
            -init mat = a mat (matrix) file that expresses the relationship between 
            the input space and the output space
Output:     -out = image in new space

COMMENTBLOCK

    flirt -in img -datatype float -ref ${ref} -init ${mat} \
    -applyxfm -out ${output}

Example 3: fsl flirt

#!/bin/sh

# Some viewers (like MRIcron) do not handle anisotropic voxels well. 
# FSL can easily convert an image with anisotropic voxels into one 
# with isotropic voxels in the same space using -applyisoxfm

# reslice current image into 1mm isotropic
flirt -in anat_CT_axial -ref anat_CT_axial -applyisoxfm 1 -out anat_CT_axial_1mm

# reslice current image into 0.5 mm isotropic voxels.
flirt -in anat_CT_axial -ref anat_CT_axial -applyisoxfm 0.5 -out anat_CT_axial_0.5mm