Skip to content

Commit b00c7b2

Browse files
committed
Rename sort-dicom-series to image-sets-normalization
1 parent 44b4e48 commit b00c7b2

19 files changed

+299
-83
lines changed

packages/dicom/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ set(CMAKE_CXX_STANDARD 17)
55

66
add_subdirectory(gdcm)
77
add_subdirectory(dcmtk)
8-
add_subdirectory(sort-dicom-series)

packages/dicom/gdcm/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ add_dependencies(${Iconv} ${Iconv_LIBRARY})
6363
add_executable(read-dicom-tags read-dicom-tags.cxx)
6464
target_link_libraries(read-dicom-tags PUBLIC ${ITK_LIBRARIES} ${Iconv_LIBRARIES} ${Iconv})
6565

66+
67+
add_executable(image-sets-normalization image-sets-normalization.cxx)
68+
target_link_libraries(image-sets-normalization PUBLIC ${ITK_LIBRARIES})
69+
70+
enable_testing()
71+
72+
add_test(NAME image-sets-normalization-help COMMAND image-sets-normalization --help)
73+
74+
add_test(NAME image-sets-normalization-smoke
75+
COMMAND image-sets-normalization image-sets.json --files
76+
${CMAKE_CURRENT_SOURCE_DIR}/test/data/input/DicomImageOrientationTest/ImageOrientation.1.dcm
77+
${CMAKE_CURRENT_SOURCE_DIR}/test/data/input/DicomImageOrientationTest/ImageOrientation.2.dcm
78+
${CMAKE_CURRENT_SOURCE_DIR}/test/data/input/DicomImageOrientationTest/ImageOrientation.3.dcm
79+
)
80+
81+
6682
if (EMSCRIPTEN)
6783
foreach(dicom_io_module
6884
read-image-dicom-file-series

packages/dicom/sort-dicom-series/sort-dicom-series.cxx renamed to packages/dicom/gdcm/image-sets-normalization.cxx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,28 @@
2525

2626
int main(int argc, char *argv[])
2727
{
28-
itk::wasm::Pipeline pipeline("sort-dicom-series", "Group DICOM files into volumes", argc, argv);
28+
itk::wasm::Pipeline pipeline("image-sets-normalization", "Group DICOM files into image sets", argc, argv);
2929

3030
std::vector<std::string> files;
31-
pipeline.add_option("--files", files, "DICOM files to group")->required()->check(CLI::ExistingFile)->type_size(1, -1)->type_name("INPUT_BINARY_FILE");
31+
pipeline.add_option("--files", files, "DICOM files")->required()->check(CLI::ExistingFile)->type_size(1, -1)->type_name("INPUT_BINARY_FILE");
3232

33-
itk::wasm::OutputTextStream volumes;
34-
pipeline.add_option("volumes", volumes, "Files grouped into volumes")->required()->type_name("OUTPUT_JSON");
33+
itk::wasm::OutputTextStream imageSetsMetadata;
34+
pipeline.add_option("image-sets-metadata", imageSetsMetadata, "Image sets JSON")->required()->type_name("OUTPUT_JSON");
3535

3636
ITK_WASM_PARSE(pipeline);
3737

38-
rapidjson::Document volumesJson;
39-
volumesJson.SetObject();
40-
rapidjson::Document::AllocatorType &allocator = volumesJson.GetAllocator();
38+
rapidjson::Document imageSetsJson;
39+
imageSetsJson.SetObject();
40+
rapidjson::Document::AllocatorType &allocator = imageSetsJson.GetAllocator();
4141

4242
rapidjson::Value almostEqualValue;
4343
almostEqualValue.SetBool(false);
44-
volumesJson.AddMember("almostEqual", almostEqualValue, allocator);
44+
imageSetsJson.AddMember("", almostEqualValue, allocator);
4545

4646
rapidjson::StringBuffer stringBuffer;
4747
rapidjson::Writer<rapidjson::StringBuffer> writer(stringBuffer);
48-
volumesJson.Accept(writer);
49-
volumes.Get() << stringBuffer.GetString();
48+
imageSetsJson.Accept(writer);
49+
imageSetsMetadata.Get() << stringBuffer.GetString();
5050

5151
return EXIT_SUCCESS;
5252
}

packages/dicom/python/itkwasm-dicom-emscripten/itkwasm_dicom_emscripten/js_package.py

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/dicom/python/itkwasm-dicom-wasi/test/test_sort_dicom_series.py

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Generated file. To retain edits, remove this comment.
2+
3+
from itkwasm_dicom_wasi import image
4+
5+
from .common import test_input_path, test_output_path
6+
7+
def test_sort_dicom_series():
8+
from itkwasm_dicom_wasi import image_sets_normalization
9+
10+
test_file_path = test_input_path / "DicomImageOrientationTest" / "ImageOrientation.1.dcm"
11+
12+
assert test_file_path.exists()
13+
14+
output_text = image_sets_normalization([test_file_path])
15+
assert output_text
16+

packages/dicom/sort-dicom-series/CMakeLists.txt

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Generated file. To retain edits, remove this comment.
2+
3+
import { BinaryFile } from 'itk-wasm'
4+
5+
interface ImageSetsNormalizationNodeOptions {
6+
/** DICOM files */
7+
files: string[] | File[] | BinaryFile[]
8+
9+
}
10+
11+
export default ImageSetsNormalizationNodeOptions
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Generated file. To retain edits, remove this comment.
2+
3+
import { JsonCompatible } from 'itk-wasm'
4+
5+
interface ImageSetsNormalizationNodeResult {
6+
/** Image sets JSON */
7+
imageSetsMetadata: JsonCompatible
8+
9+
}
10+
11+
export default ImageSetsNormalizationNodeResult
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Generated file. To retain edits, remove this comment.
2+
3+
import {
4+
JsonCompatible,
5+
InterfaceTypes,
6+
PipelineOutput,
7+
PipelineInput,
8+
runPipelineNode
9+
} from 'itk-wasm'
10+
11+
import ImageSetsNormalizationNodeOptions from './image-sets-normalization-node-options.js'
12+
import ImageSetsNormalizationNodeResult from './image-sets-normalization-node-result.js'
13+
14+
import path from 'path'
15+
import { fileURLToPath } from 'url'
16+
17+
/**
18+
* Group DICOM files into image sets
19+
*
20+
* @param {ImageSetsNormalizationNodeOptions} options - options object
21+
*
22+
* @returns {Promise<ImageSetsNormalizationNodeResult>} - result object
23+
*/
24+
async function imageSetsNormalizationNode(
25+
options: ImageSetsNormalizationNodeOptions = { files: [] as string[], }
26+
) : Promise<ImageSetsNormalizationNodeResult> {
27+
28+
const mountDirs: Set<string> = new Set()
29+
30+
const desiredOutputs: Array<PipelineOutput> = [
31+
{ type: InterfaceTypes.JsonCompatible },
32+
]
33+
34+
const inputs: Array<PipelineInput> = [
35+
]
36+
37+
const args = []
38+
// Inputs
39+
// Outputs
40+
const imageSetsMetadataName = '0'
41+
args.push(imageSetsMetadataName)
42+
43+
// Options
44+
args.push('--memory-io')
45+
if (options.files) {
46+
if(options.files.length < 1) {
47+
throw new Error('"files" option must have a length > 1')
48+
}
49+
args.push('--files')
50+
51+
options.files.forEach((value) => {
52+
mountDirs.add(path.dirname(value as string))
53+
args.push(value as string)
54+
})
55+
}
56+
57+
const pipelinePath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'pipelines', 'image-sets-normalization')
58+
59+
const {
60+
returnValue,
61+
stderr,
62+
outputs
63+
} = await runPipelineNode(pipelinePath, args, desiredOutputs, inputs, mountDirs)
64+
if (returnValue !== 0 && stderr !== "") {
65+
throw new Error(stderr)
66+
}
67+
68+
const result = {
69+
imageSetsMetadata: outputs[0]?.data as JsonCompatible,
70+
}
71+
return result
72+
}
73+
74+
export default imageSetsNormalizationNode

0 commit comments

Comments
 (0)