X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkDicom2Image.cxx;h=38e8aa3d4889f51dd049e97bcf7caa7104431d94;hb=d55f025b18f68066a52b8f33c2dc6481e82c2580;hp=b3bcc902de0699f224e2047f9922f4f0f057bc29;hpb=e4970a5c24b53d6842e4f8f02d63b957f03bfbba;p=clitk.git diff --git a/tools/clitkDicom2Image.cxx b/tools/clitkDicom2Image.cxx index b3bcc90..38e8aa3 100644 --- a/tools/clitkDicom2Image.cxx +++ b/tools/clitkDicom2Image.cxx @@ -23,6 +23,8 @@ #include "clitkImageCommon.h" #include "vvImageReader.h" #include "vvImageWriter.h" +#include +#include #include #include #include @@ -55,6 +57,15 @@ int main(int argc, char * argv[]) } else for (unsigned int i=0; iSetUseSeriesDetails(false); + std::string folderName="."; + const size_t last_slash_idx = input_files[0].rfind('/'); + if (std::string::npos != last_slash_idx) + folderName = input_files[0].substr(0, last_slash_idx); + nameGenerator->SetInputDirectory(folderName); //=========================================== /// Get slices locations ... @@ -82,11 +93,9 @@ int main(int argc, char * argv[]) hreader.Read(); gdcm::DataSet& ds = hreader.GetFile().GetDataSet(); - if (args_info.extract_series_flag) { - gdcm::Attribute<0x20,0x000e> series_UID_att; - series_UID_att.SetFromDataSet(ds); - series_UID = series_UID_att.GetValue(); - } + 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()); @@ -121,9 +130,7 @@ int main(int argc, char * argv[]) header->SetMaxSizeLoadEntry(16384); // required ? header->Load(); - if (args_info.extract_series_flag) { - series_UID = header->GetEntryValue(0x20,0x000e).c_str(); - } + series_UID = header->GetEntryValue(0x20,0x000e).c_str(); series_UIDs.insert(series_UID); theorigin[series_UID].resize(3); @@ -148,8 +155,30 @@ int main(int argc, char * argv[]) std::vector locs = sliceLocations[*sn]; std::vector origin = theorigin[*sn]; std::vector files = seriesFiles[*sn]; - std::vector sliceIndex; - clitk::GetSortedIndex(locs, sliceIndex); + std::vector sliceIndex(files.size()); + //clitk::GetSortedIndex(locs, sliceIndex); + //Look for files into GDCMSeriesFileNames, because it sorts files correctly and take the order + const std::vector & temp = nameGenerator->GetFileNames(*sn); + for(unsigned int i=0; i " << sliceIndex[0] << " / " << 0 << " => "