<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Thanks for sharing the code Lifan, it might help somebody in the future.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 26, 2016 at 2:02 PM, Chen, Lifan <span dir="ltr"><<a href="mailto:LCHEN41@mgh.harvard.edu" target="_blank">LCHEN41@mgh.harvard.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt"><font size="3" face="Times New Roman">Hey Cyril and Dženan,</font>
<div><font size="3" face="Times New Roman"><br>
</font></div>
<div><font size="3" face="Times New Roman">Thanks very much for your help. I now fix this problem by using itkJoinSeriesImageFilter. This class could elevate a series of 3D volumes (x,y,z)*t into 4D level (x,y,z, t). Though I am not sure this is the best way
for ITK to do so, at least it is the best solution I could find for now and hope this could help if anyone would work on 4D series using ITK in future. Here is part of my code:</font></div>
<div><font size="3" face="Times New Roman"><br>
</font></div>
<div><font size="3" face="Times New Roman"><span style="white-space:pre-wrap"></span>typedef itk::JoinSeriesImageFilter<Image3DType, Image4DType> JoinSeriesImageFilterType;</font></div>
<div><font face="Times New Roman" size="3">
<div><span style="white-space:pre-wrap"></span>typedef itk::GDCMSeriesFileNames NamesGeneratorType;</div>
<div><span style="white-space:pre-wrap"></span>joinFilter = JoinSeriesImageFilterType::New();</div><span class="">
<div><span style="white-space:pre-wrap"></span>NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();</div>
</span><div><span style="white-space:pre-wrap"></span>nameGenerator->AddSeriesRestriction("0008|0032"); //Use diffrent restriction depend on the dicom header</div>
<div>
<div><span style="white-space:pre-wrap"></span>nameGenerator->SetUseSeriesDetails(true);</div>
<div><span style="white-space:pre-wrap"></span>nameGenerator->SetDirectory(_filename);</div>
</div>
<div>
<div><span style="white-space:pre-wrap"></span>typedef std::vector< std::string > FileNamesContainer;</div>
<div><span style="white-space:pre-wrap"></span>FileNamesContainer fileNames;</div><span class="">
<div><span style="white-space:pre-wrap"></span>if (true == _isFileLoaded){</div>
<div><span style="white-space:pre-wrap"></span>SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();</div>
<div><span style="white-space:pre-wrap"></span>SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();</div>
</span><div><span style="white-space:pre-wrap"></span>for (seriesItr; seriesItr != seriesEnd; seriesItr++){</div>
<div><span style="white-space:pre-wrap"></span>ReaderType::Pointer reader = ReaderType::New();</div>
<div><span style="white-space:pre-wrap"></span>std::string seriesIdentifier = seriesItr->c_str();</div><span class="">
<div><span style="white-space:pre-wrap"></span>fileNames = nameGenerator->GetFileNames(seriesIdentifier);</div>
<div><span style="white-space:pre-wrap"></span>reader->SetFileNames(fileNames);</div>
</span><div><span style="white-space:pre-wrap"></span>reader->Update();</div>
<div><span style="white-space:pre-wrap"></span>joinFilter->SetInput(inputIndex, reader->GetOutput());</div>
<div><span style="white-space:pre-wrap"></span>inputIndex++;</div>
<div><span style="white-space:pre-wrap"></span>}</div>
</div>
<div><span style="white-space:pre-wrap"></span>joinFilter->Update();</div>
<div><br>
</div>
<div>Best wishes,</div>
<div>Lifan</div>
</font></div>
<div>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div style="direction:ltr"><font face="Tahoma" size="2" color="#000000"><b>发件人:</b> Dženan Zukić [<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>]<br>
<b>发送时间:</b> 2016年2月26日 9:47<br>
<b>收件人:</b> Cyril Jaudet<br>
<b>抄送:</b> Chen, Lifan; <a href="mailto:community@itk.org" target="_blank">community@itk.org</a><br>
<b>主题:</b> Re: [ITK] 转发: ITK try to read 4D dicom time series(3d, t), but get 3d*t<br>
</font><br>
</div><div><div class="h5">
<div></div>
<div>
<div dir="ltr">
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
I only now see that you sent this only to me Cyril! I CC'd Lifan and the list.</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Feb 25, 2016 at 11:34 AM, Cyril Jaudet <span dir="ltr">
<<a href="mailto:drcjaudet@gmail.com" target="_blank">drcjaudet@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div>
<div>
<div>
<div>Hi Lifan, <br>
</div>
here some code that i past in the python interpreter of 3dslicer based on vtk.<br>
<br>
_First download slicer and load multi image module.<br>
</div>
_Import your serie with the dicom importer.<br>
</div>
_Go into the multivolume support/multivolume explorer<br>
</div>
_Enable frame copying or something similar.<br>
<div>
<div>
<div>Now you have two serie (module data to see/rename them)<br>
</div>
<div>1 multiframe serie<br>
</div>
<div>1 image that will be used as reference to extract the 3d + t image<br>
</div>
<div>_Copy/paste the following line in the python interpreter of 3dslicer.<br>
<br>
</div>
<div><br>
from __main__ import vtk, qt, ctk, slicer<br>
from math import *<br>
import numpy as np<br>
from vtk.util import numpy_support<br>
import SimpleITK as sitk<br>
import sitkUtils as su<br>
import math<br>
<br>
def convert4Dto3D(multi,reference):<br>
multiNode=slicer.util.getNode(multi)<br>
refNode=slicer.util.getNode(reference)<br>
multiImage=multiNode.GetImageData()<br>
N=multiNode.GetNumberOfFrames()<br>
for i in range (N): #extract image<br>
im=vtk.vtkImageExtractComponents()<br>
im.SetInputData(multiImage)<br>
im.SetComponents(i)<br>
im.Update()<br>
frame=slicer.modules.volumes.logic().CloneVolume(slicer.mrmlScene,refNode,'frame_'+str(i))<br>
frame.SetAndObserveImageData(im.GetOutput())<br>
<br>
<br>
</div>
<div>_then type:<br>
convert4Dto3D(multi,reference)<br>
</div>
<div>changing the name of multi and reference by the corresponding name of your data<br>
</div>
<div>_it will extract the image under the name frame0, frame1...<br>
</div>
<div>_save them <br>
<br>
</div>
<div>Hope that help,<br>
</div>
<div><br>
Cyril Jaudet<br>
</div>
<div>UZBrussel<br>
</div>
</div>
</div>
</div>
<div>
<div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2016-02-24 18:46 GMT+01:00 Dženan Zukić <span dir="ltr">
<<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
Hi Lifan,</div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
<br>
</div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
did you examine the DICOM headers? Do different timepoints have different acquisition times?</div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
<br>
</div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
Regards,</div>
<div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">
Dženan</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">
<div>
<div>On Wed, Feb 24, 2016 at 11:22 AM, Chen, Lifan <span dir="ltr"><<a href="mailto:LCHEN41@mgh.harvard.edu" target="_blank">LCHEN41@mgh.harvard.edu</a>></span> wrote:<br>
</div>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div>
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt"><font size="3">Hey all,</font>
<div><font size="3"><br>
</font></div>
<div><font size="3">Any help would be appreciated. This problem really gets me in for couple of days.</font></div>
<div><font size="3"><br>
</font></div>
<div><font size="3">Thanks,</font></div>
<div><font size="3">Lifan</font><br>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div style="direction:ltr"><font color="#000000" face="Tahoma" size="2"><b>发件人:</b> Chen, Lifan<br>
<b>发送时间:</b> 2016年2月23日 17:48<br>
<b>收件人:</b> <a href="mailto:community@itk.org" target="_blank">community@itk.org</a><br>
<b>主题:</b> ITK try to read 4D dicom time series(3d, t), but get 3d*t<br>
</font><br>
</div>
<div>
<div>
<div></div>
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt"><font size="3">Hi all,</font>
<div><font size="3"><br>
</font></div>
<div><font size="3">These days, I am trying to use ITK to handle 4D dicom series (3d+t). I use GDCMSeriesFileNames to generate seriesUIDs and ImageSeriesReader to read these images.</font></div>
<div><font size="3"><br>
</font></div>
<div><font size="3">The following is part of my code:</font></div>
<div>
<div><font size="3">typedef double PixelType;</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>typedef itk::Image< PixelType, 4> Image4DType; //4D image type</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>typedef itk::Image< PixelType, 3> Image3DType; //3D image type</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>typedef itk::ImageSeriesReader< Image4DType > ReaderType;</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>typedef itk::GDCMImageIO ImageIOType;</font></div>
</div>
<div>
<div><font size="3"><span style="white-space:pre-wrap"></span>reader = ReaderType::New();</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>dicomIO = ImageIOType::New();</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>typedef itk::GDCMSeriesFileNames NamesGeneratorType;</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>nameGenerator->AddSeriesRestriction("0008|0021");</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>nameGenerator->SetUseSeriesDetails(true);</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>nameGenerator->SetDirectory(_filename);</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>typedef std::vector< std::string > SeriesIdContainer;</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>_isFileLoaded = !(seriesUID.empty());</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>if (true == _isFileLoaded){</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>std::string seriesIdentifier = seriesUID.begin()->c_str();</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>typedef std::vector< std::string > FileNamesContainer;</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>FileNamesContainer fileNames;</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>fileNames = nameGenerator->GetFileNames(seriesIdentifier);</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>reader->SetFileNames(fileNames);</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>reader->SetImageIO(dicomIO);</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>reader->Update();</font></div>
<div><font size="3"><span style="white-space:pre-wrap"></span>}</font></div>
</div>
<div><font size="3"><br>
</font></div>
<div><font size="3">I have tried this code and the reader worked well. However I got a [x,y,z*t, 1] data, but not [x, y, z, t] data. I understand the problem may caused by nameGenerator, but I use SetUseSeriesDetails and AddSeriesRestriction("0008|0021")(aquisition
time)which are implied by documents to handle 4d images.I have also tried several methods but all not work. I wonder whether ITK have an original method to handle 4d images.</font></div>
<div><font size="3"><br>
</font></div>
<div><font size="3">Have anyone ever met this problem before? Any help or recommendations would be appreciated. </font></div>
<div><font size="3"><br>
</font></div>
<div><font size="3">Thanks,</font></div>
<div><font size="3">Lifan</font></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<p></p>
<p>The information in this e-mail is intended only for the person to whom it is<br>
addressed. If you believe this e-mail was sent to you in error and the e-mail<br>
contains patient information, please contact the Partners Compliance HelpLine at<br>
<a href="http://www.partners.org/complianceline" target="_blank">http://www.partners.org/complianceline</a> . If the e-mail was sent to you in error<br>
but does not contain patient information, please contact the sender and properly<br>
dispose of the e-mail.</p>
</div>
</div>
</div>
<br>
</div>
</div>
_______________________________________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
<br>
</blockquote>
</div>
<br>
</div>
<br>
_______________________________________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div></div></div>
</div>
</div>
</div>
</blockquote></div><br></div>