[Insight-users] using MINC with ITK: how to define negative pixels?

Audette, Michel Michel.Audette at medizin.uni-leipzig.de
Fri Apr 20 04:22:39 EDT 2007


Dear all, 

I am trying to use the MINC reader in ITK, and although this CT image features a substantial proportion of background voxels around -5200, when I try to do a histogram and to define the PixelType as integer (not unsigned int), the program fails to pick up the negative voxels. 

For example, setting a histogram size of 10, I get output like this (I have a few print statements in the Insight Minc code as well): 

Reading MINC2.0 Format Image: becken_boehme_final_ct.mnc2
valid range volume_minmax0 -5200  volume_minmax1 10000
setting Histogram with min -5200  and max 10000
Histogram size 10
bin = 0 frequency = 0  measurement = -4535
bin = 1 frequency = 0  measurement = -3005
bin = 2 frequency = 0  measurement = -1475
bin = 3 frequency = 1.67772e+07  measurement = 55
bin = 4 frequency = 8.33189e+06  measurement = 1585
bin = 5 frequency = 59577  measurement = 3115
bin = 6 frequency = 88832  measurement = 4645
bin = 7 frequency = 97040  measurement = 6175
bin = 8 frequency = 81357  measurement = 7705

The file is apparently of type unsigned short, 
maudette at icaw164201:~/research/source/voxelseg_pelvis> mincinfo becken_boehme_final_ct.mnc
file: becken_boehme_final_ct.mnc
image: unsigned short 0 to 4095
image dimensions: zspace yspace xspace
    dimension name         length         step        start
    --------------         ------         ----        -----
    zspace                    284    -0.732422      -1427.5
    yspace                    512    -0.732422         83.5
    xspace                    512    -0.732422        165.5

but the internal scale factors map those unsigned shorts to a range between -5200 to 10000, and this range of values is visible with Display software from the MNI. 

Can anyone suggest a course of action to fix this? 

Btwn, the source code appears below (and similar results with typedef short or unsigned short PixelType, and setting number of bins 100, 1000 and so on...)  
  typedef int       PixelType;

  // using itkOrientedImage to make sure direction cosines 
  // are taken into account! (itkImage will not do that)
  typedef itk::OrientedImage<PixelType, 3> myImage;
  myImage::Pointer imagefixed;
  myImage::IndexType pixelIndex;

  // Read the image in MINC2.0 format
  std::cout << "Reading MINC2.0 Format Image: " << ctFile << std::endl;
  typedef itk::ImageFileReader<myImage>  ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName( ctFile );
  
  typedef itk::MINC2ImageIO        ImageIOType;
  ImageIOType::Pointer minc2ImageIO = ImageIOType::New();
  
  reader->SetImageIO( minc2ImageIO );
  try
    {
    reader->Update();
    }
  catch (itk::ExceptionObject & e)
    {
      std::cerr << "exception in file reader " << std::endl;
      std::cerr << e.GetDescription() << std::endl;
      std::cerr << e.GetLocation() << std::endl;
      return EXIT_FAILURE;
    }

  typedef itk::Statistics::ScalarImageToHistogramGenerator<myImage>   HistogramGeneratorType;
  HistogramGeneratorType::Pointer histogramGenerator = HistogramGeneratorType::New();
  histogramGenerator->SetInput(  reader->GetOutput() );
  histogramGenerator->SetNumberOfBins( 10 );
  histogramGenerator->SetMarginalScale( 10.0 );
  histogramGenerator->SetHistogramMin(  (minc2ImageIO->getVolumeMin()-100) );
  histogramGenerator->SetHistogramMax(  minc2ImageIO->getVolumeMax() );
  std::cout << " setting Histogram with min " << minc2ImageIO->getVolumeMin() 
	    << "  and max " << minc2ImageIO->getVolumeMax() << " \n"; 
  histogramGenerator->Compute();
  typedef HistogramGeneratorType::HistogramType  HistogramType;
  const HistogramType * histogram = histogramGenerator->GetOutput();
  const unsigned int histogramSize = histogram->Size();
  std::cout << "Histogram size " << histogramSize << std::endl;
  unsigned int bin;
  for( bin=0; bin < histogramSize; bin++ )
    {
      std::cout << "bin = " << bin << " frequency = ";
      std::cout << histogram->GetFrequency( bin, 0 ) 
		<< "  measurement = " << histogram->GetMeasurement( bin, 0 ) << std::endl;
    }
   
Best regards, 

Michel Audette, Ph.D.  
Innovation Center Computer Assisted Surgery (ICCAS)  
Philipp-Rosenthal-Strasse 55 
Leipzig, Germany 
Phone: ++49 (0) 341 / 97 - 1 20 13 
Fax: ++49 (0) 341 / 97 - 1 20 09 

 

 

 




More information about the Insight-users mailing list