From 133a3b14fe0d225aff4ea4edd53d61e7f3d063c2 Mon Sep 17 00:00:00 2001 From: tbaudier Date: Thu, 20 Dec 2018 13:08:55 +0100 Subject: [PATCH] Change dicom file sorting procedure in clitkDicom2Image In clitkDicom2Image, the sorting of files was based on the slice position but it's not correct when a transformation matrix is set. It's ok when you open a dicom serie with vv. So I used GDCMSeriesFileNames like with vv to sort filenames correctly --- tools/clitkDicom2Image.cxx | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tools/clitkDicom2Image.cxx b/tools/clitkDicom2Image.cxx index b3bcc90..e6e2396 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(true); + 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 ... @@ -149,7 +160,22 @@ int main(int argc, char * argv[]) std::vector origin = theorigin[*sn]; std::vector files = seriesFiles[*sn]; std::vector sliceIndex; - clitk::GetSortedIndex(locs, sliceIndex); + //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 << " => " -- 2.47.1