-
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.
Merge pull request #1165 from jadh4v/dcmqi-seg
Dcmqi seg
- Loading branch information
Showing
128 changed files
with
5,853 additions
and
101 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
.../python/itkwasm-compare-images-emscripten/itkwasm_compare_images_emscripten/js_package.py
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+158 Bytes
(100%)
...pare-images-wasi/itkwasm_compare_images_wasi/wasm_modules/compare-double-images.wasi.wasm
Binary file not shown.
Binary file modified
BIN
+158 Bytes
(100%)
...m-compare-images-wasi/itkwasm_compare_images_wasi/wasm_modules/vector-magnitude.wasi.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
...itkwasm-compress-stringify-emscripten/itkwasm_compress_stringify_emscripten/js_package.py
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+160 Bytes
(100%)
...-stringify-wasi/itkwasm_compress_stringify_wasi/wasm_modules/compress-stringify.wasi.wasm
Binary file not shown.
Binary file modified
BIN
+160 Bytes
(100%)
...ngify-wasi/itkwasm_compress_stringify_wasi/wasm_modules/parse-string-decompress.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,2 +1,2 @@ | ||
const defaultImageTag = '20240810-4e9a4bf0' | ||
const defaultImageTag = '20240822-c390b350' | ||
export default defaultImageTag |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/*========================================================================= | ||
* Copyright NumFOCUS | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0.txt | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*=========================================================================*/ | ||
|
||
// DCMQI includes | ||
// #undef HAVE_SSTREAM // Avoid redefinition warning | ||
#include "dcmqi/Dicom2ItkConverter.h" | ||
#include "dcmqi/internal/VersionConfigure.h" | ||
|
||
// DCMTK includes | ||
#include "dcmtk/oflog/configrt.h" | ||
|
||
// ITK includes | ||
#include "itkComposeImageFilter.h" | ||
#include "itkVectorImage.h" | ||
|
||
// ITK-wasm includes | ||
#include "itkPipeline.h" | ||
#include "itkOutputImage.h" | ||
#include "itkOutputTextStream.h" | ||
|
||
typedef dcmqi::Helper helper; | ||
constexpr unsigned int Dimension = 3; | ||
using PixelType = short; | ||
using ScalarImageType = itk::Image<PixelType, Dimension>; | ||
using VectorImageType = itk::VectorImage<PixelType, Dimension>; | ||
|
||
int runPipeline( | ||
const std::string & inputSEGFileName, | ||
itk::wasm::OutputImage<VectorImageType>& outputImage, | ||
itk::wasm::OutputTextStream& outputMetaInfoJSON, | ||
const bool mergeSegments) | ||
{ | ||
#if !defined(NDEBUG) || defined(_DEBUG) | ||
// Display DCMTK debug, warning, and error logs in the console | ||
dcmtk::log4cplus::BasicConfigurator::doConfigure(); | ||
#endif | ||
|
||
if(helper::isUndefinedOrPathDoesNotExist(inputSEGFileName, "Input DICOM file")) | ||
{ | ||
std::cerr << "ERROR: " << inputSEGFileName.c_str() << " is undefined or path does not exist." << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
DcmRLEDecoderRegistration::registerCodecs(); | ||
|
||
DcmFileFormat sliceFF; | ||
// std::cout << "Loading DICOM SEG file " << inputSEGFileName << std::endl; | ||
CHECK_COND(sliceFF.loadFile(inputSEGFileName.c_str())); | ||
DcmDataset* dataset = sliceFF.getDataset(); | ||
|
||
try | ||
{ | ||
dcmqi::Dicom2ItkConverter converter; | ||
std::string metaInfo; | ||
OFCondition result = converter.dcmSegmentation2itkimage(dataset, metaInfo, mergeSegments); | ||
if (result.bad()) | ||
{ | ||
std::cerr << "ERROR: Failed to convert DICOM SEG to ITK image: " << result.text() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
using ImageToVectorImageFilterType = itk::ComposeImageFilter<ScalarImageType>; | ||
auto imageToVectorImageFilter = ImageToVectorImageFilterType::New(); | ||
int inputNumber = 0; | ||
for (auto itkImage = converter.begin(); itkImage != nullptr; itkImage = converter.next()) | ||
{ | ||
imageToVectorImageFilter->SetInput(inputNumber++, itkImage); | ||
} | ||
imageToVectorImageFilter->Update(); | ||
VectorImageType::Pointer vectorImage = imageToVectorImageFilter->GetOutput(); | ||
if (!vectorImage) | ||
{ | ||
std::cerr << "Failed to create VectorImage." << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
outputImage.Set(vectorImage); | ||
outputMetaInfoJSON.Get() << metaInfo.c_str(); | ||
return EXIT_SUCCESS; | ||
} | ||
catch (int e) | ||
{ | ||
std::cerr << "Fatal error encountered." << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
} | ||
|
||
int main(int argc, char * argv[]) | ||
{ | ||
itk::wasm::Pipeline pipeline("read-overlapping-segmentation", "Read DICOM segmentation object with overlapping segments into a VectorImage.", argc, argv); | ||
|
||
std::string dicomFileName; | ||
pipeline.add_option("dicom-file", dicomFileName, "Input DICOM file")->required()->check(CLI::ExistingFile)->type_name("INPUT_BINARY_FILE"); | ||
|
||
itk::wasm::OutputImage<VectorImageType> outputImage; | ||
pipeline.add_option("seg-image", outputImage, "dicom segmentation object as an image")->required()->type_name("OUTPUT_IMAGE"); | ||
|
||
itk::wasm::OutputTextStream outputMetaInfoJSON; | ||
pipeline.add_option("meta-info", outputMetaInfoJSON, "Output overlay information")->type_name("OUTPUT_JSON"); | ||
|
||
bool mergeSegments{false}; | ||
pipeline.add_flag("--merge-segments", mergeSegments, "Merge segments into a single image"); | ||
|
||
ITK_WASM_PARSE(pipeline); | ||
|
||
// Pipeline code goes here | ||
runPipeline(dicomFileName, outputImage, outputMetaInfoJSON, mergeSegments); | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
|
Oops, something went wrong.