[ITK] [ITK-users] Resampling and manual image
Matt McCormick
matt.mccormick at kitware.com
Mon Apr 28 09:26:02 EDT 2014
Hi Guillaume,
A few pointers may help:
- Make sure to use ITK 4.5.2 or later, which has fixes for writing DICOM
series spacing.
- Use a different format than DICOM when possible for writing out generated
files. It is difficult to get the tags correct, especially with an
operation like resampling where the number of slices can change.
- See this guide for further tips [1].
- See this example for reference [2].
Hope this helps,
Matt
[1] http://gdcm.sourceforge.net/wiki/index.php/Writing_DICOM
[2] http://www.itk.org/Wiki/ITK/Examples/DICOM/ResampleDICOM
On Tue, Apr 22, 2014 at 2:43 PM, Guillaume Lemaître
<g.lemaitre58 at gmail.com>wrote:
> Hi all,
>
> I would like to have some advise to do the following task.
>
> I have a set of annotated DICOM (binary 0 - 255 intensity) with a given
> spacing, orientation and position. This manual segmentation is
> corresponding to a prostate from an initial T2W sequence.
>
> A part of DICOM, I have an MRSI sequence from Siemens (*.rda) in which the
> header is containing information such as position, orientation and spacing
> of the csi grid matrix used during the acquisition.
>
> My aim would be to resample the annotated DICOM serie into a new DICOM
> serie using the MRSI header. I attached the code that I tried to implement
> to do this task but I don't succeed to obtain a correct serie when saving
> into a DICOM serie. When opening the stored DICOM serie, it seems that the
> field regarding the z spacing and the position of the first voxel are not
> equal to the one of the rda manually affected during the resampling.
>
> I was wondering to know the best way to do such manipulation. For
> instance, it could be better to create a manual image using the field of
> the rda file and just use the intensities
>
> ResampleFilterType::Pointer resampler = ResampleFilterType::New();
>
> resampler->SetInput(inputAnnotatedVolume->GetOutput());
>
> resampler->SetTransform(transform);
>
> resampler->SetInterpolator(interpolator);
>
> // Create a type compatible to ITK
>
> // Define the new origin
>
> double* outputOrigin = new double [rdaPatient.getPositionPatient().size()];
>
> for(int i = 0; i < rdaPatient.getPositionPatient().size(); i++)
>
> outputOrigin[i] = rdaPatient.getPositionPatient()[i];
>
> resampler->SetOutputOrigin(outputOrigin);
>
> // Define the new spacing
>
> double* outputSpacing = new double [rdaPatient.getPixelSpacing().size()];
>
> for(int i = 0; i < rdaPatient.getPixelSpacing().size(); i++)
>
> outputSpacing[i] = rdaPatient.getPixelSpacing()[i];
>
> resampler->SetOutputSpacing(outputSpacing);
>
> // Define the new orientation
>
> typename ResampleFilterType::DirectionType outputDirection;
>
> //double ** outputDirection = new double* [3];
>
> //for(int i = 0; i < 3 ; i++)
>
> // outputDirection[i] = new double [3];
>
> // Affect the new values
>
> outputDirection[0][0] = rdaPatient.getOrientationPatient()[0][0];
>
> outputDirection[0][1] = rdaPatient.getOrientationPatient()[0][1];
>
> outputDirection[0][2] = rdaPatient.getVoiNormalVector()[0];
>
> outputDirection[1][0] = rdaPatient.getOrientationPatient()[1][0];
>
> outputDirection[1][1] = rdaPatient.getOrientationPatient()[1][1];
>
> outputDirection[1][2] = rdaPatient.getVoiNormalVector()[1];
>
> outputDirection[2][0] = rdaPatient.getOrientationPatient()[2][0];
>
> outputDirection[2][1] = rdaPatient.getOrientationPatient()[2][1];
>
> outputDirection[2][2] = rdaPatient.getVoiNormalVector()[2];
>
> resampler->SetOutputDirection(inputAnnotatedVolume->GetOutput()->GetDirection());
>
> // Define the size of the ouput
>
> // Let's comput the new size
>
> InputImageType::SizeType outputSize;
>
> typedef InputImageType::SizeType::SizeValueType SizeValueType;
>
> outputSize[0] = static_cast<SizeValueType>(rdaPatient.getCsiMatrixSize()[0]);
>
> outputSize[1] = static_cast<SizeValueType>(rdaPatient.getCsiMatrixSize()[1]);
>
> outputSize[2] = static_cast<SizeValueType>(rdaPatient.getCsiMatrixSize()[2]);
>
> resampler->SetSize(outputSize);
>
> // Resampling now
>
> resampler->Update();
>
>
> Thanks in advance for the advices,
>
> --
>
>
>
>
> *LEMAÎTRE Guillaume PhD CandiateMSc Erasmus Mundus ViBOT
> (Vision-roBOTic)MSc Business Innovation and Technology Management (in
> progress) *
> g.lemaitre58 at gmail.com
>
> *ViCOROB - Computer Vision and Robotic Team*
> Universitat de Girona, Campus Montilivi, Edifici P-IV 17071 Girona
> Tel. +34 972 41 98 12 - Fax. +34 972 41 82 59
> http://vicorob.udg.es/
>
> *LE2I - Le Creusot*IUT Le Creusot, Laboratoire LE2I, 12 rue de la
> Fonderie, 71200 Le Creusot
> Tel. +33 3 85 73 10 90 - Fax. +33 3 85 73 10 97
> http://le2i.cnrs.fr
>
> https://sites.google.com/site/glemaitre58/
> Vice - Chairman of A.S.C. Fours UFOLEP
> Chairman of A.S.C. Fours FFC
> Webmaster of http://ascfours.free.fr
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140428/b8a905df/attachment-0002.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users
More information about the Community
mailing list