[ITK] 答复: 转发: ITK try to read 4D dicom time series(3d, t), but get 3d*t

Chen, Lifan LCHEN41 at mgh.harvard.edu
Fri Feb 26 14:02:43 EST 2016


Hey Cyril and Dženan,

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:

typedef itk::JoinSeriesImageFilter<Image3DType, Image4DType> JoinSeriesImageFilterType;
typedef itk::GDCMSeriesFileNames NamesGeneratorType;
joinFilter = JoinSeriesImageFilterType::New();
NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
nameGenerator->AddSeriesRestriction("0008|0032");  //Use diffrent restriction depend on the dicom header
nameGenerator->SetUseSeriesDetails(true);
nameGenerator->SetDirectory(_filename);
typedef std::vector< std::string >   FileNamesContainer;
FileNamesContainer fileNames;
if (true == _isFileLoaded){
SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
for (seriesItr; seriesItr != seriesEnd; seriesItr++){
ReaderType::Pointer reader = ReaderType::New();
std::string seriesIdentifier = seriesItr->c_str();
fileNames = nameGenerator->GetFileNames(seriesIdentifier);
reader->SetFileNames(fileNames);
reader->Update();
joinFilter->SetInput(inputIndex, reader->GetOutput());
inputIndex++;
}
joinFilter->Update();

Best wishes,
Lifan
________________________________
发件人: Dženan Zukić [dzenanz at gmail.com]
发送时间: 2016年2月26日 9:47
收件人: Cyril Jaudet
抄送: Chen, Lifan; community at itk.org
主题: Re: [ITK] 转发: ITK try to read 4D dicom time series(3d, t), but get 3d*t

I only now see that you sent this only to me Cyril! I CC'd Lifan and the list.

On Thu, Feb 25, 2016 at 11:34 AM, Cyril Jaudet <drcjaudet at gmail.com<mailto:drcjaudet at gmail.com>> wrote:
Hi Lifan,
here some code that i past in the python interpreter of 3dslicer based on vtk.

_First download slicer and load multi image module.
_Import your serie with the dicom importer.
_Go into the multivolume support/multivolume explorer
_Enable frame copying or something similar.
Now you have two serie (module data to see/rename them)
1 multiframe serie
1 image that will be used as reference to extract the 3d + t image
_Copy/paste the following line in the python interpreter of 3dslicer.


from __main__ import vtk, qt, ctk, slicer
from math import *
import numpy as np
from vtk.util import numpy_support
import SimpleITK as sitk
import sitkUtils as su
import math

def convert4Dto3D(multi,reference):
    multiNode=slicer.util.getNode(multi)
    refNode=slicer.util.getNode(reference)
    multiImage=multiNode.GetImageData()
    N=multiNode.GetNumberOfFrames()
    for i in range (N):    #extract image
        im=vtk.vtkImageExtractComponents()
        im.SetInputData(multiImage)
        im.SetComponents(i)
        im.Update()
        frame=slicer.modules.volumes.logic().CloneVolume(slicer.mrmlScene,refNode,'frame_'+str(i))
        frame.SetAndObserveImageData(im.GetOutput())


_then type:
convert4Dto3D(multi,reference)
changing the name of multi and reference by the corresponding name of your data
_it will extract the image under the name frame0, frame1...
_save them

Hope that help,

Cyril Jaudet
UZBrussel

2016-02-24 18:46 GMT+01:00 Dženan Zukić <dzenanz at gmail.com<mailto:dzenanz at gmail.com>>:
Hi Lifan,

did you examine the DICOM headers? Do different timepoints have different acquisition times?

Regards,
Dženan

On Wed, Feb 24, 2016 at 11:22 AM, Chen, Lifan <LCHEN41 at mgh.harvard.edu<mailto:LCHEN41 at mgh.harvard.edu>> wrote:
Hey all,

Any help would be appreciated. This problem really gets me in for couple of days.

Thanks,
Lifan
________________________________
发件人: Chen, Lifan
发送时间: 2016年2月23日 17:48
收件人: community at itk.org<mailto:community at itk.org>
主题: ITK try to read 4D dicom time series(3d, t), but get 3d*t

Hi all,

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.

The following is part of my code:
typedef double    PixelType;
typedef itk::Image< PixelType, 4>         Image4DType;                  //4D image type
typedef itk::Image< PixelType, 3>         Image3DType;                  //3D image type
typedef itk::ImageSeriesReader< Image4DType >        ReaderType;
typedef itk::GDCMImageIO       ImageIOType;
reader = ReaderType::New();
dicomIO = ImageIOType::New();
typedef itk::GDCMSeriesFileNames NamesGeneratorType;
NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
nameGenerator->AddSeriesRestriction("0008|0021");
nameGenerator->SetUseSeriesDetails(true);
nameGenerator->SetDirectory(_filename);
typedef std::vector< std::string >    SeriesIdContainer;
const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
_isFileLoaded = !(seriesUID.empty());
if (true == _isFileLoaded){
SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
std::string seriesIdentifier = seriesUID.begin()->c_str();
typedef std::vector< std::string >   FileNamesContainer;
FileNamesContainer fileNames;
fileNames = nameGenerator->GetFileNames(seriesIdentifier);
reader->SetFileNames(fileNames);
reader->SetImageIO(dicomIO);
reader->Update();
}

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.

Have anyone ever met this problem before? Any help or recommendations would be appreciated.

Thanks,
Lifan

The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

_______________________________________________
Community mailing list
Community at itk.org<mailto:Community at itk.org>
http://public.kitware.com/mailman/listinfo/community



_______________________________________________
Community mailing list
Community at itk.org<mailto:Community at itk.org>
http://public.kitware.com/mailman/listinfo/community



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20160226/0def5efa/attachment-0001.html>


More information about the Community mailing list