Need to resample ALFF images in order to run fsl randomise with MNI mask

I am using XCP_D to generate ALFF images. The output ALFF images are in LAS orientation and I need to get them to RAS and resample them to have the same dimensions as MNI152_T1_2mm_brain_mask.nii.gz.

In order to flip the images from LAS to RAS, I am using a combination of fslorient and fslswapdim:

fslorient -swaporient alff.nii.gz
fslswapdim alff.nii.gz RL PA IS alff_reorient.nii.gz

Then to resample:
flirt -in alff_reorient.nii.gz -ref ~/fsl/data/standard/MNI152_T1_2mm_brain_mask.nii.gz -out alff_resampled

fsleyes accepts these output images: alff_resampled.nii.gz and MNI152_T1_2mm_brain_mask.nii.gz to have the same orientation/field of view.

Does this seem like a valid approach for resampling/reorienting?
If so, should I resample prior to doing any additional calculations on the alff image (calculating z-stat, fALFF, etc.) or only at the very end when I run fsl’s randomise and am forced to provide a mask?


Hi @julieg, are the anatomical labels for your original images correct when viewed in FSLeyes? If so, I would recommend using fslreorient2std rather than fslorient / fslswapdim, as the former is completely harmless, whereas fslorient / fslswapdim are more advanced tools and it is very easy to make a mistake with them.

The fslreorient2std command just applies a series of 90 degree rotations to the data to bring it into RAS orientation (changing both the voxel storage order, and applying the same rotations to the sform/qform). The fslorient and fslswapdim commands allow you to make arbitrary modifications to the image orientation information, and so are much more dangerous.

Regarding the resampling step, your suggested FLIRT command is actually calculating a registration between the two images, which is probably not what you want. Are your images (before running your flirt command) aligned with the MNI152 when viewed in FSLeyes? If so, you can resample them using -applyxfm -usesqform, e.g.:

flirt -in alff_reorient.nii.gz \
      -ref ~/fsl/data/standard/MNI152_T1_2mm_brain_mask.nii.gz \
      -applyxfm -usesqform \
      -out alff_resampled

Thanks a lot for the reply @paulmccarthy. When you say “are the anatomical labels for your original images correct when viewed in FSLeyes” could you elaborate on how I can check for that? When I open up fsleyes with the alff image and the fsl/MNI152_T1_2mm_brain_mask overlayed, this is what I see:

The MNI152 fslhd info for MNI is:

type info
qform_xorient Right-to-Left
qform_yorient Posterior-to-Anterior
qform_zorient Inferior-to-Superior
sform_name MNI_152
sform_xorient Right-to-Left
sform_yorient Posterior-to-Anterior
sform_zorient Inferior-to-Superior
file_type NIFTI-1+

The alff image fslhd info is:

type info
qform_xorient Left-to-Right
qform_yorient Posterior-to-Anterior
qform_zorient Inferior-to-Superior
sform_name Scanner Anat
sform_xorient Left-to-Right
sform_yorient Posterior-to-Anterior
sform_zorient Inferior-to-Superior
file_type NIFTI-1+

When I run fslreorient2std alff.nii.gz, nothing changes in the fslhd information.

Thanks again,

Hi @julieg ,

as shown here, the three spatial dimensions X (LR), Y ( PA) and Z (IS) can be in stored as 48 possible permutations. After running fslreorient2std this choice reduces to two possibilities depending on the sign of the determinant of the affine transformation: RAS or LAS. This means that if you start with an image with RAS orientation, it will stay RAS after fslreorient2std . The same for an image in LAS: it stays in LAS after fslreorient2std .
But the good news is that FSL works perfectly well with LAS, RAS or any other storage order for images. As for the resulting image after running FLIRT, it is the reference image that determines the qform and sform, and consequently the handedness.
(Source of this last assertion here)

Thanks alot for that thorough response @jsein . Just to clarify, you’re saying that I can skip fslreorient2std and go ahead and run FLIRT, and FLIRT will handle the handedness issue.

Yes, that is right, no need to run fslreorient2std in your case.