Docker-Clara-SDK: Exception in SimpleITK ImageFileWirter_Execute

Hi,

I followed the installation guide for running the AIAA server with Clara SDK 4.0 in Docker on Ubuntu 20.04. I can successfully configure models and open/close sessions with my Orthanc container. However, as soon as I try to request a segmentation for my current session, the process throws an error after BoundingBoxd transformation. The issue is, that the ImageIO writer cannot be determined.
I’m sending DICOM images via an open session to the model.

AIAA-Logs:

[2021-11-23 15:44:19] [INFO] (aiaa.www.api.api_v1) - ===============================================================================
[2021-11-23 15:44:19] [INFO] (aiaa.www.api.api_v1) - API_v1:: /v1/inference (model: clara_pt_deepgrow_2d_annotation)
[2021-11-23 15:44:19] [INFO] (aiaa.www.api.api_v1) - ===============================================================================
[2021-11-23 15:44:19] [INFO] (aiaa.inference.inference_utils) - PRE - Run Transforms
[2021-11-23 15:44:19] [INFO] (aiaa.inference.inference_utils) - PRE - Input Keys: dict_keys(['image_original', 'image', 'image_path', 'params', 'transform_meta'])
No DICOM magic number found, but the file appears to be DICOM without a preamble.
Proceeding without caution.No DICOM magic number found, but the file appears to be DICOM without a preamble.
.
.
.
Proceeding without caution.No DICOM magic number found, but the file appears to be DICOM without a preamble.
Proceeding without caution.[2021-11-23 15:44:19] [INFO] (aiaa.inference.inference_utils) - PRE - Transform (LoadImaged): Time: 0.3387; image: (112, 512, 512)
[2021-11-23 15:44:19] [INFO] (aiaa.inference.inference_utils) - PRE - Transform (AddChanneld): Time: 0.0000; image: (1, 112, 512, 512)
[2021-11-23 15:44:22] [INFO] (aiaa.inference.inference_utils) - PRE - Transform (Spacingd): Time: 2.3756; image: (1, 71, 321, 1534)
[2021-11-23 15:44:22] [INFO] (aiaa.inference.inference_utils) - PRE - Transform (ScaleIntensityRanged): Time: 0.1495; image: (1, 71, 321, 1534)
[2021-11-23 15:44:22] [INFO] (aiaa.inference.triton_inference) - Input  Shape: (1, 1, 71, 321, 1534), Type: ndarray
[2021-11-23 15:44:33] [INFO] (aiaa.inference.triton_inference) - Output Shape: torch.Size([1, 2, 71, 321, 1534]), Type: Tensor
[2021-11-23 15:44:33] [INFO] (aiaa.inference.inference_utils) - POST - Run Transforms
[2021-11-23 15:44:33] [INFO] (aiaa.inference.inference_utils) - POST - Input Keys: dict_keys(['image_original', 'image', 'image_path', 'params', 'transform_meta', 'image_meta_dict', 'image_transforms', 'pred'])
[2021-11-23 15:44:33] [INFO] (aiaa.inference.inference_utils) - POST - Transform (AddChanneld): Time: 0.0001; image: (1, 71, 321, 1534); pred: torch.Size([1, 2, 71, 321, 1534])
[2021-11-23 15:44:34] [INFO] (aiaa.inference.inference_utils) - POST - Transform (Activationsd): Time: 0.4482; image: (1, 71, 321, 1534); pred: torch.Size([1, 2, 71, 321, 1534])
[2021-11-23 15:44:38] [INFO] (aiaa.inference.inference_utils) - POST - Transform (AsDiscreted): Time: 4.4727; image: (1, 71, 321, 1534); pred: torch.Size([1, 1, 71, 321, 1534])
[2021-11-23 15:44:38] [INFO] (aiaa.inference.inference_utils) - POST - Transform (SqueezeDimd): Time: 0.0001; image: (1, 71, 321, 1534); pred: torch.Size([1, 71, 321, 1534])
[2021-11-23 15:44:38] [INFO] (aiaa.inference.inference_utils) - POST - Transform (ToNumpyd): Time: 0.0001; image: (1, 71, 321, 1534); pred: (1, 71, 321, 1534)
[2021-11-23 15:44:39] [INFO] (aiaa.inference.inference_utils) - POST - Transform (Restored): Time: 0.1909; image: (1, 71, 321, 1534); pred: (112, 512, 512)
[2021-11-23 15:44:39] [INFO] (aiaa.inference.inference_utils) - POST - Transform (ExtremePointsd): Time: 0.0796; image: (1, 71, 321, 1534); pred: (112, 512, 512)
[2021-11-23 15:44:39] [INFO] (aiaa.inference.inference_utils) - POST - Transform (BoundingBoxd): Time: 0.0122; image: (1, 71, 321, 1534); pred: (112, 512, 512)
[2021-11-23 15:44:40] [ERROR] (aiaa.www.api.api_v1) - Exception thrown in SimpleITK ImageFileWriter_Execute: /tmp/SimpleITK/Code/IO/src/sitkImageFileWriter.cxx:206:
[2021-11-23 15:44:40] sitk::ERROR: Unable to determine ImageIO writer for "/tmp/tmp3tyj99yd"
[2021-11-23 15:44:40] Traceback (most recent call last):
[2021-11-23 15:44:40]   File "/opt/conda/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
[2021-11-23 15:44:40]     rv = self.dispatch_request()
[2021-11-23 15:44:40]   File "/opt/conda/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
[2021-11-23 15:44:40]     return self.view_functions[rule.endpoint](**req.view_args)
[2021-11-23 15:44:40]   File "www/api/api_v1.py", line 368, in api_v1_inference
[2021-11-23 15:44:40]   File "www/api/api_v1.py", line 255, in run_inference
[2021-11-23 15:44:40]   File "www/api/api_v1.py", line 168, in run_infer
[2021-11-23 15:44:40]   File "actions/inference_engine.py", line 97, in run
[2021-11-23 15:44:40]   File "transforms/writer.py", line 86, in __call__
[2021-11-23 15:44:40]   File "/opt/conda/lib/python3.8/site-packages/SimpleITK/extra.py", line 394, in WriteImage
[2021-11-23 15:44:40]     return writer.Execute(image)
[2021-11-23 15:44:40]   File "/opt/conda/lib/python3.8/site-packages/SimpleITK/SimpleITK.py", line 5518, in Execute
[2021-11-23 15:44:40]     return _SimpleITK.ImageFileWriter_Execute(self, *args)
[2021-11-23 15:44:40] RuntimeError: Exception thrown in SimpleITK ImageFileWriter_Execute: /tmp/SimpleITK/Code/IO/src/sitkImageFileWriter.cxx:206:
[2021-11-23 15:44:40] sitk::ERROR: Unable to determine ImageIO writer for "/tmp/tmp3tyj99yd"

