-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
213 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/_version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "2.1.0" | ||
__version__ = "3.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...n/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/read_image_dicom_file_series_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Generated file. Do not edit. | ||
|
||
from pathlib import Path | ||
import os | ||
from typing import Dict, Tuple, Optional, List | ||
|
||
from .js_package import js_package | ||
|
||
from itkwasm.pyodide import ( | ||
to_js, | ||
to_py, | ||
js_resources | ||
) | ||
from itkwasm import ( | ||
InterfaceTypes, | ||
Image, | ||
BinaryFile, | ||
) | ||
|
||
async def read_image_dicom_file_series_async( | ||
input_images: List[os.PathLike] = [], | ||
single_sorted_series: bool = False, | ||
) -> Tuple[Image, Dict]: | ||
"""Read a DICOM image series and return the associated image volume | ||
:param input_images: File names in the series | ||
:type input_images: os.PathLike | ||
:param single_sorted_series: The input files are a single sorted series | ||
:type single_sorted_series: bool | ||
:return: Output image volume | ||
:rtype: Image | ||
:return: Output sorted filenames | ||
:rtype: Dict | ||
""" | ||
js_module = await js_package.js_module | ||
web_worker = js_resources.web_worker | ||
|
||
kwargs = {} | ||
if input_images is not None: | ||
kwargs["inputImages"] = to_js(BinaryFile(input_images)) | ||
if single_sorted_series: | ||
kwargs["singleSortedSeries"] = to_js(single_sorted_series) | ||
|
||
outputs = await js_module.readImageDicomFileSeries(web_worker, **kwargs) | ||
|
||
output_web_worker = None | ||
output_list = [] | ||
outputs_object_map = outputs.as_object_map() | ||
for output_name in outputs.object_keys(): | ||
if output_name == 'webWorker': | ||
output_web_worker = outputs_object_map[output_name] | ||
else: | ||
output_list.append(to_py(outputs_object_map[output_name])) | ||
|
||
js_resources.web_worker = output_web_worker | ||
|
||
if len(output_list) == 1: | ||
return output_list[0] | ||
return tuple(output_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/_version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "2.1.0" | ||
__version__ = "3.0.0" |
77 changes: 77 additions & 0 deletions
77
packages/dicom/python/itkwasm-dicom-wasi/itkwasm_dicom_wasi/read_image_dicom_file_series.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Generated file. Do not edit. | ||
|
||
from pathlib import Path, PurePosixPath | ||
import os | ||
from typing import Dict, Tuple, Optional, List | ||
|
||
from importlib_resources import files as file_resources | ||
|
||
_pipeline = None | ||
|
||
from itkwasm import ( | ||
InterfaceTypes, | ||
PipelineOutput, | ||
PipelineInput, | ||
Pipeline, | ||
Image, | ||
BinaryFile, | ||
) | ||
|
||
def read_image_dicom_file_series( | ||
input_images: List[os.PathLike] = [], | ||
single_sorted_series: bool = False, | ||
) -> Tuple[Image, Dict]: | ||
"""Read a DICOM image series and return the associated image volume | ||
:param input_images: File names in the series | ||
:type input_images: os.PathLike | ||
:param single_sorted_series: The input files are a single sorted series | ||
:type single_sorted_series: bool | ||
:return: Output image volume | ||
:rtype: Image | ||
:return: Output sorted filenames | ||
:rtype: Dict | ||
""" | ||
global _pipeline | ||
if _pipeline is None: | ||
_pipeline = Pipeline(file_resources('itkwasm_dicom_wasi').joinpath(Path('wasm_modules') / Path('read-image-dicom-file-series.wasi.wasm'))) | ||
|
||
pipeline_outputs: List[PipelineOutput] = [ | ||
PipelineOutput(InterfaceTypes.Image), | ||
PipelineOutput(InterfaceTypes.JsonObject), | ||
] | ||
|
||
pipeline_inputs: List[PipelineInput] = [ | ||
] | ||
|
||
args: List[str] = ['--memory-io',] | ||
# Inputs | ||
# Outputs | ||
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') | ||
|
||
args.append('--input-images') | ||
for value in input_images: | ||
input_file = str(PurePosixPath(input_images)) | ||
pipeline_inputs.append(PipelineInput(InterfaceTypes.BinaryFile, BinaryFile(value))) | ||
args.append(input_file) | ||
|
||
if single_sorted_series: | ||
args.append('--single-sorted-series') | ||
|
||
|
||
outputs = _pipeline.run(args, pipeline_outputs, pipeline_inputs) | ||
|
||
result = ( | ||
outputs[0].data, | ||
outputs[1].data.data, | ||
) | ||
return result | ||
|
Binary file added
BIN
+5.79 MB
...itkwasm-dicom-wasi/itkwasm_dicom_wasi/wasm_modules/read-image-dicom-file-series.wasi.wasm
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "2.1.0" | ||
__version__ = "3.0.0" |
32 changes: 32 additions & 0 deletions
32
packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_image_dicom_file_series.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated file. Do not edit. | ||
|
||
import os | ||
from typing import Dict, Tuple, Optional, List | ||
|
||
from itkwasm import ( | ||
environment_dispatch, | ||
Image, | ||
BinaryFile, | ||
) | ||
|
||
def read_image_dicom_file_series( | ||
input_images: List[os.PathLike] = [], | ||
single_sorted_series: bool = False, | ||
) -> Tuple[Image, Dict]: | ||
"""Read a DICOM image series and return the associated image volume | ||
:param input_images: File names in the series | ||
:type input_images: os.PathLike | ||
:param single_sorted_series: The input files are a single sorted series | ||
:type single_sorted_series: bool | ||
:return: Output image volume | ||
:rtype: Image | ||
:return: Output sorted filenames | ||
:rtype: Dict | ||
""" | ||
func = environment_dispatch("itkwasm_dicom", "read_image_dicom_file_series") | ||
output = func(input_images=input_images, single_sorted_series=single_sorted_series) | ||
return output |
32 changes: 32 additions & 0 deletions
32
packages/dicom/python/itkwasm-dicom/itkwasm_dicom/read_image_dicom_file_series_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated file. Do not edit. | ||
|
||
import os | ||
from typing import Dict, Tuple, Optional, List | ||
|
||
from itkwasm import ( | ||
environment_dispatch, | ||
Image, | ||
BinaryFile, | ||
) | ||
|
||
async def read_image_dicom_file_series_async( | ||
input_images: List[os.PathLike] = [], | ||
single_sorted_series: bool = False, | ||
) -> Tuple[Image, Dict]: | ||
"""Read a DICOM image series and return the associated image volume | ||
:param input_images: File names in the series | ||
:type input_images: os.PathLike | ||
:param single_sorted_series: The input files are a single sorted series | ||
:type single_sorted_series: bool | ||
:return: Output image volume | ||
:rtype: Image | ||
:return: Output sorted filenames | ||
:rtype: Dict | ||
""" | ||
func = environment_dispatch("itkwasm_dicom", "read_image_dicom_file_series_async") | ||
output = await func(input_images=input_images, single_sorted_series=single_sorted_series) | ||
return output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters