+ 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<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();
+
+ if (args_info.extract_series_flag) {
+ 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
+ }
+
+ //===========================================
+ // Sort slices locations ...
+ std::set<std::string>::iterator sn = series_UIDs.begin();
+ while ( sn != series_UIDs.end() ) {
+ std::vector<double> locs = sliceLocations[*sn];
+ std::vector<double> origin = theorigin[*sn];
+ std::vector<std::string> files = seriesFiles[*sn];