Reading DICOM Images

Solved!
konathan
Level 3
Reading DICOM Images

Hi!

I am trying to read DICOM images through a Python recipe. However, I receive this error "UnsupportedOperation: seek" (see the attached image for reference). I have tried the same code to read the image locally and it works fine. Do you have any idea why I receive this error?

 

P.S. I uploaded the image in a managed folder in DSS

Thanks,

Konstantina

0 Kudos
1 Solution
AlexT
Dataiker

Hi @konathan,
If you see -> "UnsupportedOperation: seek" you need to copy the file locally or in tempfile/tempdir.
get_download_stream() is indeed not seekable.

import dataiku
import tempfile

# Replace "replace_folder_id" with your actual folder ID
image_fldr = dataiku.Folder("replace_folder_id")

# Replace "file-name.jpg" and suffix

with image_fldr.get_download_stream("file-name.jpg") as f:
    with tempfile.NamedTemporaryFile(suffix=".jpg") as temp_image:
        temp_image.write(f.read())
        temp_image.seek(0)
        #continue the rest of your code on the specific files




View solution in original post

0 Kudos
2 Replies
AlexT
Dataiker

Hi @konathan,
If you see -> "UnsupportedOperation: seek" you need to copy the file locally or in tempfile/tempdir.
get_download_stream() is indeed not seekable.

import dataiku
import tempfile

# Replace "replace_folder_id" with your actual folder ID
image_fldr = dataiku.Folder("replace_folder_id")

# Replace "file-name.jpg" and suffix

with image_fldr.get_download_stream("file-name.jpg") as f:
    with tempfile.NamedTemporaryFile(suffix=".jpg") as temp_image:
        temp_image.write(f.read())
        temp_image.seek(0)
        #continue the rest of your code on the specific files




0 Kudos
konathan
Level 3
Author

Thank you @AlexT for the help!

0 Kudos

Labels

?
Labels (1)

Setup info

?
A banner prompting to get Dataiku