From: tbaudier Date: Thu, 20 Dec 2018 10:01:48 +0000 (+0100) Subject: Change serie number to serie UID X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e4970a5c24b53d6842e4f8f02d63b957f03bfbba;p=clitk.git Change serie number to serie UID In clitkDicom2Image, change serie number to serie UID. Serie UID is more restrictive and better to separate series Change number to string because series UID is a string Series UID is better to use itk::GDCMSeriesFileNames --- diff --git a/tools/clitkDicom2Image.cxx b/tools/clitkDicom2Image.cxx index 5c9889b..b3bcc90 100644 --- a/tools/clitkDicom2Image.cxx +++ b/tools/clitkDicom2Image.cxx @@ -58,12 +58,12 @@ int main(int argc, char * argv[]) //=========================================== /// Get slices locations ... - int series_number = -1; - std::set series_numbers; - std::map< int, std::vector > theorigin; - std::map< int, std::vector > theorientation; - std::map< int, std::vector > sliceLocations; - std::map< int, std::vector > seriesFiles; + std::string series_UID = ""; + std::set series_UIDs; + std::map< std::string, std::vector > theorigin; + std::map< std::string, std::vector > theorientation; + std::map< std::string, std::vector > sliceLocations; + std::map< std::string, std::vector > seriesFiles; #if GDCM_MAJOR_VERSION >= 2 if (args_info.verbose_flag) std::cout << "Using GDCM-2.x" << std::endl; @@ -83,28 +83,28 @@ int main(int argc, char * argv[]) gdcm::DataSet& ds = hreader.GetFile().GetDataSet(); if (args_info.extract_series_flag) { - gdcm::Attribute<0x20,0x11> series_number_att; - series_number_att.SetFromDataSet(ds); - series_number = series_number_att.GetValue(); + gdcm::Attribute<0x20,0x000e> series_UID_att; + series_UID_att.SetFromDataSet(ds); + series_UID = series_UID_att.GetValue(); } - series_numbers.insert(series_number); - theorigin[series_number] = gdcm::ImageHelper::GetOriginValue(hreader.GetFile()); - theorientation[series_number] = gdcm::ImageHelper::GetDirectionCosinesValue(hreader.GetFile()); + 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_number][1]*theorientation[series_number][5]- - theorientation[series_number][2]*theorientation[series_number][4]; - double n2 = theorientation[series_number][3]*theorientation[series_number][2]- - theorientation[series_number][5]*theorientation[series_number][0]; - double n3 = theorientation[series_number][0]*theorientation[series_number][4]- - theorientation[series_number][1]*theorientation[series_number][3]; - double sloc = theorigin[series_number][0]*n1+ - theorigin[series_number][1]*n2+ - theorigin[series_number][2]*n3; - sliceLocations[series_number].push_back(sloc); + 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_number].push_back(theorigin[series_number][2]); - seriesFiles[series_number].push_back(input_files[i]); + 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); @@ -122,16 +122,16 @@ int main(int argc, char * argv[]) header->Load(); if (args_info.extract_series_flag) { - series_number = atoi(header->GetEntryValue(0x20,0x11).c_str()); + series_UID = header->GetEntryValue(0x20,0x000e).c_str(); } - series_numbers.insert(series_number); - theorigin[series_number].resize(3); - theorigin[series_number][0] = header->GetXOrigin(); - theorigin[series_number][1] = header->GetYOrigin(); - theorigin[series_number][2] = header->GetZOrigin(); - sliceLocations[series_number].push_back(theorigin[series_number][2]); - seriesFiles[series_number].push_back(input_files[i]); + 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; @@ -143,8 +143,8 @@ int main(int argc, char * argv[]) //=========================================== // Sort slices locations ... - std::set::iterator sn = series_numbers.begin(); - while ( sn != series_numbers.end() ) { + std::set::iterator sn = series_UIDs.begin(); + while ( sn != series_UIDs.end() ) { std::vector locs = sliceLocations[*sn]; std::vector origin = theorigin[*sn]; std::vector files = seriesFiles[*sn]; @@ -229,7 +229,7 @@ int main(int argc, char * argv[]) } std::string outfile; - if (series_numbers.size() == 1) + if (series_UIDs.size() == 1) outfile = args_info.output_arg; else { std::ostringstream name;