This function takes in an image, flips the image over the left/right plane, registers that flipped image to the original image, then applies the half transformation
mid_sagittal_align(
file,
opts = "",
translation = TRUE,
force_rpi = TRUE,
verbose = TRUE
)
apply_mid_sagittal_align(
file,
file_mat,
apply_opts = "",
force_rpi = TRUE,
verbose = TRUE
)(character) input filename or class nifti
(character) options passed to flirt
(logical) should the translation parameters be preserved (TRUE) or set to zero (FALSE)
Should rpi_orient_file be
run?
(logical) print diagnostic messages
file name of mat file for half transform from [mid_sagittal_align]
options to pass to [fslr::flirt_apply]
Filename of output or nifti depending on retimg
if (have.fsl()){
mnifile = file.path(fsldir(), "data", "standard",
"MNI152_T1_2mm.nii.gz")
aligned = mid_sagittal_align(mnifile)
thresh = readnii(mnifile) > 0
file_mat = attr(aligned, "half_transform")
force_rpi = attr(aligned, "force_rpi")
flipped_thresh = apply_mid_sagittal_align(
file = thresh,
file_mat = file_mat,
apply_opts = "-interp nearestneighbour",
force_rpi = force_rpi
)
}