Hi,
For the purpose of my analysis, I would like to save flipped versions of my fMRI NIfTI files. With the 2019 version of MRIcron, I have tried View, then flip L/R, and then I save that image as a new file. However, I do not think it saves the flipped version. Is there a way to do this in MRIcron?
Thank you.
Hello,
MRIcron is a visualization tool, not an image manipulation tool. The View/FlipLR is designed to change between neurological and radiological orientation.
You could try MRIcroGL, which has the Import/Tools/Rotation menu item.
Alternately, you could write a Python script. Here is what ChatGPT suggests:
--------------
import nibabel as nib
import numpy as np
def flip_first_dimension(input_path, output_path):
# Load the NIfTI file
img = nib.load(input_path)
data = img.get_fdata()
# Flip the order of voxels in the first
dimension
flipped_data = np.flip(data, axis=0)
# Create a new NIfTI image with the flipped
data
flipped_img = nib.Nifti1Image(flipped_data,
img.affine, img.header)
# Save the flipped NIfTI file
nib.save(flipped_img, output_path)
print(f"Flipped NIfTI file saved to
{output_path}")
if __name__ == "__main__":
# Replace 'input_file.nii.gz' and
'output_file.nii.gz' with your file paths
input_file_path = 'input_file.nii.gz'
output_file_path = 'output_file.nii.gz'
flip_first_dimension(input_file_path, output_file_path)