# Get original SeriesInstanceUID before AddSeriesRestriction();

**URL:** https://discourse.itk.org/t/get-original-seriesinstanceuid-before-addseriesrestriction/1698
**Category:** Engineering
**Tags:** dicom
**Created:** [March 23, 2019, 9:57pm UTC](https://discourse.itk.org/t/get-original-seriesinstanceuid-before-addseriesrestriction/1698 "2019-03-23T21:57:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jonasteuwen](https://discourse.itk.org/user_avatar/discourse.itk.org/jonasteuwen/32/1335_2.png) [@jonasteuwen](https://discourse.itk.org/u/jonasteuwen)
#### Post date: [March 23, 2019, 9:57pm UTC](https://discourse.itk.org/t/get-original-seriesinstanceuid-before-addseriesrestriction/1698/1 "2019-03-23T21:57:37Z")

</div>

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->AddSeriesRestriction("0020|0100");
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?

---

<div class="post-metadata">

### Author: ![jonasteuwen](https://discourse.itk.org/user_avatar/discourse.itk.org/jonasteuwen/32/1335_2.png) [@jonasteuwen](https://discourse.itk.org/u/jonasteuwen)
#### Post date: [March 24, 2019, 2:43pm UTC](https://discourse.itk.org/t/get-original-seriesinstanceuid-before-addseriesrestriction/1698/2 "2019-03-24T14:43:13Z")

</div>

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`

Use:

```
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();
reader->SetImageIO(dicomIO);
```
