Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address a removed monai function, fix CUDA 11 runtime lib, and resurrect option to omit or not DICOM SEG empty frame #471

Merged
merged 4 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ jobs:
python3 -c 'import sys; print(sys.executable)'
python3 -c 'import site; print(site.getsitepackages())'
python3 -m pip freeze
export LD_LIBRARY_PATH=`pwd`/.venv/lib/python3.8/site-packages/nvidia/cuda_runtime/lib:$LD_LIBRARY_PATH
python3 -c 'from holoscan.core import *'
./run check -f
./run check -f
- name: Run Unit tests
run: |
source .venv/bin/activate
Expand Down
4 changes: 2 additions & 2 deletions examples/apps/ai_unetr_seg_app/unetr_seg_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
from monai.deploy.operators.monai_seg_inference_operator import InMemImageReader, MonaiSegInferenceOperator
from monai.transforms import (
Activationsd,
AddChanneld,
AsDiscreted,
Compose,
CropForegroundd,
EnsureChannelFirstd,
Invertd,
LoadImaged,
Orientationd,
Expand Down Expand Up @@ -132,7 +132,7 @@ def pre_process(self, img_reader, out_dir: str = "./input_images") -> Compose:
return Compose(
[
LoadImaged(keys=my_key, reader=img_reader),
AddChanneld(keys=my_key),
EnsureChannelFirstd(keys=my_key),
# The SaveImaged transform can be commented out to save a couple seconds.
# Uncompress NIfTI file, nii, is used favoring speed over size, but can be changed to nii.gz
SaveImaged(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from monai.deploy.conditions import CountCondition
from monai.deploy.core import AppContext, Application, ConditionType, Fragment, Image, Operator, OperatorSpec
from monai.deploy.operators.dicom_text_sr_writer_operator import DICOMTextSRWriterOperator, EquipmentInfo, ModelInfo
from monai.transforms import AddChannel, Compose, EnsureType, ScaleIntensity
from monai.transforms import Compose, EnsureChannelFirst, EnsureType, ScaleIntensity

MEDNIST_CLASSES = ["AbdomenCT", "BreastMRI", "CXR", "ChestCT", "Hand", "HeadCT"]

Expand Down Expand Up @@ -170,7 +170,7 @@ def setup(self, spec: OperatorSpec):

@property
def transform(self):
return Compose([AddChannel(), ScaleIntensity(), EnsureType()])
return Compose([EnsureChannelFirst(channel_dim="no_channel"), ScaleIntensity(), EnsureType()])

def compute(self, op_input, op_output, context):
import json
Expand Down Expand Up @@ -218,7 +218,7 @@ def compose(self):
self, app_context=app_context, output_folder=app_output_path, model_path=model_path, name="classifier_op"
)

my_model_info = ModelInfo("MONAI WG Trainer", "MEDNIST Classifier", "0.1", "xyz")
my_model_info = ModelInfo("MONAI WG Trainer", "MEDNIST Classifier", "0.1", "1234")
my_equipment = EquipmentInfo(manufacturer="MOANI Deploy App SDK", manufacturer_model="DICOM SR Writer")
my_special_tags = {"SeriesDescription": "Not for clinical use. The result is for research use only."}
dicom_sr_operator = DICOMTextSRWriterOperator(
Expand Down
8 changes: 7 additions & 1 deletion monai/deploy/operators/dicom_seg_writer_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
segment_descriptions: List[SegmentDescription],
output_folder: Path,
custom_tags: Optional[Dict[str, str]] = None,
omit_empty_frames: bool = True,
**kwargs,
):
"""Instantiates the DICOM Seg Writer instance with optional list of segment label strings.
Expand All @@ -205,12 +206,16 @@
Object encapsulating the description of each segment present in the segmentation.
output_folder: Folder for file output, overridden by named input on compute.
Defaults to current working dir's child folder, output.
custom_tags: OptonalDict[str, str], optional
custom_tags: Optonal[Dict[str, str]], optional
Dictionary for setting custom DICOM tags using Keywords and str values only
omit_empty_frames: bool, optional
Whether to omit frames that contain no segmented pixels from the output segmentation.
Defaults to True, same as the underlying lib API.
"""

self._seg_descs = [sd.to_segment_description(n) for n, sd in enumerate(segment_descriptions, 1)]
self._custom_tags = custom_tags
self._omit_empty_frames = omit_empty_frames

Check warning on line 218 in monai/deploy/operators/dicom_seg_writer_operator.py

View check run for this annotation

Codecov / codecov/patch

monai/deploy/operators/dicom_seg_writer_operator.py#L218

Added line #L218 was not covered by tests
self.output_folder = output_folder if output_folder else DICOMSegmentationWriterOperator.DEFAULT_OUTPUT_FOLDER

self.input_name_seg = "seg_image"
Expand Down Expand Up @@ -323,6 +328,7 @@
manufacturer_model_name="MONAI Deploy App SDK",
software_versions=version_str,
device_serial_number="0000",
omit_empty_frames=self._omit_empty_frames,
)

# Adding a few tags that are not in the Dataset
Expand Down
Loading
Loading