Reading DICOM Images

Konstantina
Konstantina Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 27 ✭✭✭✭✭

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

Tagged:

Best Answer

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,226 Dataiker
    edited July 17 Answer ✓

    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




Answers

Setup Info
    Tags
      Help me…