[Insight-users] using MINC with ITK: how to define negative
pixels... more developments
Audette, Michel
Michel.Audette at medizin.uni-leipzig.de
Fri Apr 20 12:55:57 EDT 2007
Hi folks,
after downloading the MINC reader for ITK, whose tar file is MINC2_ITK_APR13.tar.gz, I noticed that
the value m_Shift computed in this reader is apparently not used by ITK: the value assumed is 0, which is causing a scaling from 0 to the maximum, rather than from the intended minimum to the maximum (the input is unsigned short, according to mincinfo, but it scales from -5200 to 10000 apparently).
As a test, I set this parameter to 0 in void MINC2ImageIO::SetSliceScalingFromLocalScaling(mihandle_t volume),
/*m_Shift = min - (valid_min *m_Scale);*/
m_Shift= 0.0;
std::cout << "scale A" << m_Scale << " valid_max " << valid_max
<< " valid_min " << valid_min << " max " << max
<< " min " << min << " m_Shift " << m_Shift << std::endl;
and I found that my histogram of a MINC CT file was unaffected.
Can someone suggest where this parameter should be read for the image to be properly scaled?
Is this something that was resolved in some other release of MINC2 IO support?
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
P.S.: print details
with m_Shift set to 0:
Reading MINC2.0 Format Image: becken_boehme_final_ct.mnc2
scale A3.71184 valid_max 4095 valid_min 0 max 10000 min -5200 m_Shift 0
number of components 1
after close
valid range valid_min 4095 valid_min 0
valid range volume_minmax0 -5200 volume_minmax1 10000
Converting random index to world coordinates
Index 0 0 0
Point 165.5 83.5 -1427.5 pixel value 868
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
bin = 9 frequency = 74941 measurement = 9235
previously, with usual m_Shift:
scale A3.71184 valid_max 4095 valid_min 0 max 10000 min -5200 m_Shift -5200
number of components 1
after close
valid range valid_min 4095 valid_min 0
valid range volume_minmax0 -5200 volume_minmax1 10000
Converting random index to world coordinates
Index 0 0 0
Point 165.5 83.5 -1427.5 pixel value 868
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
bin = 9 frequency = 74941 measurement = 9235
-----Original Message-----
From: Audette, Michel
Sent: Fri 4/20/2007 10:22 AM
To: minc-users at bic.mni.mcgill.ca; insight-users at itk.org
Subject: using MINC with ITK: how to define negative pixels?
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