1
votes

When I read a dicom series with a series reader in itk,

I always find the origin=[0 0 0] and spacing=[1 1 1], the same for all different datasets.

* main function:-

    void main()
    {
        reader = READ_DCM(Input_DCM_Paths[0]);
        cout<<" Reading Done!!"<<endl;
        cout<< " Origin: " <<reader->GetOutput()->GetOrigin()<< endl;
        cout<< " Spacing: " <<reader->GetOutput()->GetSpacing()<< endl;
    }

* reader function:-

    SeriesReaderType::Pointer READ_DCM (std::string InputFolder)
    {
      SeriesReaderType::Pointer seriesReader = SeriesReaderType::New();
      seriesReader->SetImageIO(itk::GDCMImageIO::New());
      itk::GDCMSeriesFileNames::Pointer nameGenerator = itk::GDCMSeriesFileNames::New();
      nameGenerator->SetUseSeriesDetails(true);
      nameGenerator->SetDirectory(InputFolder);
      std::string seriesID = nameGenerator->GetSeriesUIDs().begin()->c_str();
      seriesReader->SetFileNames(nameGenerator->GetFileNames(seriesID));
      seriesReader->Update();
      return seriesReader;
    }

* 1st series output in itk:-

enter image description here

* 1st series output in matlab:-

enter image description here

What's worng with my 'series reader' code ?? I followed the "reading part" in this example.

2
you forgot to specify which DICOM Instance you are reading. The attribute Pixel Spacing may belong to an extended SOP Class UID.malat
sorry, I don't know about that? is it the dicom tag (0008,0016) = << SOP Class UID = '1.2.840.10008.5.1.4.1.1.7' >> ? or << (0008,0016) = SOP Instance UID = '1.2.276.0.28.3.2418833.1095761920.42.5040.2012041216272628700 ' >> ?Sonnenschein
Just use gdcminfo next time. You are dealing with a Secondary Capture Image Storage instance. This instance does not define Pixel Spacing attribute therefore it is correct to assume (1,1) for pixel spacing (same goes for IPP).malat

2 Answers

0
votes

I have the same problem, i use following similar codes to read dicom series, but the output of spacing between slices is sometimes correct BUT not always:

// 1) Read the input series

typedef itk::GDCMImageIO ImageIOType;
typedef itk::GDCMSeriesFileNames InputNamesGeneratorType;

ImageIOType::Pointer gdcmIO = ImageIOType::New();
InputNamesGeneratorType::Pointer inputNames=InputNamesGeneratorType::New();
inputNames->SetInputDirectory( dirPath );
inputNames->AddSeriesRestriction("0020|0013");

// then i select a serie identifier and pass it to the reader

typedef itk::ImageSeriesReader< CTImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New(); ;
reader->SetImageIO( gdcmIO );
reader->SetFileNames(  inputNames->GetFileNames(  seriesIdentifier.c_str() ));
reader->UpdateOutputInformation();

--->>> reader->GetOutput()->GetSpacing()[2] is not correct always!!!

0
votes

ITK/SimpleITK assume that when you provide a series of images the files are in the same order as the slices. For many collections this is not the case and you have to presort the files (more details for python here) based on the Slice Location tag (or .GetOrigin).