[Neuroimaging] How to read NifTi files using file-like objects?

Satrajit Ghosh satra at mit.edu
Sat May 19 10:20:09 EDT 2018


hi jon,

there are a few projects out there that use tensorflow with brain images.
one that we are involved with is this one:
https://github.com/kaczmarj/nobrainer ,  which uses nibabel to read and
chunk volumes on the fly. a previous version used to convert the volumes to
hdf5 files, but the current one just reads directly. feel free to use the
code in the project or submit issues on the github repo.

and deepneuro and niftynet has specific models for glioma segmentation.

https://github.com/QTIM-Lab/DeepNeuro
https://github.com/NifTK/NiftyNet

cheers,

satra

On Fri, May 18, 2018 at 3:40 AM, Jon Deaton <jdeaton at stanford.edu> wrote:

> Hello NiBabel mailing list,
>
> I am a student working on the BraTS tumor segmentation challenge. I am
> using NiBabel to read images but I am having difficulty loading NIfTI
> formatted image files (*.nii) from file-like objects rather than by file
> name. So far I have been using the typical interface in nibabel for
> loading these files into memory:
>
> import nibabel
> data = nibabel.load(image_filename).get_data()
>
> However, the trouble is that nibabel.load accepts filenames but not
> file-like objects. I need to use a file-like object because I am loading
> the data from Google Cloud Storage inside Google ML Engine, which requires
> opening files using tensorflow.python.lib.io.file_io like so:
>
> from tensorflow.python.lib.io import file_io
> def load_nifti(image_filename):
>     with file_io.FileIO(image_filename, mode='r') as fileobj:
>         return # something that extracts the NifTI data from fileobj
>
>
> I have had a lot of difficulty finding the correct interface in NiBabel to
> do this so I was hoping that one of you might be able to help me accomplish
> this task
>
> Thank you,
> Jon Deaton
>
>
>
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20180519/7d294e26/attachment.html>


More information about the Neuroimaging mailing list