Discussion:
[ITK-users] Translation on each Dicom on a Directory
Matias
2017-03-24 23:46:18 UTC
Permalink
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
Francois Budin
2017-03-27 13:40:40 UTC
Permalink
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
Post by Matias
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
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
Loading...