From: tbaudier Date: Thu, 28 Feb 2019 13:05:14 +0000 (+0100) Subject: Add instanceNumber sorting for clitkDicom2Image X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=afd2671211668e6106886aa59c7bb13a82c48a94;p=clitk.git Add instanceNumber sorting for clitkDicom2Image Sometimes (eg: with MR from HEH), the basic algorithm is not sufficient to sort dicom slices It is the case when multiples sequences are in the same image, the z position is the same for a same slice in all sequences, it creates conflict In such a case, we can sort slices according instanceNumber --- diff --git a/tools/clitkDicom2Image.cxx b/tools/clitkDicom2Image.cxx index 38e8aa3..e705f85 100644 --- a/tools/clitkDicom2Image.cxx +++ b/tools/clitkDicom2Image.cxx @@ -74,6 +74,7 @@ int main(int argc, char * argv[]) 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 > instanceNumber; std::map< std::string, std::vector > seriesFiles; #if GDCM_MAJOR_VERSION >= 2 if (args_info.verbose_flag) @@ -115,6 +116,10 @@ int main(int argc, char * argv[]) 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) @@ -154,6 +159,7 @@ int main(int argc, char * argv[]) while ( sn != series_UIDs.end() ) { std::vector locs = sliceLocations[*sn]; std::vector origin = theorigin[*sn]; + std::vector instanceNumberSerie = instanceNumber[*sn]; std::vector files = seriesFiles[*sn]; std::vector sliceIndex(files.size()); //clitk::GetSortedIndex(locs, sliceIndex); @@ -223,8 +229,22 @@ int main(int argc, char * argv[]) // Create ordered vector of filenames std::vector sorted_files; sorted_files.resize(sliceIndex.size()); - for(unsigned int i=0; i::iterator maxInstanceNumber = std::max_element(instanceNumberSerie.begin(), instanceNumberSerie.end()); + std::vector instanceNumberTemp(*maxInstanceNumber, ""); + for(unsigned int i=0; i