Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: GDCMImageIO SINGLEBIT image type #2004

Closed
wants to merge 2 commits into from

Conversation

issakomi
Copy link
Member

@issakomi issakomi commented Sep 16, 2020

SINGLEBIT image type for GDCMImageIO. Closes #1969.

@issakomi issakomi changed the title WIP: GDCMImageIO SINGLEBIT image type ENH: GDCMImageIO SINGLEBIT image type Sep 16, 2020
@issakomi
Copy link
Member Author

issakomi commented Sep 16, 2020

Test file (original from TCIA)

Simple test:

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include <iostream>

int main(int, char * argv[])
{
  using ImageType  = itk::Image<unsigned char, 3>;
  using ReaderType = itk::ImageFileReader<ImageType>;
  using WriterType = itk::ImageFileWriter<ImageType>;
  ReaderType::Pointer reader = ReaderType::New();
  WriterType::Pointer writer = WriterType::New();
  try
  {
    reader->SetFileName(argv[1]);
    reader->Update();
    writer->SetFileName("from_singlebit.mha");
    writer->SetInput(reader->GetOutput());
    writer->Update();
  }
  catch (const itk::ExceptionObject & ex)
  {
    std::cout << ex << std::endl;
    return 1;
  }
  return 0;
}

Edit: BTW, missing sinlge-bit image type was also mentioned here 2 years ago
https://discourse.slicer.org/t/segmentation-storage-1-2-840-10008-5-1-4-1-1-66-4/4274

@dzenanz
Copy link
Member

dzenanz commented Sep 16, 2020

Do you want to add a regression test yourself? Reusing the read/write test should be easy if you follow the pattern.

@issakomi
Copy link
Member Author

issakomi commented Sep 17, 2020

Thank you! Test program were probably easy, but unfortunately i don't know how it works with files, seems to be complicated, upload, links, etc. Is the file in above post OK, it is ~480 KB?

@dzenanz
Copy link
Member

dzenanz commented Sep 17, 2020

480KB is not bad, but a smaller one would be preferable. The simplest way is to use web interface to upload data, then use the web interface to download the hash file. Then reference it in test code just like the other input files.

@issakomi
Copy link
Member Author

issakomi commented Sep 18, 2020

Found smaller file ~ 46KB, original from TCIA.
Edit: upload to data portal

@issakomi
Copy link
Member Author

issakomi commented Sep 21, 2020

I have tried. Added

itk_add_test(NAME itkGDCM_ComplianceTest_singlebit
  COMMAND ITKIOGDCMTestDriver
    --compare DATA{Baseline/single-bit.mha}
      ${ITK_TEST_OUTPUT_DIR}/single-bit.mha
    itkGDCMImageReadWriteTest
      DATA{Input/single-bit.dcm}
      ${ITK_TEST_OUTPUT_DIR}/single-bit.mha
      scalar)

it produced compressed MHA file of float type: ElementType = MET_FLOAT, not sure it is good for binary mask. Also not sure do i need new function like function(AddComplianceTest fileName)

MET_FLOAT because test forces float.

  switch (pixelType)
  {
    case IOPixelType::SCALAR:
      ITK_TEST_EXPECT_EQUAL(numberOfComponents, 1);
      ITK_TEST_EXPECT_EQUAL(gdcmImageIO->GetPixelTypeAsString(pixelType), expectedPixelType);
      return ReadWrite<itk::Image<float, Dimension>>(inputImage, outputImage);

@issakomi
Copy link
Member Author

I have to know about that float before i shall upload mha file.

@dzenanz
Copy link
Member

dzenanz commented Sep 21, 2020

Since it is a binary mask, it should compress really well and be small. It does not matter that it is float. I think it is OK to upload.

@issakomi
Copy link
Member Author

issakomi commented Sep 21, 2020

OK, i have uploaded mha file and added sha512 files. The test seems to work

      Start 24: itkGDCM_ComplianceTest_singlebit
24/32 Test #24: itkGDCM_ComplianceTest_singlebit ................   Passed    0.04 sec

Another question, i see also md5 files for other input and baseline files, do i need to generate and add md5 file too?

@dzenanz
Copy link
Member

dzenanz commented Sep 21, 2020

You could, but this is usually done at the time of release by a script.

Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you amend the PR with the test+data?

@issakomi
Copy link
Member Author

Oh, something went wrong, commits should be merged, but they are not, probably i have done something wrong.

@issakomi
Copy link
Member Author

Somehow it is not correct. I am getting strange messages from git. I'll close the PR and re-create.

@issakomi issakomi closed this Sep 21, 2020
@issakomi issakomi deleted the singlebit branch September 21, 2020 17:26
@issakomi
Copy link
Member Author

S. #2010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: GDCMImageIO issue loading single-bit binary dcm mask.
2 participants