X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkDicom2Image.cxx;h=399168c958cfa0f916b8769879f62a50481d86e7;hb=f48c960aef6e0a5a4edea516b062197db009e25f;hp=ffd08e8a9b9941c49585b5ec5cf05a7028cec97d;hpb=38df4d1b1ea8396c225e35131eb212e02377ea45;p=clitk.git diff --git a/tools/clitkDicom2Image.cxx b/tools/clitkDicom2Image.cxx index ffd08e8..399168c 100644 --- a/tools/clitkDicom2Image.cxx +++ b/tools/clitkDicom2Image.cxx @@ -26,7 +26,7 @@ #include #include #include -#if GDCM_MAJOR_VERSION == 2 +#if GDCM_MAJOR_VERSION >= 2 #include #include #include @@ -64,7 +64,7 @@ int main(int argc, char * argv[]) std::map< int, std::vector > theorientation; std::map< int, std::vector > sliceLocations; std::map< int, std::vector > seriesFiles; -#if GDCM_MAJOR_VERSION == 2 +#if GDCM_MAJOR_VERSION >= 2 if (args_info.verbose_flag) std::cout << "Using GDCM-2.x" << std::endl; #else @@ -76,7 +76,7 @@ int main(int argc, char * argv[]) for(unsigned int i=0; i= 2 gdcm::Reader hreader; hreader.SetFileName(input_files[i].c_str()); hreader.Read(); @@ -91,16 +91,19 @@ int main(int argc, char * argv[]) series_numbers.insert(series_number); theorigin[series_number] = gdcm::ImageHelper::GetOriginValue(hreader.GetFile()); theorientation[series_number] = gdcm::ImageHelper::GetDirectionCosinesValue(hreader.GetFile()); - 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); + if (args_info.extract_series_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); + } else + sliceLocations[series_number].push_back(theorigin[series_number][2]); seriesFiles[series_number].push_back(input_files[i]); gdcm::Attribute<0x28, 0x100> pixel_size; @@ -238,7 +241,7 @@ int main(int argc, char * argv[]) } vvImageWriter::Pointer writer = vvImageWriter::New(); writer->SetInput(image); - if (!image->GetTransform().empty()) + if (args_info.extract_series_flag && !image->GetTransform().empty()) writer->SetSaveTransform(true); writer->SetOutputFileName(outfile); writer->Update();