Skip to content

Commit

Permalink
Add verification for DICOMWeb datastore in DICOM SEG inference
Browse files Browse the repository at this point in the history
Signed-off-by: José Frias <[email protected]>
  • Loading branch information
joselfrias committed Oct 11, 2023
1 parent a6cb220 commit b82a12c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions monailabel/endpoints/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from requests_toolbelt import MultipartEncoder

from monailabel.config import RBAC_USER, settings
from monailabel.datastore.dicom import DICOMWebDatastore
from monailabel.datastore.utils.convert import binary_to_image, nifti_to_dicom_seg
from monailabel.endpoints.user.auth import RBAC, User
from monailabel.interfaces.app import MONAILabelApp
Expand Down Expand Up @@ -173,14 +174,14 @@ def run_inference(
raise HTTPException(status_code=500, detail="Failed to execute infer")

# Dicom Seg Integration
if output == "dicom_seg" and image:
if output == "dicom_seg":
dicom_seg_file = None
image_uri = instance.datastore().get_image_uri(image)
if not image_uri:
raise HTTPException(status_code=500, detail="Image not found")
if not isinstance(instance.datastore(), DICOMWebDatastore):
raise HTTPException(status_code=500, detail="DICOM SEG format is not supported in a non-DICOM datastore")
elif p.get("label_info") is None:
raise HTTPException(status_code=404, detail="Parameters for DICOM Seg inference cannot be empty!")
raise HTTPException(status_code=404, detail="Parameters for DICOM SEG inference cannot be empty!")

Check warning on line 182 in monailabel/endpoints/infer.py

View check run for this annotation

Codecov / codecov/patch

monailabel/endpoints/infer.py#L177-L182

Added lines #L177 - L182 were not covered by tests
# Transform image uri to id (similar to _to_id in local datastore)
image_uri = instance.datastore().get_image_uri(image)
suffixes = [".nii", ".nii.gz", ".nrrd"]
image_path = [image_uri.replace(suffix, "") for suffix in suffixes if image_uri.endswith(suffix)][0]
res_img = result.get("file") if result.get("file") else result.get("label")
Expand Down

0 comments on commit b82a12c

Please sign in to comment.