How can this error be fixed?

Thanks!

Hello,

Can you share your configs along with the steps that you setup and run AIAA?

In our documentation we don’t have Orthanc container: AI-Assisted Annotation — Clara Train SDK v4.0 documentation

I have set up the AIAA-Server according to the official documentation: AI-Assisted Annotation — Clara Train SDK v4.0 documentation
Additionally I set up an Orthanc container according to the Orthanc documentation: Orthanc for Docker.
In order to execute the segmentation process using the model “clara_pt_deepgrow_3d_annotation”, I’m creating a new session with the AIAA-Server endpoint /session?expiry=30. The request contains the follwing body:

{
  "dicom": {
    "server_address": "192.168.0.199",
    "server_port": 4242,
    "ae_title": "ORTHANC",
    "query_level": "SERIES",
    "patient_id": "FC63BCAD",
    "study_uid": "2.16.840.1.114151.3.1.7640.12000643.21464.1638433360.946",
    "series_uid": "2.16.840.1.114151.3.1.7640.12000643.21464.1638433365.1053"
  } 
}

After I receive the session_token I’m calling the endpoint /v1/segmentation?model=clara_pt_deepgrow_3d_annotation&session_id=SESSION_ID_HERE.

The AIAA-Server logs are processing the DICOM-files which were loaded into the session. At some point the segmentation process stops with the error from my first post.

The transform chain from your first post looks like a segmentation model not the deepgrow3D model.

  1. If you want to run the segmentation model, you need to check if spacing is scaling to 1.0, 1.0, 1.0, is 71, 321, 1534 the right dimension?

  2. If you want to run the deepgrow3D model, you need to load the deepgrow3D model first.
    And then you will need to pass the foreground and background points for deepgrow3D model inference.
    To have a sense of it, you can use the 3D slicer with CT image as first step to see what are the query parameters that you need to pass in.
    You can view http://0.0.0.0:[port]/docs for the AIAA API usage.