Skip to content

Commit c12a1a9

Browse files
authored
Editorial changes to correct typos, rename parameters, and add comments (#526)
* Editorial changes to correct typos, rename parameters, adding comments. Retested examples. Signed-off-by: M Q <mingmelvinq@nvidia.com> * More editorial changes covering the whole repo Signed-off-by: M Q <mingmelvinq@nvidia.com> * Fix flake8 complaint Signed-off-by: M Q <mingmelvinq@nvidia.com> * Fix flake8 complaints Signed-off-by: M Q <mingmelvinq@nvidia.com> --------- Signed-off-by: M Q <mingmelvinq@nvidia.com>
1 parent caf9790 commit c12a1a9

32 files changed

+99
-93
lines changed

docs/_static/custom.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ blockquote p {
107107
}
108108

109109
/* Mermaid
110-
to avoid the lable text being cut off
110+
to avoid the label text being cut off
111111
*/
112112
.edgeTerminals {
113113
font-size: 9px !important;

docs/source/developing_with_sdk/packaging_app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ It is required that the application configuration yaml file as well as the depen
1313
### Basic Usage of MONAI Application Packager
1414

1515
```bash
16-
monai-deploy package <APP_PATH> --config <COMFIG> --tag <TAG> --platform <x64-workstation> [--models <MODEL_PATH>] [--log-level <LEVEL>] [-h]
16+
monai-deploy package <APP_PATH> --config <CONFIG> --tag <TAG> --platform <x64-workstation> [--models <MODEL_PATH>] [--log-level <LEVEL>] [-h]
1717
```
1818

1919
#### Required Arguments

docs/source/getting_started/tutorials/mednist_app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jupyter-lab
4242
<div style="text-align: center;">
4343
<iframe width="560" height="315" src="https://www.youtube.com/embed/WwjilJFHuU4" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
4444
45-
<p>Video may show the use of previous SDK verson.</p>
45+
<p>Video may show the use of previous SDK version.</p>
4646
</div>
4747
```
4848

docs/source/getting_started/tutorials/monai_bundle_app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jupyter-lab
3232
<div style="text-align: center;">
3333
<iframe width="560" height="315" src="https://www.youtube.com/embed/nivgfD4pwWE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
3434
35-
<p>Video may show the use of previous SDK verson.</p>
35+
<p>Video may show the use of previous SDK version.</p>
3636
</div>
3737
```
3838

docs/source/release_notes/v0.3.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This operator uses [Clara Viz](https://pypi.org/project/clara-viz/) to provide i
1616

1717
### STL Surface Mesh Conversion Operator
1818

19-
This operator converts a volume image to surface mesh, in [STL file format](https://en.wikipedia.org/wiki/STL_(file_format)). Its API allows the client to control if smoothing needs to be applied, and if only keeping the largest connected component; the latter is useful when muliple disjoint segments are in a volume image, and the application needs to control if all or only the largest to be included in the output.
19+
This operator converts a volume image to surface mesh, in [STL file format](https://en.wikipedia.org/wiki/STL_(file_format)). Its API allows the client to control if smoothing needs to be applied, and if only keeping the largest connected component; the latter is useful when multiple disjoint segments are in a volume image, and the application needs to control if all or only the largest to be included in the output.
2020

2121
## What's fixed/updated
2222

docs/source/release_notes/v0.4.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
The new operator, `MONAI Bundle Inference Operator`, is intended to automate the inference with a MONAI Bundle in TorchScript with the following functionalities:
1111
- Parse the model metadata and extra configuration data in the TorchScript file
12-
- Instanciate MONAI transforms and inferer objects per bundle configuration data
12+
- Instantiate MONAI transforms and inferer objects per bundle configuration data
1313
- Convert input/output of the operator to and from model network input
1414
- Support named model and can be used in a multi-model application
1515

docs/source/release_notes/v0.5.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- Generated DICOM instances as AI evidence now have the attribute <a href="https://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.12.html#table_C.12-1">(0008,0201) Timezone Offset From UTC</a>, in addition to the DICOM date and time which are set with values from the underlying operating system. The OS is expected to be synchronized with a known good timing source and have the correct timezone setting
88
- Generated DICOM instance file names are now based on the SOP instance UID
99
- Support DICOM instance level attribute matching in the DICOM Series Selection Operator
10-
- Operators and example applications are verified to be re-runable without needing to reinitialize the application object or re-load the AI model network. This will allow a main function or an external script to instantiate the application object once and use it to process multiple discreet inputs, either in a batch processing mode or in a long running service
10+
- Operators and example applications are verified to be re-runable without needing to reinitialize the application object or re-load the AI model network. This will allow a main function or an external script to instantiate the application object once and use it to process multiple discrete inputs, either in a batch processing mode or in a long running service
1111
- Tutorials, in Jupyter notebooks, are re-organized and updated
1212
- Reference added for <a href="https://github.com/Project-MONAI/monai-deploy/releases">MONAI Deploy Express</a> for hosting MAPs in development environments
1313
- Removed is the reference to the deprecated MONAI Inference Service

docs/srs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ The SDK shall allow the packaging of the application in a standardized format so
521521

522522
### Background
523523

524-
Please refer to [MONAI Application Packge Spec](https://github.com/Project-MONAI/monai-deploy-experimental/blob/main/guidelines/monai-application-package.md)for details.
524+
Please refer to [MONAI Application Package Spec](https://github.com/Project-MONAI/monai-deploy-experimental/blob/main/guidelines/monai-application-package.md)for details.
525525

526526
### Verification Strategy
527527

examples/apps/ai_unetr_seg_app/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def compose(self):
8080
_algorithm_family = codes.DCM.ArtificialIntelligence
8181
_algorithm_version = "0.1.0"
8282

83-
# List of (Segment name, [Code menaing str]), not including background which is value of 0.
83+
# List of (Segment name, [Code meaning str]), not including background which is value of 0.
8484
# User must provide correct codes, which can be looked at, e.g.
8585
# https://bioportal.bioontology.org/ontologies/SNOMEDCT
8686
# Alternatively, consult the concept and code dictionaries in PyDicom

examples/apps/ai_unetr_seg_app/unetr_seg_operator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class UnetrSegOperator(Operator):
5656

5757
def __init__(
5858
self,
59-
frament: Fragment,
59+
fragment: Fragment,
6060
*args,
6161
app_context: AppContext,
6262
model_path: Path,
@@ -71,13 +71,13 @@ def __init__(
7171
self.model_path = model_path
7272
self.output_folder = output_folder
7373
self.output_folder.mkdir(parents=True, exist_ok=True)
74-
self.fragement = frament # Cache and later pass the Fragment/Application to contained operator(s)
74+
self.app_fragment = fragment # Cache and later pass the Fragment/Application to contained operator(s)
7575
self.app_context = app_context
7676
self.input_name_image = "image"
7777
self.output_name_seg = "seg_image"
7878
self.output_name_saved_images_folder = "saved_images_folder"
7979

80-
super().__init__(frament, *args, **kwargs)
80+
super().__init__(fragment, *args, **kwargs)
8181

8282
def setup(self, spec: OperatorSpec):
8383
spec.input(self.input_name_image)
@@ -102,7 +102,7 @@ def compute(self, op_input, op_output, context):
102102

103103
# Delegates inference and saving output to the built-in operator.
104104
infer_operator = MonaiSegInferenceOperator(
105-
self.fragement,
105+
self.app_fragment,
106106
roi_size=(
107107
96,
108108
96,

examples/apps/breast_density_classifier_app/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Sample data and a torchscript model can be downloaded from https://drive.google.
99
python app.py -i <input_dir> -o <out_dir> -m <breast_density_model>
1010
```
1111

12-
## Package the application as a MONAI Application Package (contianer image)
12+
## Package the application as a MONAI Application Package (container image)
1313
In order to build the MONAI App Package, go a level up and execute the following command.
1414
```
1515
monai-deploy package breast_density_classification_app -m <breast_density_model> -c breast_density_classifer_app/app.yaml --tag breast_density:0.1.0 --platform x64-workstation -l DEBUG
@@ -20,4 +20,4 @@ monai-deploy package breast_density_classification_app -m <breast_density_model>
2020
monai-deploy run breast_density-x64-workstation-dgpu-linux-amd64:0.1.0 -i <input_dir> -o <output_dir>
2121
```
2222

23-
Once the container exits successfully, check the results in the output directory. There should be a newly creeated DICOM instance file and a `output.json` file containing the classification results.
23+
Once the container exits successfully, check the results in the output directory. There should be a newly created DICOM instance file and a `output.json` file containing the classification results.

examples/apps/breast_density_classifier_app/breast_density_classifier_operator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ClassifierOperator(Operator):
4040

4141
def __init__(
4242
self,
43-
frament: Fragment,
43+
fragment: Fragment,
4444
*args,
4545
model_name: Optional[str] = "",
4646
app_context: AppContext,
@@ -67,7 +67,7 @@ def __init__(
6767
# The name of the optional input port for passing data to override the output folder path.
6868
self.input_name_output_folder = "output_folder"
6969

70-
# The output folder set on the object can be overriden at each compute by data in the optional named input
70+
# The output folder set on the object can be overridden at each compute by data in the optional named input
7171
self.output_folder = output_folder
7272

7373
# Need the name when there are multiple models loaded
@@ -80,7 +80,7 @@ def __init__(
8080

8181
self.model = self._get_model(self.app_context, self.model_path, self._model_name)
8282

83-
super().__init__(frament, *args, **kwargs)
83+
super().__init__(fragment, *args, **kwargs)
8484

8585
def _get_model(self, app_context: AppContext, model_path: Path, model_name: str):
8686
"""Load the model with the given name from context or model path
@@ -116,7 +116,7 @@ def _convert_dicom_metadata_datatype(self, metadata: Dict):
116116
if not metadata:
117117
return metadata
118118

119-
# Try to convert data type for the well knowned attributes. Add more as needed.
119+
# Try to convert data type for the well known attributes. Add more as needed.
120120
if metadata.get("SeriesInstanceUID", None):
121121
try:
122122
metadata["SeriesInstanceUID"] = str(metadata["SeriesInstanceUID"])
Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
1-
import logging
2-
from pathlib import Path
3-
import torch
4-
from diffusers import StableDiffusionPipeline
5-
from monai.deploy.core import AppContext, Application
6-
from PIL import Image
7-
import numpy as np
81
import argparse
2+
import logging
3+
4+
import torch
5+
from diffusers import StableDiffusionPipeline
96

7+
from monai.deploy.core import Application
108

119

1210
class App(Application):
13-
name = "Diffusion Image App"
14-
description = "Simple application showing diffusion to generate Images"
15-
def compose(self):
16-
model_id = "Nihirc/Prompt2MedImage"
17-
device = "cuda"
18-
parser = argparse.ArgumentParser()
19-
parser.add_argument("--input_prompt", type=str, default="Generate a X-ray")
20-
parser.add_argument("--output", type=str, default="./out.jpg")
21-
args = parser.parse_args()
22-
23-
input_prompt = args.input_prompt
24-
output_path = args.output
25-
print("Input Prompt: ", input_prompt)
26-
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
27-
pipe = pipe.to(device)
28-
prompt = "Show me an X ray pevic fracture"
29-
image = pipe(prompt).images[0]
30-
image.save(output_path)
11+
name = "Diffusion Image App"
12+
description = "Simple application showing diffusion to generate Images"
13+
14+
def compose(self):
15+
model_id = "Nihirc/Prompt2MedImage"
16+
device = "cuda"
17+
parser = argparse.ArgumentParser()
18+
parser.add_argument("--input_prompt", type=str, default="Generate a X-ray")
19+
parser.add_argument("--output", type=str, default="./out.jpg")
20+
args = parser.parse_args()
21+
22+
input_prompt = args.input_prompt
23+
output_path = args.output
24+
print("Input Prompt: ", input_prompt)
25+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
26+
pipe = pipe.to(device)
27+
prompt = "Show me an X ray pevic fracture"
28+
image = pipe(prompt).images[0]
29+
image.save(output_path)
3130

3231

3332
if __name__ == "__main__":
34-
logging.info(f"Begin {__name__}")
35-
App().run()
36-
logging.info(f"End {__name__}")
37-
38-
39-
33+
logging.info(f"Begin {__name__}")
34+
App().run()
35+
logging.info(f"End {__name__}")

examples/apps/mednist_classifier_monaideploy/mednist_classifier_monaideploy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class MedNISTClassifierOperator(Operator):
100100

101101
def __init__(
102102
self,
103-
frament: Fragment,
103+
fragment: Fragment,
104104
*args,
105105
app_context: AppContext,
106106
model_name: Optional[str] = "",
@@ -127,7 +127,7 @@ def __init__(
127127
# The name of the optional input port for passing data to override the output folder path.
128128
self.input_name_output_folder = "output_folder"
129129

130-
# The output folder set on the object can be overriden at each compute by data in the optional named input
130+
# The output folder set on the object can be overridden at each compute by data in the optional named input
131131
self.output_folder = output_folder
132132

133133
# Need the name when there are multiple models loaded
@@ -138,7 +138,7 @@ def __init__(
138138
self.model = self._get_model(self.app_context, self.model_path, self._model_name)
139139

140140
# This needs to be at the end of the constructor.
141-
super().__init__(frament, *args, **kwargs)
141+
super().__init__(fragment, *args, **kwargs)
142142

143143
def _get_model(self, app_context: AppContext, model_path: Path, model_name: str):
144144
"""Load the model with the given name from context or model path

examples/apps/simple_imaging_app/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
307307
# TAG-NUM-gHEX
308308
mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe)
309309
if not mo:
310-
# unparseable. Maybe git-describe is misbehaving?
310+
# unparsable. Maybe git-describe is misbehaving?
311311
pieces["error"] = ("unable to parse git-describe output: '%s'"
312312
% describe_out)
313313
return pieces

examples/apps/simple_imaging_app/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ def compose(self):
4949
output_data_path = Path(app_context.output_path)
5050
logging.info(f"sample_data_path: {sample_data_path}")
5151

52-
# Please note that the Application object, self, is passed as the first positonal argument
52+
# Please note that the Application object, self, is passed as the first positional argument
5353
# and the others as kwargs.
5454
# Also note the CountCondition of 1 on the first operator, indicating to the application executor
55-
# to invoke this operator, hence the pipleline, only once.
55+
# to invoke this operator, hence the pipeline, only once.
5656
sobel_op = SobelOperator(self, CountCondition(self, 1), input_path=sample_data_path, name="sobel_op")
5757
median_op = MedianOperator(self, name="median_op")
5858
gaussian_op = GaussianOperator(self, output_folder=output_data_path, name="gaussian_op")

examples/apps/simple_imaging_app/gaussian_operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class GaussianOperator(Operator):
2424
single input:
2525
an image array object
2626
single output:
27-
an image arrary object, without enforcing a downsteam receiver
27+
an image array object, without enforcing a downstream receiver
2828
2929
Besides, this operator also saves the image file in the given output folder.
3030
"""

monai/deploy/core/domain/dicom_series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def get_sop_instances(self):
5151
return self._sop_instances
5252

5353
# Properties named after DICOM Series module attribute keywords
54-
# There are two required (Type 1) attrbutes for a series:
54+
# There are two required (Type 1) attributes for a series:
5555
# Keyword: SeriesInstanceUID, Tag: (0020,000E)
5656
# Keyword: Modality, Tag: (0008,0060)
5757
#

monai/deploy/core/domain/dicom_sop_instance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828

2929
class DICOMSOPInstance(Domain):
30-
"""This class representes a SOP Instance.
30+
"""This class represents a SOP Instance.
3131
3232
An attribute can be looked up with a slice ([group_number, element number]).
3333
"""

monai/deploy/core/domain/dicom_study.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_all_series(self):
3535
return list(self._series_dict.values())
3636

3737
# Properties named after DICOM Study module attribute keywords
38-
# There is only one required (Type 1) attrbute for a study:
38+
# There is only one required (Type 1) attribute for a study:
3939
# Keyword: StudyInstanceUID, Tag: (0020,000D)
4040
#
4141
@property

monai/deploy/operators/clara_viz_operator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ClaraVizOperator(Operator):
3333
seg_image: Image object of the segmentation image derived from the input image.
3434
"""
3535

36-
def __init__(self, fragement: Fragment, *args, **kwargs):
36+
def __init__(self, fragment: Fragment, *args, **kwargs):
3737
"""Constructor of the operator.
3838
3939
Args:
@@ -43,7 +43,7 @@ def __init__(self, fragement: Fragment, *args, **kwargs):
4343
self.input_name_image = "image"
4444
self.input_name_seg_image = "seg_image"
4545

46-
super().__init__(fragement, *args, **kwargs)
46+
super().__init__(fragment, *args, **kwargs)
4747

4848
def setup(self, spec: OperatorSpec):
4949
spec.input(self.input_name_image)

monai/deploy/operators/dicom_encapsulated_pdf_writer_operator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ class DICOMEncapsulatedPDFWriterOperator(Operator):
4545
None
4646
4747
File output:
48-
Generaed DICOM instance file in the provided output folder.
48+
Generated DICOM instance file in the provided output folder.
4949
"""
5050

5151
# File extension for the generated DICOM Part 10 file.
5252
DCM_EXTENSION = ".dcm"
53-
# The default output folder for saveing the generated DICOM instance file.
53+
# The default output folder for saving the generated DICOM instance file.
5454
DEFAULT_OUTPUT_FOLDER = Path(os.getcwd()) / "output"
5555

5656
def __init__(
@@ -249,7 +249,7 @@ def _is_pdf_bytes(self, content: bytes):
249249
return True
250250

251251

252-
# Commenting out the following as pttype complains about the contructor for no reason
252+
# Commenting out the following as pttype complains about the constructor for no reason
253253
# def test(test_copy_tags: bool = True):
254254
# from monai.deploy.operators.dicom_data_loader_operator import DICOMDataLoaderOperator
255255
# from monai.deploy.operators.dicom_series_selector_operator import DICOMSeriesSelectorOperator

monai/deploy/operators/dicom_seg_writer_operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def __init__(
206206
Object encapsulating the description of each segment present in the segmentation.
207207
output_folder: Folder for file output, overridden by named input on compute.
208208
Defaults to current working dir's child folder, output.
209-
custom_tags: Optonal[Dict[str, str]], optional
209+
custom_tags: Optional[Dict[str, str]], optional
210210
Dictionary for setting custom DICOM tags using Keywords and str values only
211211
omit_empty_frames: bool, optional
212212
Whether to omit frames that contain no segmented pixels from the output segmentation.

monai/deploy/operators/dicom_text_sr_writer_operator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ class DICOMTextSRWriterOperator(Operator):
4242
None
4343
4444
File output:
45-
Generaed DICOM instance file in the provided output folder.
45+
Generated DICOM instance file in the provided output folder.
4646
"""
4747

4848
# File extension for the generated DICOM Part 10 file.
4949
DCM_EXTENSION = ".dcm"
50-
# The default output folder for saveing the generated DICOM instance file.
50+
# The default output folder for saving the generated DICOM instance file.
5151
# DEFAULT_OUTPUT_FOLDER = Path(os.path.join(os.path.dirname(__file__))) / "output"
5252
DEFAULT_OUTPUT_FOLDER = Path.cwd() / "output"
5353

@@ -259,7 +259,7 @@ def write(self, content_text, dicom_series: Optional[DICOMSeries], output_dir: P
259259
self._logger.info(f"DICOM SOP instance saved in {file_path}")
260260

261261

262-
# Commenting out the following as pttype complains about the contructor for no reason
262+
# Commenting out the following as pttype complains about the constructor for no reason
263263
# def test(test_copy_tags: bool = True):
264264
# from monai.deploy.operators.dicom_data_loader_operator import DICOMDataLoaderOperator
265265
# from monai.deploy.operators.dicom_series_selector_operator import DICOMSeriesSelectorOperator

0 commit comments

Comments
 (0)