[prev in list] [next in list] [prev in thread] [next in thread] 

List:       insight-users
Subject:    Re: [ITK-users] Translation on each Dicom on a Directory
From:       Francois Budin <francois.budin () kitware ! com>
Date:       2017-03-27 13:40:40
Message-ID: CAHwLD2VStQWzVPhFCGvR1BF6jMBd8Sdd7q8NMn_sKvAeMn6qkA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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@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
>

[Attachment #5 (text/html)]

<div dir="ltr"><div><div><div>Hello,<br><br></div>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?<br></div>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.<br><br></div>Your code could look like this (modify and complete what you \
need:<br><br>typedef itk::NumericSeriesFileNames      \
NameGeneratorType;<br>NameGeneratorType::Pointer nameGenerator = \
NameGeneratorType::New();<div><div>nameGenerator-&gt;SetSeriesFormat( argv[1] );<br>  \
<br>nameGenerator-&gt;SetStartIndex( first );<br>nameGenerator-&gt;SetEndIndex( last \
);<br>nameGenerator-&gt;SetIncrementIndex( 1 );<br>std::vector&lt;std::string&gt; \
names = nameGenerator-&gt;GetFileNames();<br><br>typedef \
itk::ImageFileReader&lt;ImageType&gt; ReaderType;<br>   \
std::vector&lt;std::string&gt;::iterator nit;<br>   for (nit = names.begin();<br>     \
nit != names.end();<br>           nit++)<br>      {<br></div><div>      \
ReaderType::Pointer reader = ReaderType::New();<br></div><div>       \
reader-&gt;SetFileName((*nit).c_str());<br></div><div>       reader-&gt;Update();<br> \
////////////<br></div><div>       // Do your computation<br></div><div>       \
////////<br>      }<br>  <br><br></div><div>Hope this \
helps,<br></div><div>Francois<br></div><div><br>[1] <a \
href="https://itk.org/Doxygen/html/classitk_1_1ImageSeriesReader.html">https://itk.org/Doxygen/html/classitk_1_1ImageSeriesReader.html</a><br></div></div></div><div \
class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 24, 2017 at 7:46 PM, \
Matias <span dir="ltr">&lt;<a href="mailto:matimontg@gmail.com" \
target="_blank">matimontg@gmail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">Hi,<br> <br>
I need to read a directory which contains X number of Dicom images. I have<br>
no troubles doing this by passing a parameter with the name of each file to<br>
ITK but I&#39;d like to read one by one and do the translation in a For. Sounds<br>
simple but I could not find an example where you read a directory, process<br>
images one by one on a For and then write the resultant image (within the<br>
same For) to an output directory..<br>
<br>
Does anyone know where I can find an example (of any kind) for reading a<br>
directory and doing some processing (any type) in a For?<br>
<br>
Thank you!<br>
<br>
<br>
<br>
--<br>
View this message in context: <a \
href="http://itk-users.7.n7.nabble.com/Translation-on-each-Dicom-on-a-Directory-tp38034.html" \
rel="noreferrer" target="_blank">http://itk-users.7.n7.nabble.<wbr>com/Translation-on-each-Dicom-<wbr>on-a-Directory-tp38034.html</a><br>
 Sent from the ITK - Users mailing list archive at Nabble.com.<br>
______________________________<wbr>_______<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" \
target="_blank">www.kitware.com</a><br> <br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" \
target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br> <br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" \
target="_blank">http://www.kitware.com/<wbr>products/protraining.php</a><br> <br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" \
target="_blank">http://www.itk.org/Wiki/ITK_<wbr>FAQ</a><br> <br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" \
target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/insight-users</a><br> \
</blockquote></div><br></div>



_____________________________________
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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic