X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkWriteDicomSeriesGenericFilter.txx;h=6f09ba9ea4fb48aef5b3b673b49c955a0dbfac40;hb=cd04d8c797defe2fdaff3d1fa09928b22dd6edc4;hp=d49c51e567b9ac836ddd6cb817df51195b4dbf79;hpb=765020625fbc092d283e221e36c83e60a1844cb7;p=clitk.git diff --git a/tools/clitkWriteDicomSeriesGenericFilter.txx b/tools/clitkWriteDicomSeriesGenericFilter.txx index d49c51e..6f09ba9 100644 --- a/tools/clitkWriteDicomSeriesGenericFilter.txx +++ b/tools/clitkWriteDicomSeriesGenericFilter.txx @@ -82,10 +82,10 @@ WriteDicomSeriesGenericFilter::UpdateWithDim(std::string PixelTy if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl; UpdateWithDimAndPixelType(); } - // else if(PixelType == "unsigned_short"){ - // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl; - // UpdateWithDimAndPixelType(); - // } + else if(PixelType == "unsigned_short"){ + if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl; + UpdateWithDimAndPixelType(); + } else if (PixelType == "unsigned_char") { if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl; @@ -96,6 +96,10 @@ WriteDicomSeriesGenericFilter::UpdateWithDim(std::string PixelTy // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl; // UpdateWithDimAndPixelType(); // } + else if (PixelType == "double") { + if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and double..." << std::endl; + UpdateWithDimAndPixelType(); + } else { if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl; UpdateWithDimAndPixelType(); @@ -196,10 +200,15 @@ WriteDicomSeriesGenericFilter::UpdateWithDimAndPixelType() } } - filter->Update(); - input = filter->GetOutput(); + try { + filter->Update(); + input = filter->GetOutput(); + } catch( itk::ExceptionObject & excp ) { + std::cerr << "Error: Exception thrown while resampling!!" << std::endl; + std::cerr << excp << std::endl; + } } - + // In some cases, due to resampling approximation issues, // the number of slices in the MHD file may be different (smaller) // from the number of files in the template dicom directory. @@ -208,6 +217,9 @@ WriteDicomSeriesGenericFilter::UpdateWithDimAndPixelType() // in verbose mode const RegionType volumeRegion = input->GetLargestPossibleRegion(); const SizeType& volumeSize = volumeRegion.GetSize(); + if (m_Verbose) { + std::cout << volumeRegion << volumeSize << std::endl; + } if (Dimension == 3 && volumeSize[2] < numberOfFilenames) { if (m_Verbose) std::cout << "Warning: The number of files in " << m_ArgsInfo.inputDir_arg << " (" << filenames_in.size() << " files) is greater than the number of slices in MHD (" << volumeSize[2] << " slices). Using only " << volumeSize[2] << " files." << std::endl; @@ -222,20 +234,16 @@ WriteDicomSeriesGenericFilter::UpdateWithDimAndPixelType() const std::vector* dictionary = reader->GetMetaDataDictionaryArray(); // Get keys - unsigned int numberOfKeysGiven=0; - if(m_ArgsInfo.midP_flag && m_ArgsInfo.key_given) - std::cerr<<"Error: both keys and midP option are given"<( *((*dictionary)[fni]), entryId, value ); } + // Output directory and filenames itksys::SystemTools::MakeDirectory( m_ArgsInfo.outputDir_arg ); // create if it doesn't exist