The problem I have is that the MRI scan is stopped manually, before the exam card is completed.Thus data anaylsis programs read the header and expect a certain number of volumes but it has less, and on top of that the final volume is partial so I can't simply modify the header so that it looks for less.Programs such as fslroi that allow trimming volumes do not handle partial volumes.How can I remove the partial data so that the file is correctly read?
How to fix a nii or rec file with partial volume
cognitive neuroscience;fmri
I found the solution using the python package nibabel.The code is rather simple. If filename is your nii, or rec file use:import nibabel as nibimg = nib.load(filename,permit_truncated=True)print(Saving image with shape:,img.shape)nib.save(img,truncated_{0}.format(filename))