<p>I found the solution using the python package nibabel.
The code is rather simple. If <code>filename</code> is your nii, or rec file use:</p>

<pre><code>import nibabel as nib
img = nib.load(filename,permit_truncated=True)
print("Saving image with shape:",img.shape)
nib.save(img,"truncated_{0}".format(filename))
</code></pre>

CC BY-SA 3.0
2017-02-22T00:41:40.263Z
2017-02-22T00:41:40.263Z
Josh Albert
<p>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?</p>

<cognitive-neuroscience><fmri>
How to fix a nii or rec file with partial volume
Josh Albert
# How to fix a nii or rec file with partial volume

(Asked by: username_0 on 2017-02-22)

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?

**Tags:** cognitive-neuroscience, fmri


---

## 1 answers

### Answer by username_0 on 2017-02-22. Score: 1 | Accepted answer

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 nib
img = nib.load(filename,permit_truncated=True)
print("Saving image with shape:",img.shape)
nib.save(img,"truncated_{0}".format(filename))


---

