<div dir="ltr"><div><div><div><div>Your data has a non-zero intercept:<br>(0028|1052) Rescale Intercept = 0 <br>(0028|1053) Rescale Slope = 3.010012<br><br></div>When ITK reads DICOM images it applies the slope and intercept:<br>
</div>value = slope * pixel + intercept<br><br></div><div>So a short or unsigned short cannot represent the values exactly. But that should only have a small error if you use a signed quantity like short.<br></div><div></div>
<br>If you define your image type as float, everything works correctly.<br><br></div><div>ITK seems to read and convert the data, but is not writing it correctly. <br></div><div><br></div><div>So, there does seem to be a problem with ITK, but at least for now you can declare your image type as float and all should be fine.<br>
</div><div><br></div>Bill<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 14, 2013 at 5:22 AM, Constantine Zakkaroff <span dir="ltr"><<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Bill,<br>
<br>
I'm wondering if you've had a chance to try it out with the data I emailed?<br>
<br>
I've tried it out with the 'Top to Bottom' dataset from <a href="http://placid.nlm.nih.gov/community/21" target="_blank">http://placid.nlm.nih.gov/<u></u>community/21</a> and it all looks completely legit. But with my data it gets all screwed up... What a strange thing!<br>
<br>
Regards,<br>
Constantine<div class="im HOEnZb"><br>
<br>
<br>
<br>
On 12/08/2013 20:09, Constantine Zakkaroff wrote:<br>
</div><div class="HOEnZb"><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Bill.<br>
<br>
OK. I actually read and write only once slice in this test.<br>
<br>
Please find it attached: MR.1.3.46.670589.11.38102.5.0.<u></u>7452.rar.<br>
<br>
I get DICOM images without extension.<br>
<br>
I'm also attaching the saved file with changed intensity: file00.rar.<br>
<br>
Many thanks,<br>
Constantine<br>
<br>
On 12/08/2013 19:51, Bill Lorensen wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I also tried VTK3.20 and got the same good results.<br>
<br>
<br>
You could try one of these:<br>
<a href="http://placid.nlm.nih.gov/community/21" target="_blank">http://placid.nlm.nih.gov/<u></u>community/21</a><br>
<br>
If your data is anonymized, perhaps you can send me a link or just a few<br>
slices.<br>
<br>
Bill<br>
<br>
<br>
<br>
On Mon, Aug 12, 2013 at 2:45 PM, Constantine Z <<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a><br>
<mailto:<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a>>> wrote:<br>
<br>
Thanks. Yes, I can see it all looks completely legit.<br>
<br>
Perhaps I can send you my data? MR from a Philips scanner. Or maybe<br>
on Win it might work differently?<br>
<br>
Regards,<br>
Constartine<br>
<br>
<br>
On 12/08/2013 7:38 p.m., Bill Lorensen wrote:<br>
<br>
<br>
I just tried your code on two different dicom datasets, a ct and<br>
an mr.<br>
<br>
Both worked for me.<br>
./DICOMTest ~/Data/itkTestcases/Back\ to\ Front/ .<br>
ITK Version: 4.5<br>
Stats for file: /home/lorensen/Data/__<u></u>itkTestcases/Back to<br>
Front//i24389.MRDC.34<br>
Min: 0, Max: 293, Mean: 28.7654, Sigma: 37.2513, Variance:<br>
1387.66, Sum:<br>
1.88517e+06<br>
Stats for file: ./file00.dcm<br>
Min: 0, Max: 293, Mean: 28.7654, Sigma: 37.2513, Variance:<br>
1387.66, Sum:<br>
1.88517e+06<br>
[build] ./DICOMTest ~/Data/NAV/CT/ ./<br>
ITK Version: 4.5<br>
Stats for file: /home/lorensen/Data/NAV/CT//__<u></u>ct.1<br>
Min: -1024, Max: 31744, Mean: 6277.24, Sigma: 13249.9, Variance:<br>
1.75559e+08, Sum: 1.64554e+09<br>
Stats for file: .//file00.dcm<br>
Min: -1024, Max: 31744, Mean: 6277.24, Sigma: 13249.9, Variance:<br>
1.75559e+08, Sum: 1.64554e+09<br>
<br>
<br>
<br>
<br>
On Mon, Aug 12, 2013 at 11:46 AM, Constantine Zakkaroff<br>
<<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a> <mailto:<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a>><br>
<mailto:<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a> <mailto:<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a>>>> wrote:<br>
<br>
Hi Brad,<br>
<br>
Yes, here's the minimal code:<br>
<br>
<br>
******************************<u></u>____**************************<u></u>**__**__************<br>
<br>
#include <cstdlib><br>
#include <itkImage.h><br>
#include <itkMetaImageIO.h><br>
#include <itkGDCMImageIO.h><br>
#include <itkGDCMSeriesFileNames.h><br>
#include <itkImageFileReader.h><br>
#include <itkImageFileWriter.h><br>
#include <itkStatisticsImageFilter.h><br>
<br>
int main(int argc, char *argv[])<br>
{<br>
std::clog << "ITK Version: " << ITK_VERSION_STRING <<<br>
std::endl;<br>
<br>
typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br>
typedef itk::Image<short, 3> ImageType;<br>
<br>
NamesGeneratorType::Pointer namesGenerator =<br>
NamesGeneratorType::New();<br>
namesGenerator->____<u></u>SetUseSeriesDetails(true);<br>
namesGenerator->____<u></u>SetInputDirectory(argv[1]);<br>
<br>
typedef itk::StatisticsImageFilter<___<u></u>_ImageType><br>
StatsFilterType;<br>
typedef itk::ImageFileReader<____<u></u>ImageType><br>
ImageReaderType;<br>
typedef itk::ImageFileWriter<____<u></u>ImageType><br>
ImageWriterType;<br>
<br>
<br>
ImageReaderType::Pointer imageReader0 =<br>
ImageReaderType::New();<br>
imageReader0->SetImageIO(itk::<u></u>____GDCMImageIO::New());<br>
<br>
StatsFilterType::Pointer statsFilter0 =<br>
StatsFilterType::New();<br>
<br>
<br>
imageReader0->SetFileName(____<u></u>namesGenerator->____<u></u>GetInputFileNames()[0]);<br>
statsFilter0->SetInput(____<u></u>imageReader0->GetOutput());<br>
<br>
statsFilter0->Update();<br>
<br>
std::clog << "Stats for file: " <<<br>
namesGenerator->____<u></u>GetInputFileNames()[0] << std::endl;<br>
<br>
std::clog <<<br>
"Min: " << statsFilter0->GetMinimum() << ", "<br>
"Max: " << statsFilter0->GetMaximum() << ", "<br>
"Mean: " << statsFilter0->GetMean() << ", "<br>
"Sigma: " << statsFilter0->GetSigma() << ", "<br>
"Variance: " <<<br>
statsFilter0->GetVariance() << ", "<br>
"Sum: " << statsFilter0->GetSum()<br>
<< std::endl;<br>
<br>
ImageWriterType::Pointer imageWriter0 =<br>
ImageWriterType::New();<br>
imageWriter0->SetInput(____<u></u>imageReader0->GetOutput());<br>
imageWriter0->SetImageIO(itk::<u></u>____GDCMImageIO::New());<br>
<br>
std::string fileName0 = std::string(argv[2]) +<br>
"/file00.dcm";<br>
imageWriter0->SetFileName(____<u></u>fileName0);<br>
<br>
imageWriter0->Update();<br>
<br>
ImageReaderType::Pointer imageReader1 =<br>
ImageReaderType::New();<br>
imageReader1->SetImageIO(itk::<u></u>____GDCMImageIO::New());<br>
<br>
StatsFilterType::Pointer statsFilter1 =<br>
StatsFilterType::New();<br>
imageReader1->SetFileName(____<u></u>fileName0);<br>
statsFilter1->SetInput(____<u></u>imageReader1->GetOutput());<br>
<br>
statsFilter1->Update();<br>
<br>
std::clog << "Stats for file: " << fileName0 <<<br>
std::endl;<br>
std::clog <<<br>
"Min: " << statsFilter1->GetMinimum() << ", "<br>
"Max: " << statsFilter1->GetMaximum() << ", "<br>
"Mean: " << statsFilter1->GetMean() << ", "<br>
"Sigma: " << statsFilter1->GetSigma() << ", "<br>
"Variance: " <<<br>
statsFilter1->GetVariance() << ", "<br>
"Sum: " << statsFilter1->GetSum()<br>
<< std::endl;<br>
<br>
system("pause");<br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
******************************<u></u>____**************************<u></u>**__**__************<br>
<br>
<br>
Many thanks,<br>
Constantine<br>
<br>
<br>
On 12/08/2013 14:48, Bradley Lowekamp wrote:<br>
<br>
<br>
Do you have the code to share so that it can be easily<br>
reproduced?<br>
<br>
<br>
Thanks,<br>
Brad<br>
<br>
On Aug 12, 2013, at 9:33 AM, Constantine Zakkaroff<br>
<<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a> <mailto:<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a>><br>
<mailto:<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a> <mailto:<a href="mailto:mnkz@leeds.ac.uk" target="_blank">mnkz@leeds.ac.uk</a>>>> wrote:<br>
<br>
Hello ALL,<br>
<br>
I'm wondering if anyone can explain what's going on<br>
with the<br>
changing image intensities in a read-write-read<br>
round-trip.<br>
I think it's a bug, but the <a href="http://issues.itk.org" target="_blank">issues.itk.org</a><br>
<<a href="http://issues.itk.org" target="_blank">http://issues.itk.org</a>><br>
<<a href="http://issues.itk.org" target="_blank">http://issues.itk.org</a>> is unresponsive at the moment.<br>
<br>
Another bug? ;)<br>
<br>
Anyhow, the strange thing is that the results for<br>
the round<br>
trip read-write-read test are very different for<br>
ITK 3.20<br>
and ITK 4.4.1.<br>
<br>
I use to StatisticsImageFilter to examine the intensity<br>
values. Here's what happens, when I simply read a DICOM<br>
image, print stats, save the image and read it again,<br>
followed by printing the stats:<br>
<br>
ITK Version: 3.20<br>
Stats for original file:<br>
Min: 0, Max: 2474, Mean: 169.236, Sigma: 256.719,<br>
Variance:<br>
65904.7, Sum: 1.40371e+007<br>
Stats for saved file:<br>
Min: 0, Max: 2471, Mean: 167.132, Sigma: 256.125,<br>
Variance:<br>
65600.1, Sum: 1.38626e+007<br>
<br>
ITK Version: 4.4<br>
Stats for original file:<br>
Min: 0, Max: 2474, Mean: 169.236, Sigma: 256.719,<br>
Variance:<br>
65904.7, Sum: 1.40371e+007<br>
Stats for saved file:<br>
Min: 0, Max: 7446, Mean: 509.114, Sigma: 772.59,<br>
Variance:<br>
596895, Sum: 4.22279e+007<br>
<br>
In both cases the code is identical. Just compiled<br>
against<br>
different versions of ITK. The images are read and<br>
written<br>
as itk::Image<unsigned short, 3>, with no<br>
processing, no<br>
changes to any aspect of the images.<br>
<br>
So, ITK 3.20 introduces a small change, which I'm<br>
pretty<br>
sure shouldn't be there. But in ITK 4.4.1 the scale of<br>
intensities changes three-fold.<br>
<br>
I'd not be surprised by a change of this magnitude<br>
if I was<br>
photocopying those images, but not when using digital<br>
software and hardware. :^) Is there something I'm not<br>
understanding here?<br>
<br>
None of this happens with<br>
read(DICOM)-write(MHD)-read(__<u></u>__MHD), where the<br>
original and<br>
<br>
round-trip values are identical:<br>
Stats for saved file: file0.mhd<br>
Min: 0, Max: 2474, Mean: 169.236, Sigma: 256.719,<br>
Variance:<br>
65904.7, Sum: 1.40371e+007<br>
<br>
Many thanks,<br>
Constantine<br>
<br>
______________________________<u></u>___________<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a> <<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>><br>
<<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/____opensource/opensource.html" target="_blank">http://www.kitware.com/____<u></u>opensource/opensource.html</a><br>
<<a href="http://www.kitware.com/__opensource/opensource.html" target="_blank">http://www.kitware.com/__<u></u>opensource/opensource.html</a>><br>
<br>
<br>
<<a href="http://www.kitware.com/__opensource/opensource.html" target="_blank">http://www.kitware.com/__<u></u>opensource/opensource.html</a><br>
<<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<u></u>opensource/opensource.html</a>>><br>
<br>
Kitware offers ITK Training Courses, for more<br>
information visit:<br>
<a href="http://www.kitware.com/____products/protraining.php" target="_blank">http://www.kitware.com/____<u></u>products/protraining.php</a><br>
<<a href="http://www.kitware.com/__products/protraining.php" target="_blank">http://www.kitware.com/__<u></u>products/protraining.php</a>><br>
<br>
<<a href="http://www.kitware.com/__products/protraining.php" target="_blank">http://www.kitware.com/__<u></u>products/protraining.php</a><br>
<<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/<u></u>products/protraining.php</a>>><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_____FAQ" target="_blank">http://www.itk.org/Wiki/ITK___<u></u>__FAQ</a><br>
<<a href="http://www.itk.org/Wiki/ITK___FAQ" target="_blank">http://www.itk.org/Wiki/ITK__<u></u>_FAQ</a>><br>
<br>
<<a href="http://www.itk.org/Wiki/ITK___FAQ" target="_blank">http://www.itk.org/Wiki/ITK__<u></u>_FAQ</a><br>
<<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_<u></u>FAQ</a>>><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/____listinfo/insight-users" target="_blank">http://www.itk.org/mailman/___<u></u>_listinfo/insight-users</a><br>
<<a href="http://www.itk.org/mailman/__listinfo/insight-users" target="_blank">http://www.itk.org/mailman/__<u></u>listinfo/insight-users</a>><br>
<br>
<<a href="http://www.itk.org/mailman/__listinfo/insight-users" target="_blank">http://www.itk.org/mailman/__<u></u>listinfo/insight-users</a><br>
<<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/<u></u>listinfo/insight-users</a>>><br>
<br>
<br>
______________________________<u></u>___________<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a> <<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>><br>
<<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/____opensource/opensource.html" target="_blank">http://www.kitware.com/____<u></u>opensource/opensource.html</a><br>
<<a href="http://www.kitware.com/__opensource/opensource.html" target="_blank">http://www.kitware.com/__<u></u>opensource/opensource.html</a>><br>
<br>
<<a href="http://www.kitware.com/__opensource/opensource.html" target="_blank">http://www.kitware.com/__<u></u>opensource/opensource.html</a><br>
<<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<u></u>opensource/opensource.html</a>>><br>
<br>
Kitware offers ITK Training Courses, for more information<br>
visit:<br>
<a href="http://www.kitware.com/____products/protraining.php" target="_blank">http://www.kitware.com/____<u></u>products/protraining.php</a><br>
<<a href="http://www.kitware.com/__products/protraining.php" target="_blank">http://www.kitware.com/__<u></u>products/protraining.php</a>><br>
<br>
<<a href="http://www.kitware.com/__products/protraining.php" target="_blank">http://www.kitware.com/__<u></u>products/protraining.php</a><br>
<<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/<u></u>products/protraining.php</a>>><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_____FAQ" target="_blank">http://www.itk.org/Wiki/ITK___<u></u>__FAQ</a><br>
<<a href="http://www.itk.org/Wiki/ITK___FAQ" target="_blank">http://www.itk.org/Wiki/ITK__<u></u>_FAQ</a>><br>
<<a href="http://www.itk.org/Wiki/ITK___FAQ" target="_blank">http://www.itk.org/Wiki/ITK__<u></u>_FAQ</a><br>
<<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_<u></u>FAQ</a>>><br>
<br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/____listinfo/insight-users" target="_blank">http://www.itk.org/mailman/___<u></u>_listinfo/insight-users</a><br>
<<a href="http://www.itk.org/mailman/__listinfo/insight-users" target="_blank">http://www.itk.org/mailman/__<u></u>listinfo/insight-users</a>><br>
<br>
<<a href="http://www.itk.org/mailman/__listinfo/insight-users" target="_blank">http://www.itk.org/mailman/__<u></u>listinfo/insight-users</a><br>
<<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/<u></u>listinfo/insight-users</a>>><br>
<br>
<br>
<br>
<br>
--<br>
Unpaid intern in BillsBasement at noware dot com<br>
<br>
<br>
<br>
<br>
<br>
--<br>
Unpaid intern in BillsBasement at noware dot com<br>
</blockquote></blockquote>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Unpaid intern in BillsBasement at noware dot com<br>
</div>