From c9abf8615bf77cba476066a7567eae2e3dee6037 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Sun, 20 Aug 2023 14:28:42 -0400 Subject: [PATCH] fix(dicom): Python Json types corrections, wasi dicom series handling --- .../apply_presentation_state_to_image_async.py | 4 +--- .../read_dicom_encapsulated_pdf_async.py | 2 +- .../read_image_dicom_file_series_async.py | 6 ++---- .../structured_report_to_html_async.py | 2 +- .../structured_report_to_text_async.py | 2 +- .../apply_presentation_state_to_image.py | 2 -- .../read_dicom_encapsulated_pdf.py | 2 +- .../read_image_dicom_file_series.py | 13 +++++-------- .../itkwasm_dicom_wasi/structured_report_to_html.py | 2 +- .../itkwasm_dicom_wasi/structured_report_to_text.py | 2 +- .../apply_presentation_state_to_image.py | 6 +++--- .../apply_presentation_state_to_image_async.py | 6 +++--- .../itkwasm_dicom/read_dicom_encapsulated_pdf.py | 2 +- .../read_dicom_encapsulated_pdf_async.py | 2 +- .../itkwasm_dicom/read_image_dicom_file_series.py | 6 +++--- .../read_image_dicom_file_series_async.py | 6 +++--- .../itkwasm_dicom/structured_report_to_html.py | 2 +- .../structured_report_to_html_async.py | 2 +- .../itkwasm_dicom/structured_report_to_text.py | 2 +- .../structured_report_to_text_async.py | 2 +- 20 files changed, 32 insertions(+), 41 deletions(-) diff --git a/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/apply_presentation_state_to_image_async.py b/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/apply_presentation_state_to_image_async.py index 0f2d8c318..196f9e4ee 100644 --- a/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/apply_presentation_state_to_image_async.py +++ b/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/apply_presentation_state_to_image_async.py @@ -1,8 +1,6 @@ -# Generated file. Do not edit. - from pathlib import Path import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from .js_package import js_package diff --git a/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/read_dicom_encapsulated_pdf_async.py b/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/read_dicom_encapsulated_pdf_async.py index 00bfab585..9ab05f49d 100644 --- a/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/read_dicom_encapsulated_pdf_async.py +++ b/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/read_dicom_encapsulated_pdf_async.py @@ -2,7 +2,7 @@ from pathlib import Path import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from .js_package import js_package diff --git a/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/read_image_dicom_file_series_async.py b/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/read_image_dicom_file_series_async.py index b27a79d8e..759c0d5cd 100644 --- a/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/read_image_dicom_file_series_async.py +++ b/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/read_image_dicom_file_series_async.py @@ -1,5 +1,3 @@ -# Generated file. Do not edit. - from pathlib import Path import os from typing import Dict, Tuple, Optional, List @@ -20,7 +18,7 @@ async def read_image_dicom_file_series_async( input_images: List[os.PathLike] = [], single_sorted_series: bool = False, -) -> Tuple[Image, Dict]: +) -> Tuple[Image, List[str]]: """Read a DICOM image series and return the associated image volume :param input_images: File names in the series @@ -33,7 +31,7 @@ async def read_image_dicom_file_series_async( :rtype: Image :return: Output sorted filenames - :rtype: Dict + :rtype: List[str] """ js_module = await js_package.js_module web_worker = js_resources.web_worker diff --git a/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/structured_report_to_html_async.py b/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/structured_report_to_html_async.py index 75de25957..040438210 100644 --- a/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/structured_report_to_html_async.py +++ b/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/structured_report_to_html_async.py @@ -2,7 +2,7 @@ from pathlib import Path import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from .js_package import js_package diff --git a/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/structured_report_to_text_async.py b/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/structured_report_to_text_async.py index a09a92a90..f6bc74a3b 100644 --- a/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/structured_report_to_text_async.py +++ b/packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/structured_report_to_text_async.py @@ -2,7 +2,7 @@ from pathlib import Path import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from .js_package import js_package diff --git a/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/apply_presentation_state_to_image.py b/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/apply_presentation_state_to_image.py index 942775c9b..c125faa94 100644 --- a/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/apply_presentation_state_to_image.py +++ b/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/apply_presentation_state_to_image.py @@ -1,5 +1,3 @@ -# Generated file. Do not edit. - from pathlib import Path, PurePosixPath import os from typing import Dict, Tuple, Optional, List diff --git a/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/read_dicom_encapsulated_pdf.py b/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/read_dicom_encapsulated_pdf.py index db09e03ec..0b1432c7c 100644 --- a/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/read_dicom_encapsulated_pdf.py +++ b/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/read_dicom_encapsulated_pdf.py @@ -2,7 +2,7 @@ from pathlib import Path, PurePosixPath import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from importlib_resources import files as file_resources diff --git a/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/read_image_dicom_file_series.py b/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/read_image_dicom_file_series.py index 4a7b8fa5e..f86f3d152 100644 --- a/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/read_image_dicom_file_series.py +++ b/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/read_image_dicom_file_series.py @@ -1,5 +1,3 @@ -# Generated file. Do not edit. - from pathlib import Path, PurePosixPath import os from typing import Dict, Tuple, Optional, List @@ -20,7 +18,7 @@ def read_image_dicom_file_series( input_images: List[os.PathLike] = [], single_sorted_series: bool = False, -) -> Tuple[Image, Dict]: +) -> Tuple[Image, List[str]]: """Read a DICOM image series and return the associated image volume :param input_images: File names in the series @@ -33,7 +31,7 @@ def read_image_dicom_file_series( :rtype: Image :return: Output sorted filenames - :rtype: Dict + :rtype: List[str] """ global _pipeline if _pipeline is None: @@ -53,10 +51,9 @@ def read_image_dicom_file_series( args.append('0') args.append('1') # Options - if len(input_images) > 1: - if len(input_images) < 1: - raise ValueError('"input-images" option must have a length > 1') - + if len(input_images) < 1: + raise ValueError('"input-images" kwarg must have a length > 1') + if len(input_images) > 0: args.append('--input-images') for value in input_images: input_file = str(PurePosixPath(input_images)) diff --git a/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/structured_report_to_html.py b/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/structured_report_to_html.py index 1edd9fc8e..3d1167535 100644 --- a/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/structured_report_to_html.py +++ b/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/structured_report_to_html.py @@ -2,7 +2,7 @@ from pathlib import Path, PurePosixPath import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from importlib_resources import files as file_resources diff --git a/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/structured_report_to_text.py b/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/structured_report_to_text.py index a9cd04f18..173ee5e1c 100644 --- a/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/structured_report_to_text.py +++ b/packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/structured_report_to_text.py @@ -2,7 +2,7 @@ from pathlib import Path, PurePosixPath import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from importlib_resources import files as file_resources diff --git a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/apply_presentation_state_to_image.py b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/apply_presentation_state_to_image.py index 26fb0e121..30b572a52 100644 --- a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/apply_presentation_state_to_image.py +++ b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/apply_presentation_state_to_image.py @@ -1,7 +1,7 @@ # Generated file. Do not edit. import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from itkwasm import ( environment_dispatch, @@ -17,7 +17,7 @@ def apply_presentation_state_to_image( frame: int = 1, no_presentation_state_output: bool = False, no_bitmap_output: bool = False, -) -> Tuple[Dict, Image]: +) -> Tuple[Any, Image]: """Apply a presentation state to a given DICOM image and render output as bitmap, or dicom file. :param image_in: Input DICOM file @@ -42,7 +42,7 @@ def apply_presentation_state_to_image( :type no_bitmap_output: bool :return: Output overlay information - :rtype: Dict + :rtype: Any :return: Output image :rtype: Image diff --git a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/apply_presentation_state_to_image_async.py b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/apply_presentation_state_to_image_async.py index 496c6d6e6..0244b908c 100644 --- a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/apply_presentation_state_to_image_async.py +++ b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/apply_presentation_state_to_image_async.py @@ -1,7 +1,7 @@ # Generated file. Do not edit. import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from itkwasm import ( environment_dispatch, @@ -17,7 +17,7 @@ async def apply_presentation_state_to_image_async( frame: int = 1, no_presentation_state_output: bool = False, no_bitmap_output: bool = False, -) -> Tuple[Dict, Image]: +) -> Tuple[Any, Image]: """Apply a presentation state to a given DICOM image and render output as bitmap, or dicom file. :param image_in: Input DICOM file @@ -42,7 +42,7 @@ async def apply_presentation_state_to_image_async( :type no_bitmap_output: bool :return: Output overlay information - :rtype: Dict + :rtype: Any :return: Output image :rtype: Image diff --git a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_dicom_encapsulated_pdf.py b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_dicom_encapsulated_pdf.py index 945013615..a24bd2ca7 100644 --- a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_dicom_encapsulated_pdf.py +++ b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_dicom_encapsulated_pdf.py @@ -1,7 +1,7 @@ # Generated file. Do not edit. import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from itkwasm import ( environment_dispatch, diff --git a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_dicom_encapsulated_pdf_async.py b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_dicom_encapsulated_pdf_async.py index 714bcf40a..9c49bc1d9 100644 --- a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_dicom_encapsulated_pdf_async.py +++ b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_dicom_encapsulated_pdf_async.py @@ -1,7 +1,7 @@ # Generated file. Do not edit. import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from itkwasm import ( environment_dispatch, diff --git a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_image_dicom_file_series.py b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_image_dicom_file_series.py index 355feaa85..6bdaa757e 100644 --- a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_image_dicom_file_series.py +++ b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_image_dicom_file_series.py @@ -1,7 +1,7 @@ # Generated file. Do not edit. import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from itkwasm import ( environment_dispatch, @@ -12,7 +12,7 @@ def read_image_dicom_file_series( input_images: List[os.PathLike] = [], single_sorted_series: bool = False, -) -> Tuple[Image, Dict]: +) -> Tuple[Image, Any]: """Read a DICOM image series and return the associated image volume :param input_images: File names in the series @@ -25,7 +25,7 @@ def read_image_dicom_file_series( :rtype: Image :return: Output sorted filenames - :rtype: Dict + :rtype: Any """ func = environment_dispatch("itkwasm_dicom", "read_image_dicom_file_series") output = func(input_images=input_images, single_sorted_series=single_sorted_series) diff --git a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_image_dicom_file_series_async.py b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_image_dicom_file_series_async.py index 4a9169167..25083ddb8 100644 --- a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_image_dicom_file_series_async.py +++ b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_image_dicom_file_series_async.py @@ -1,7 +1,7 @@ # Generated file. Do not edit. import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from itkwasm import ( environment_dispatch, @@ -12,7 +12,7 @@ async def read_image_dicom_file_series_async( input_images: List[os.PathLike] = [], single_sorted_series: bool = False, -) -> Tuple[Image, Dict]: +) -> Tuple[Image, Any]: """Read a DICOM image series and return the associated image volume :param input_images: File names in the series @@ -25,7 +25,7 @@ async def read_image_dicom_file_series_async( :rtype: Image :return: Output sorted filenames - :rtype: Dict + :rtype: Any """ func = environment_dispatch("itkwasm_dicom", "read_image_dicom_file_series_async") output = await func(input_images=input_images, single_sorted_series=single_sorted_series) diff --git a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_html.py b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_html.py index 08aedf246..df78180b4 100644 --- a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_html.py +++ b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_html.py @@ -1,7 +1,7 @@ # Generated file. Do not edit. import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from itkwasm import ( environment_dispatch, diff --git a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_html_async.py b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_html_async.py index 02e867840..2e648038b 100644 --- a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_html_async.py +++ b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_html_async.py @@ -1,7 +1,7 @@ # Generated file. Do not edit. import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from itkwasm import ( environment_dispatch, diff --git a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_text.py b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_text.py index b6eb84687..1a432dc9d 100644 --- a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_text.py +++ b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_text.py @@ -1,7 +1,7 @@ # Generated file. Do not edit. import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from itkwasm import ( environment_dispatch, diff --git a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_text_async.py b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_text_async.py index 08a35dc4e..fc06f2f43 100644 --- a/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_text_async.py +++ b/packages/dicom/python/itkwasm-dicom/itkwasm_dicom/structured_report_to_text_async.py @@ -1,7 +1,7 @@ # Generated file. Do not edit. import os -from typing import Dict, Tuple, Optional, List +from typing import Dict, Tuple, Optional, List, Any from itkwasm import ( environment_dispatch,