Get original SeriesInstanceUID before AddSeriesRestriction();


(Jonas Teuwen) #1

I have a 4D dicom series in a folder (which could contain multiple of those) for which (0020,0100) TemporalPositionIdentifier contains the identifier of the time point. I want to convert this to a 4D (or a series of 3D images), so I read the data using

using NamesGeneratorType = itk::GDCMSeriesFileNames;
NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
nameGenerator->SetUseSeriesDetails( true );
// Splitting on TemporalPositionIdentifier, could also use TriggerTime
// (0020,0100) TemporalPositionIdentifier
nameGenerator->SetDirectory( argv[1] );

Then I get in nameGenerator->GetSeriesUIDs(); the SeriesUIDs for this series, which are basically the original SeriesInstanceUID + the number in the trigger time (Or some other index?). Now I wish to write these volumes to a filename of the format SeriesInstanceUID-<curr volume>-<num timepoints>.nrrd. In other words: how do I obtain the original SeriesInstanceUID without parsing through the directory again? Is the appended number the “TemporalPositionIdentifier” (or whatever tag I use?) so I can strip it of the current SeriesInstanceUID and would this behavior be robust?

(Jonas Teuwen) #2

Let me reply to my own question, in case someone might run into the same problem, and was due to my misunderstanding on how the GDCM ITK wrapper works.

The SeriesUID which is given by the NameGenerator has more numbers appended than the original SeriesInstanceUID


std::string FindDicomTag( const std::string & entryId, const itk::GDCMImageIO::Pointer dicomIO )
std::string tagValue;
bool found = dicomIO->GetValueFromTag(entryId, tagValue);
if ( !found )
    tagvalue = "Empty";
return tagValue;

Then you can get the information from the dicomIO object which you used in the reader anyway.

using ImageIOType = itk::GDCMImageIO;
ImageIOType::Pointer dicomIO = ImageIOType::New();