GDCMSeriesFileNames SetRecursive


(Romain Leguay) #1

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.


(Dženan Zukić) #2

Does it work without SetRecursive call? If that is not the issue, can you start with an example which is known to work and gradually modify it to suit your needs?


(Romain Leguay) #3

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;
}


(Dženan Zukić) #4

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


(Romain Leguay) #5

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


(Mathieu Malaterre) #6

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.


(Dženan Zukić) #7

It is related to GDCMSeriesFileNames::SetInputDirectory. I have made a patch to improve the documentation. That is the easiest.