[Neuroimaging] Using nibabel to merge 3D image pairs into single-file 4D Nifti1

Matthew Brett matthew.brett at gmail.com
Tue Mar 28 16:47:30 EDT 2017


Hi,

On Tue, Mar 28, 2017 at 7:45 PM, Dav Clark <davclark at gmail.com> wrote:
> Unfortunately, there do seem to be some minor differences. I don't know if
> they matter, but I'm unsettled that they are different at all...
>
> To clarify, I'm starting with nifti pair images for each TR, so I used your
> function, and then converted to Nifti1:
>
> converted = nib.concat_images(fnames)
> converted2 = nib.Nifti1Image.from_image(converted)

I'm sure you know, but you can always save directly to whatever format
the extension implies, as in:

converted = nib.concat_images(fnames)
nib.save(converted, 'my_filename.nii')

> This version, upon saving with .to_filename() comes up in fslview as totally
> black (the range is not calibrated for some reason - maybe there's an errant
> bright voxel somewhere?). Compared to the results from `fslmerge -t fnames`,
> setting the range the same for voxel intensities, I get the same images, and
> the same time-series shape. However, intensities are slightly off (even in
> the same TR) by values ranging from hundreds to thousands (the raw
> intensities are in 100,000's). So, usually < 1% I suspect.
>
> Is this worth getting to the bottom of? Happy to share some EPIs with you
> somewhere... by default I would use JHU Box.

Just to clarify - the result of `fslmerge` does not look totally black
in fslview?

Do the images from fslmerge and `nib.concat_images` have the same data
range?  What range do they have, when you load them into nibabel and
do:

data = img.get_data()
print(data.min(), data.max())

?

Cheers,

Matthew


More information about the Neuroimaging mailing list