<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body fpstyle="1" ocsi="0">
<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 class="Apple-tab-span" style="white-space:pre"></span>typedef itk::JoinSeriesImageFilter<Image3DType, Image4DType> JoinSeriesImageFilterType;</font></div>
<div><font face="Times New Roman" size="3">
<div><span class="Apple-tab-span" style="white-space:pre"></span>typedef itk::GDCMSeriesFileNames NamesGeneratorType;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>joinFilter = JoinSeriesImageFilterType::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>nameGenerator->AddSeriesRestriction("0008|0032");  //Use diffrent restriction depend on the dicom header</div>
<div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>nameGenerator->SetUseSeriesDetails(true);</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>nameGenerator->SetDirectory(_filename);</div>
</div>
<div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>typedef std::vector< std::string >   FileNamesContainer;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>FileNamesContainer fileNames;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>if (true == _isFileLoaded){</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>for (seriesItr; seriesItr != seriesEnd; seriesItr++){</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>ReaderType::Pointer reader = ReaderType::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>std::string seriesIdentifier = seriesItr->c_str();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>fileNames = nameGenerator->GetFileNames(seriesIdentifier);</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>reader->SetFileNames(fileNames);</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>reader->Update();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>joinFilter->SetInput(inputIndex, reader->GetOutput());</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>inputIndex++;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>}</div>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></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 tabindex="-1">
<div id="divRpF349763" style="direction: ltr;"><font face="Tahoma" size="2" color="#000000"><b>发件人:</b> Dženan Zukić [dzenanz@gmail.com]<br>
<b>发送时间:</b> 2016年2月26日 9:47<br>
<b>收件人:</b> Cyril Jaudet<br>
<b>抄送:</b> Chen, Lifan; community@itk.org<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>
<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 class="HOEnZb">
<div class="h5">
<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>
</body>
</html>