# GDCMSeriesFileNames SetRecursive

**URL:** <https://discourse.itk.org/t/gdcmseriesfilenames-setrecursive/1211>\
**Category:** Algorithms\
**Created:** [August 20, 2018, 2:36pm UTC](https://discourse.itk.org/t/gdcmseriesfilenames-setrecursive/1211 "2018-08-20T14:36:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Athius](https://discourse.itk.org/user_avatar/discourse.itk.org/athius/32/304_2.png) [@Athius](https://discourse.itk.org/u/Athius)\
**Post date:** [August 20, 2018, 2:36pm UTC](https://discourse.itk.org/t/gdcmseriesfilenames-setrecursive/1211/1 "2018-08-20T14:36:11Z")

</div>

Hello everyone,

I try to read all my dicoms recursively. For this I try to use itk::GDCMSeriesFileNames class (itk version 4.13.1).

itk::GDCMSeriesFileNames::Pointer nameGenerator = itk::GDCMSeriesFileNames::New();  
nameGenerator-\>SetDirectory(dirName);  
nameGenerator-\>SetRecursive(true);  
nameGenerator-\>Update();

Unfortunately, I have a warning message saying that no series were found.

Did I do something wrong?

Thank you.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [August 20, 2018, 3:31pm UTC](https://discourse.itk.org/t/gdcmseriesfilenames-setrecursive/1211/2 "2018-08-20T15:31:11Z")

</div>

Does it work without `SetRecursive` call? If that is not the issue, can you start with an [example](https://itk.org/ITKExamples/src/IO/GDCM/ReadDICOMSeriesAndWrite3DImage/Documentation.html) which is known to work and gradually modify it to suit your needs?

---

<div class="post-metadata">

**Author:** ![Athius](https://discourse.itk.org/user_avatar/discourse.itk.org/athius/32/304_2.png) [@Athius](https://discourse.itk.org/u/Athius)\
**Post date:** [August 20, 2018, 3:45pm UTC](https://discourse.itk.org/t/gdcmseriesfilenames-setrecursive/1211/3 "2018-08-20T15:45:38Z")

</div>

I forgot to mention: it’s working if I launch my software on a folder containing directly the disoms.

For example:

parentFolder/

childFolder/

dicomFile01

dicomFile02

If I launch my app with childFolder has the directory, the series is read (I have the series UID). If I launch my app with parentFolder, I expected to have the same result, but I have nothing (except the warning telling me that no series were found).

I did the test with and without SetRecursive call and the same results as above appear.

I use this example as starting point.

This is the simple code I use to test:

> #include \<iostream\>  
> #include \<string\>  
> #include \<vector\>  
> #include \<itkGDCMSeriesFileNames.h\>  
> int main(int argc, char const \*argv)  
> {  
> if (argc \< 2)  
> {  
> std::cout \<\< “Usage: " \<\< argv[0] \<\< " dicom\_path” \<\< std::endl;  
> return 0;  
> }  
> itk::GDCMSeriesFileNames::Pointer nameGenerator = itk::GDCMSeriesFileNames::New();  
> nameGenerator-\>SetRecursive(true);  
> nameGenerator-\>SetDirectory(argv[1]);  
> nameGenerator-\>Update();  
> std::vector\<std::string\> seriesUID = nameGenerator-\>GetSeriesUIDs();  
> for (auto & uid : seriesUID)  
> {  
> std::cout \<\< uid \<\< std::endl;  
> }  
> return 0;  
> }

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [August 20, 2018, 3:50pm UTC](https://discourse.itk.org/t/gdcmseriesfilenames-setrecursive/1211/4 "2018-08-20T15:50:49Z")

</div>

@mathieu.malaterre This sounds like either like a limitation or a bug in GDCM.

---

<div class="post-metadata">

**Author:** ![Athius](https://discourse.itk.org/user_avatar/discourse.itk.org/athius/32/304_2.png) [@Athius](https://discourse.itk.org/u/Athius)\
**Post date:** [August 20, 2018, 4:57pm UTC](https://discourse.itk.org/t/gdcmseriesfilenames-setrecursive/1211/5 "2018-08-20T16:57:31Z")

</div>

I found the solution we must call SetRecursive before the SetDirectory!

---

<div class="post-metadata">

**Author:** ![mathieu.malaterre](https://discourse.itk.org/user_avatar/discourse.itk.org/mathieu.malaterre/32/205_2.png) [@mathieu.malaterre](https://discourse.itk.org/u/mathieu.malaterre)\
**Post date:** [August 21, 2018, 5:48am UTC](https://discourse.itk.org/t/gdcmseriesfilenames-setrecursive/1211/6 "2018-08-21T05:48:25Z")

</div>

I agree this is a bug. I am not convinced this lie in GDCM codebase. I would have assumed this was in GDCMSeriesFileNames. Anyway feel free to create an issue and assigned it to me. Thanks for the report.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [August 22, 2018, 3:33pm UTC](https://discourse.itk.org/t/gdcmseriesfilenames-setrecursive/1211/7 "2018-08-22T15:33:41Z")

</div>

It is related to [GDCMSeriesFileNames::SetInputDirectory](https://github.com/InsightSoftwareConsortium/ITK/blob/188a16320790b559165c481a3867f4a6beef7315/Modules/IO/GDCM/src/itkGDCMSeriesFileNames.cxx#L73-L77). I have made a [patch](http://review.source.kitware.com/#/c/23656/) to improve the documentation. That is the easiest.
