[Neuroimaging] Reading a byte stream into nibabel

val hs valeriehayot at gmail.com
Wed Feb 22 16:46:41 EST 2017


Works great! Thanks!

Valerie

On Wed, Feb 22, 2017 at 2:51 PM, Christopher Markiewicz <effigies at bu.edu>
wrote:

> Hi Valerie,
>
> Assuming that it's not gzipped, you can do something like:
>
>     from io import BytesIO
>     from nibabel import FileHolder, Nifti1Image
>     fh = FileHolder(fileobj=BytesIO(input_stream))
>     img = Nifti1Image.from_filemap({'header': fh, 'image': fh})
>
> If it is gzipped, adjust accordingly:
>
>     from gzip import GzipFile
>     fh = FileHolder(fileobj=GzipFile(fileobj=BytesIO(input_stream)))
>
> Cheers,
> Chris
>
>
> On Wed, Feb 22, 2017 at 2:22 PM, val hs <valeriehayot at gmail.com> wrote:
>
>> Hi,
>>
>> I am trying to process nifti-1 images using HDFS and I was wondering if
>> it was possible to read an image's byte stream into nibabel as I want to
>> avoid saving the image locally.
>>
>> Thanks,
>>
>> Valerie
>>
>> _______________________________________________
>> Neuroimaging mailing list
>> Neuroimaging at python.org
>> https://mail.python.org/mailman/listinfo/neuroimaging
>>
>>
>
> _______________________________________________
> 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/20170222/0f9e1de8/attachment.html>


More information about the Neuroimaging mailing list