+ if (args_info.verbose_flag)
+ std::cout << "Reading <" << input_files[i] << std::endl;
+#if GDCM_MAJOR_VERSION >= 2
+ gdcm::Reader hreader;
+ hreader.SetFileName(input_files[i].c_str());
+ hreader.Read();
+ gdcm::DataSet& ds = hreader.GetFile().GetDataSet();
+
+ gdcm::Attribute<0x20,0x000e> series_UID_att;
+ series_UID_att.SetFromDataSet(ds);
+ series_UID = series_UID_att.GetValue().c_str();
+
+ series_UIDs.insert(series_UID);
+ theorigin[series_UID] = gdcm::ImageHelper::GetOriginValue(hreader.GetFile());
+ theorientation[series_UID] = gdcm::ImageHelper::GetDirectionCosinesValue(hreader.GetFile());
+ if (args_info.patientSystem_flag) {
+ double n1 = theorientation[series_UID][1]*theorientation[series_UID][5]-
+ theorientation[series_UID][2]*theorientation[series_UID][4];
+ double n2 = theorientation[series_UID][3]*theorientation[series_UID][2]-
+ theorientation[series_UID][5]*theorientation[series_UID][0];
+ double n3 = theorientation[series_UID][0]*theorientation[series_UID][4]-
+ theorientation[series_UID][1]*theorientation[series_UID][3];
+ double sloc = theorigin[series_UID][0]*n1+
+ theorigin[series_UID][1]*n2+
+ theorigin[series_UID][2]*n3;
+ sliceLocations[series_UID].push_back(sloc);
+ } else
+ sliceLocations[series_UID].push_back(theorigin[series_UID][2]);
+ seriesFiles[series_UID].push_back(input_files[i]);
+
+ gdcm::Attribute<0x20,0x0013> instanceNumber_att;
+ instanceNumber_att.SetFromDataSet(ds);
+ instanceNumber[series_UID].push_back(instanceNumber_att.GetValue());
+
+ gdcm::Attribute<0x28, 0x100> pixel_size;
+ pixel_size.SetFromDataSet(ds);
+ /* if (pixel_size.GetValue() != 16)
+ {
+ std::cerr << "Pixel type not 2 bytes ! " << std::endl;
+ std::cerr << "In file " << input_files[i] << std::endl;
+ exit(0);
+ }
+ */
+#else
+ gdcm::File *header = new gdcm::File();
+ header->SetFileName(input_files[i]);
+ header->SetMaxSizeLoadEntry(16384); // required ?
+ header->Load();
+
+ series_UID = header->GetEntryValue(0x20,0x000e).c_str();
+
+ series_UIDs.insert(series_UID);
+ theorigin[series_UID].resize(3);
+ theorigin[series_UID][0] = header->GetXOrigin();
+ theorigin[series_UID][1] = header->GetYOrigin();
+ theorigin[series_UID][2] = header->GetZOrigin();
+ sliceLocations[series_UID].push_back(theorigin[series_UID][2]);
+ seriesFiles[series_UID].push_back(input_files[i]);
+ /*if (header->GetPixelSize() != 2) {
+ std::cerr << "Pixel type 2 bytes ! " << std::endl;
+ std::cerr << "In file " << input_files[i] << std::endl;
+ exit(0);
+ }
+ */
+#endif