[ITK] [ITK-users] Translation on each Dicom on a Directory

Francois Budin francois.budin at kitware.com
Mon Mar 27 09:40:40 EDT 2017


Hello,

If I understand correctly what you are saying, you were able to use
itkImageSeriesReader [1] but you do not want all your files of dimension
N-1 to be merged altogether in a file of dimension N, correct?
In this case, you will have to read each file individually with
itkImageReader. You can still use itkNumericSeriesFileNames to create the
list of file names.

Your code could look like this (modify and complete what you need:

typedef itk::NumericSeriesFileNames    NameGeneratorType;
NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
nameGenerator->SetSeriesFormat( argv[1] );

nameGenerator->SetStartIndex( first );
nameGenerator->SetEndIndex( last );
nameGenerator->SetIncrementIndex( 1 );
std::vector<std::string> names = nameGenerator->GetFileNames();

typedef itk::ImageFileReader<ImageType> ReaderType;
  std::vector<std::string>::iterator nit;
  for (nit = names.begin();
       nit != names.end();
       nit++)
    {
    ReaderType::Pointer reader = ReaderType::New();
    reader->SetFileName((*nit).c_str());
    reader->Update();
    ////////////
    // Do your computation
    ////////
    }


Hope this helps,
Francois

[1] https://itk.org/Doxygen/html/classitk_1_1ImageSeriesReader.html

On Fri, Mar 24, 2017 at 7:46 PM, Matias <matimontg at gmail.com> wrote:

> Hi,
>
> I need to read a directory which contains X number of Dicom images. I have
> no troubles doing this by passing a parameter with the name of each file to
> ITK but I'd like to read one by one and do the translation in a For. Sounds
> simple but I could not find an example where you read a directory, process
> images one by one on a For and then write the resultant image (within the
> same For) to an output directory..
>
> Does anyone know where I can find an example (of any kind) for reading a
> directory and doing some processing (any type) in a For?
>
> Thank you!
>
>
>
> --
> View this message in context: http://itk-users.7.n7.nabble.
> com/Translation-on-each-Dicom-on-a-Directory-tp38034.html
> Sent from the ITK - Users mailing list archive at Nabble.com.
> _____________________________________
> 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://public.kitware.com/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20170327/b014ff7e/attachment.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://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list