[ITK-users] [ITK] Using Python SimpleITK to Read/Write to BytesIO instance rather than file
Lowekamp, Bradley (NIH/NLM/LHC) [C]
blowekamp at mail.nih.gov
Wed Oct 26 11:37:26 EDT 2016
Hi,
Have you done a performance comparison? These other libraries may just download and cache the files, before doing file IO.
I recall there was a URL/HTTP based ITK ImageIO, but that just downloaded the files and then use the actual file ImageIO. It was wrapped in a nice package to enable seamless passing of “http” URLS as filename strings to ITK.
HTH,
Brad
> On Oct 26, 2016, at 11:26 AM, Brian E Chapman <Brian.Chapman at utah.edu> wrote:
>
> Ziv,
>
> Thanks for your reply and the pointer to opneigtlink. Our main motivation is speed: just trying to save the write-to-disk/read-from-disk costs. Using PyDICOM we can read directly from Girder via streams and I believe we also can with nibabel. But ultimately our processing will be done with ITK and I was hoping to have SimpleITK so I was hoping to avoid all the challenges of reading in one format, passing to simpleitk and trying to keep track of all the meta data appropriately in the process.
>
> Brian
>
> ------
> Brian E. Chapman, Ph.D.
> Associate Professor
> Department of Radiology and Imaging Sciences
> University of Utah
>
>> On Oct 26, 2016, at 8:22 AM, Yaniv, Ziv Rafael (NIH/NLM/LHC) [C] <zivrafael.yaniv at nih.gov> wrote:
>>
>> Hi Brian,
>>
>> Currently ITK/SimpleITK do not have components for reading an image
>> directly from a stream. We usually download, save to disk, and read from
>> disk using the appropriate IO. We used this approach with our Jupyter
>> notebooks where the read function either finds the data in a cache or
>> fetches it from MIDAS into the cache and then reads it
>> (https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/mast
>> er/downloaddata.py).
>>
>> The challenge with streaming is that we currently don't have a protocol
>> for interpreting the streamed data (meta-data-dictionary + intensity/color
>> values). A possible solution is to use a client-server architecture with
>> the OpenIGTLink protocol (http://openigtlink.org). You can transfer
>> meta-data (patient name etc.) and complete images. See the specification
>> on their website.
>>
>> Out of curiosity, what is the motivation for the streaming only approach
>> (girder -> SimpleITK -> girder)?
>>
>> hope this helps
>> Ziv
>>
>>
>>
>>
>>
>> On 10/25/16, 5:15 PM, "Brian E Chapman" <Brian.Chapman at utah.edu> wrote:
>>
>>> Hi,
>>>
>>> We are looking at using SimpleITK in conjunction with Girder to read
>>> images from girder manipulate the images with a Python script and then
>>> write the contents back up to Girder. We would prefer to do this using
>>> Byte streams rather than saving to a local file, reading/writing to the
>>> local file and then uploading the file to Girder, but we have not been
>>> able to find a way within SimpleITK (within Python) to read and write
>>> from/to streams rather than files.
>>>
>>> Any guidance would be appreciated.
>>>
>>> Brian
>>>
>>> _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://www.kitware.com/products/protraining.php
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/mailman/listinfo/insight-users
>>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
More information about the Insight-users
mailing list