From: David Sarrut Date: Thu, 18 Jul 2013 08:52:25 +0000 (+0200) Subject: Merge branch 'master' of git.creatis.insa-lyon.fr:clitk X-Git-Tag: v1.4.0~169 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=3f3fe9260222ca3ec2a9a22b9f81009506792e38;hp=b9fe7c71fdc55235d879e019025ae3528440d9aa;p=clitk.git Merge branch 'master' of git.creatis.insa-lyon.fr:clitk --- diff --git a/README.md b/README.md new file mode 100644 index 0000000..8f03a23 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ + + +VV, a 4D image viewer, see : http://vv.creatis.insa-lyon.fr + diff --git a/cluster_tools/gate_make_release.sh b/cluster_tools/gate_make_release.sh index d50b2fe..363d583 100755 --- a/cluster_tools/gate_make_release.sh +++ b/cluster_tools/gate_make_release.sh @@ -35,7 +35,7 @@ rm -fr $(basename ${G4RADIOACTIVEDATA}) rm -fr $(basename ${G4ABLADATA}) rm -fr $(basename ${G4LEDATA}) rm -fr $(basename ${G4REALSURFACEDATA}) -rm -fr test_libs fgate_shared_libs.tar.gz fgate_release.tar.gz +rm -fr test_libs gate_shared_libs.tar.gz gate_release.tar.gz echo "Copying libraries" function get_deps { @@ -63,7 +63,7 @@ rm -f test_libs/libc.so* echo "Zipping libraries" ( cd test_libs - tar -czvf ../fgate_shared_libs.tar.gz ** + tar -czvf ../gate_shared_libs.tar.gz ** ) || usage "can't create libraries tar" echo "Copying binary" @@ -80,8 +80,8 @@ cp -r "${G4NEUTRONXSDATA}" . cp -r "${G4PIIDATA}" . echo "Making release" -tar -czvf fgate_release.tar.gz \ - ${GATENAME} fgate_shared_libs.tar.gz \ +tar -czvf gate_release.tar.gz \ + ${GATENAME} gate_shared_libs.tar.gz \ $(basename ${G4NEUTRONHPDATA}) \ $(basename ${G4LEVELGAMMADATA}) \ $(basename ${G4RADIOACTIVEDATA}) \ @@ -92,6 +92,6 @@ tar -czvf fgate_release.tar.gz \ $(basename ${G4PIIDATA}) \ || usage "can't create release zip" -chmod -w fgate_release.tar.gz +chmod -w gate_release.tar.gz diff --git a/common/vvImageWriter.txx b/common/vvImageWriter.txx index 0705197..81e45ee 100644 --- a/common/vvImageWriter.txx +++ b/common/vvImageWriter.txx @@ -38,6 +38,8 @@ void vvImageWriter::UpdateWithDim(std::string OutputPixelType) UpdateWithDimAndOutputPixelType(); } else if (OutputPixelType == "int") { UpdateWithDimAndOutputPixelType(); + } else if (OutputPixelType == "unsigned_int") { + UpdateWithDimAndOutputPixelType(); } else if (OutputPixelType == "double") { UpdateWithDimAndOutputPixelType(); } else if (OutputPixelType == "float") { diff --git a/segmentation/clitkExtractLung.ggo b/segmentation/clitkExtractLung.ggo index 44b99a2..f31f718 100644 --- a/segmentation/clitkExtractLung.ggo +++ b/segmentation/clitkExtractLung.ggo @@ -36,7 +36,7 @@ option "skipslices" - "0: Number of slices to skip before sear option "upperThresholdForTrachea" - "0: Initial upper threshold for trachea" double no default="-900" option "multiplierForTrachea" - "0: Multiplier for the region growing" double no default="5" option "thresholdStepSizeForTrachea" - "0: Threshold step size" int no default="64" -option "seed" - "0,1: Index of the trachea seed point (in pixel, not in mm)" int no multiple +option "seed" - "0,1: Index of the trachea seed point (in mm NOT IN PIXELS)" float no multiple option "doNotCheckTracheaVolume" - "0,1: If set, do not check the trachea volume" flag off option "verboseRG" - "0,1: Verbose RegionGrowing" flag off option "maxElongation" - "1: Maximum allowed elongation of candidate regions for the trachea" float no default="0.5" @@ -63,7 +63,7 @@ option "opencloseRadius" - "OpenClose radius" int no section "Step 6 : fill holes" option "doNotFillHoles" - "Do not fill holes if set" flag on -option "dir" d "Directions (axes) to perform filling (defaults to 2,1,0)" int multiple no +#option "dir" d "Directions (axes) to perform filling (defaults to 2,1,0)" int multiple no section "Step 7 : lung separation (labelling)" option "doNotSeparateLungs" - "Do not separate lungs if set" flag off diff --git a/segmentation/clitkExtractLungFilter.h b/segmentation/clitkExtractLungFilter.h index 6f31cee..6c50b1c 100644 --- a/segmentation/clitkExtractLungFilter.h +++ b/segmentation/clitkExtractLungFilter.h @@ -164,7 +164,8 @@ namespace clitk { itkSetMacro(SeedPreProcessingThreshold, int); itkGetConstMacro(SeedPreProcessingThreshold, int); - void AddSeed(InternalIndexType s); + void AddSeedInPixels(InternalIndexType s); + void AddSeed(InputImagePointType s); std::vector & GetSeeds() { return m_Seeds; } itkSetMacro(TracheaVolumeMustBeCheckedFlag, bool); @@ -252,6 +253,7 @@ namespace clitk { InputImagePixelType m_ThresholdStepSizeForTrachea; double m_MultiplierForTrachea; std::vector m_Seeds; + std::vector m_SeedsInMM; int m_NumberOfSlicesToSkipBeforeSearchingSeed; bool m_TracheaVolumeMustBeCheckedFlag; bool m_VerboseRegionGrowingFlag; diff --git a/segmentation/clitkExtractLungFilter.txx b/segmentation/clitkExtractLungFilter.txx index a0acdd5..b76001f 100644 --- a/segmentation/clitkExtractLungFilter.txx +++ b/segmentation/clitkExtractLungFilter.txx @@ -90,8 +90,7 @@ ExtractLungFilter(): TracheaVolumeMustBeCheckedFlagOn(); SetNumSlices(50); SetMaxElongation(0.5); - SetSeedPreProcessingThreshold(-400); - + SetSeedPreProcessingThreshold(-400); // Step 3 default values SetNumberOfHistogramBins(500); @@ -135,7 +134,19 @@ SetInput(const ImageType * image) template void clitk::ExtractLungFilter:: -AddSeed(InternalIndexType s) +//AddSeed(InternalIndexType s) +AddSeed(InputImagePointType s) +{ + m_SeedsInMM.push_back(s); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +template +void +clitk::ExtractLungFilter:: +AddSeedInPixels(InternalIndexType s) { m_Seeds.push_back(s); } @@ -461,7 +472,6 @@ GenerateOutputInformation() // smalest one (sometimes appends with the stomach if (initialNumberOfLabels >1) { if (GetRemoveSmallLabelBeforeSeparationFlag()) { - DD(GetRemoveSmallLabelBeforeSeparationFlag()); typedef itk::RelabelComponentImageFilter RelabelFilterType; typename RelabelFilterType::Pointer relabelFilter = RelabelFilterType::New(); relabelFilter->SetInput(working_mask); @@ -577,7 +587,7 @@ SearchForTracheaSeed(int skip) it.GoToBegin(); while (!it.IsAtEnd()) { if(it.Get() < GetUpperThresholdForTrachea() ) { - AddSeed(it.GetIndex()); + AddSeedInPixels(it.GetIndex()); // DD(it.GetIndex()); } ++it; @@ -853,7 +863,7 @@ TracheaRegionGrowing() f->SetVerbose(GetVerboseRegionGrowingFlag()); for(unsigned int i=0; iAddSeed(m_Seeds[i]); - // DD(m_Seeds[i]); + //DD(m_Seeds[i]); } f->Update(); PrintMemory(GetVerboseMemoryFlag(), "After RG update"); @@ -907,6 +917,15 @@ SearchForTrachea() // compute trachea volume // if volume not plausible -> skip more slices and restart + // If initial seed, convert from mm to pixels + if (m_SeedsInMM.size() > 0) { + for(unsigned int i=0; iTransformPhysicalPointToIndex(m_SeedsInMM[i], index); + m_Seeds.push_back(index); + } + } + bool has_seed; bool stop = false; double volume = 0.0; diff --git a/segmentation/clitkExtractLungGenericFilter.txx b/segmentation/clitkExtractLungGenericFilter.txx index b9a94d8..01455c8 100644 --- a/segmentation/clitkExtractLungGenericFilter.txx +++ b/segmentation/clitkExtractLungGenericFilter.txx @@ -94,10 +94,10 @@ SetOptionsFromArgsInfoToFilter(FilterType * f) f->SetMaxElongation(mArgsInfo.maxElongation_arg); f->SetSeedPreProcessingThreshold(mArgsInfo.seedPreProcessingThreshold_arg); - typename FilterType::InputImageIndexType s; + typename FilterType::InputImagePointType s; if (mArgsInfo.seed_given) { ConvertOptionMacro(mArgsInfo.seed, s, 3, false); - f->AddSeed(s); + f->AddSeed(s); } f->SetMinimalComponentSize(mArgsInfo.minSize_arg); diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 1db0dcc..77f12f9 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -108,6 +108,12 @@ IF (CLITK_BUILD_TOOLS) TARGET_LINK_LIBRARIES(clitkAffineTransform clitkCommon ) SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkAffineTransform) + WRAP_GGO(clitkElastixTransformToMatrix_GGO_C clitkElastixTransformToMatrix.ggo) + ADD_EXECUTABLE(clitkElastixTransformToMatrix clitkElastixTransformToMatrix.cxx ${clitkElastixTransformToMatrix_GGO_C}) + TARGET_LINK_LIBRARIES(clitkElastixTransformToMatrix clitkCommon ) + SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkElastixTransformToMatrix) + + WRAP_GGO(clitkSetBackground_GGO_C clitkSetBackground.ggo) ADD_EXECUTABLE(clitkSetBackground clitkSetBackground.cxx clitkSetBackgroundGenericFilter.cxx ${clitkSetBackground_GGO_C}) TARGET_LINK_LIBRARIES(clitkSetBackground clitkCommon) diff --git a/tools/clitkAffineTransformGenericFilter.h b/tools/clitkAffineTransformGenericFilter.h index 6cd2a91..3950632 100644 --- a/tools/clitkAffineTransformGenericFilter.h +++ b/tools/clitkAffineTransformGenericFilter.h @@ -87,6 +87,11 @@ namespace clitk //---------------------------------------- void Update(); + template + static + typename itk::Matrix + createMatrixFromElastixFile(std::vector & filename, bool verbose=true); + protected: //---------------------------------------- @@ -103,13 +108,9 @@ namespace clitk template void UpdateWithDimAndPixelType(); template void UpdateWithDimAndVectorType(); - template - typename itk::Matrix - createMatrixFromElastixFile(std::vector & filename); - - bool GetElastixValueFromTag(std::ifstream & is, std::string tag, std::string & value); - void GetValuesFromValue(const std::string & s, - std::vector & values); + static bool GetElastixValueFromTag(std::ifstream & is, std::string tag, std::string & value); + static void GetValuesFromValue(const std::string & s, + std::vector & values); //---------------------------------------- // Data members diff --git a/tools/clitkAffineTransformGenericFilter.txx b/tools/clitkAffineTransformGenericFilter.txx index d3cd19e..03cf862 100644 --- a/tools/clitkAffineTransformGenericFilter.txx +++ b/tools/clitkAffineTransformGenericFilter.txx @@ -183,7 +183,7 @@ namespace clitk if (m_ArgsInfo.elastix_given) { std::vector s; for(uint i=0; i(s); + matrix = createMatrixFromElastixFile(s, m_Verbose); } else matrix.SetIdentity(); @@ -497,7 +497,7 @@ namespace clitk template template typename itk::Matrix - AffineTransformGenericFilter::createMatrixFromElastixFile(std::vector & filename) + AffineTransformGenericFilter::createMatrixFromElastixFile(std::vector & filename, bool verbose) { if (Dimension != 3) { FATAL("Only 3D yet" << std::endl); @@ -509,7 +509,7 @@ namespace clitk for(uint j=0; jSetParameters(p); - if (m_Verbose) { + if (verbose) { std::cout << "Rotation (deg) : " << rad2deg(p[0]) << " " << rad2deg(p[1]) << " " << rad2deg(p[2]) << std::endl; std::cout << "Center of rot (phy) : " << p[3] << " " << p[4] << " " << p[5] << std::endl; std::cout << "Translation (phy) : " << p[6] << " " << p[7] << " " << p[8] << std::endl; @@ -562,7 +562,7 @@ namespace clitk // Compose with previous if needed if (j!=0) { mat->Compose(previous); - if (m_Verbose) { + if (verbose) { std::cout << "Composed rotation (deg) : " << rad2deg(mat->GetAngleX()) << " " << rad2deg(mat->GetAngleY()) << " " << rad2deg(mat->GetAngleZ()) << std::endl; std::cout << "Composed center of rot (phy) : " << mat->GetCenter() << std::endl; std::cout << "Compsoed translation (phy) : " << mat->GetTranslation() << std::endl; diff --git a/tools/clitkDicom2Image.cxx b/tools/clitkDicom2Image.cxx index c7b2e23..b25b001 100644 --- a/tools/clitkDicom2Image.cxx +++ b/tools/clitkDicom2Image.cxx @@ -82,12 +82,13 @@ int main(int argc, char * argv[]) gdcm::Attribute<0x28, 0x100> pixel_size; pixel_size.SetFromDataSet(ds); - if (pixel_size.GetValue() != 16) - { - std::cerr << "Pixel type 2 bytes ! " << std::endl; - std::cerr << "In file " << input_files[i] << std::endl; - exit(0); - } + /* if (pixel_size.GetValue() != 16) + { + std::cerr << "Pixel type not 2 bytes ! " << std::endl; + std::cerr << "In file " << input_files[i] << std::endl; + exit(0); + } + */ #else if (args_info.verbose_flag) std::cout << "Not using GDCM-2.x" << std::endl; @@ -107,11 +108,12 @@ int main(int argc, char * argv[]) theorigin[series_number][2] = header->GetZOrigin(); sliceLocations[series_number].push_back(theorigin[series_number][2]); seriesFiles[series_number].push_back(input_files[i]); - if (header->GetPixelSize() != 2) { + /*if (header->GetPixelSize() != 2) { std::cerr << "Pixel type 2 bytes ! " << std::endl; std::cerr << "In file " << input_files[i] << std::endl; exit(0); } + */ #endif } diff --git a/tools/clitkDicomInfo.cxx b/tools/clitkDicomInfo.cxx index fe2d869..202afc7 100644 --- a/tools/clitkDicomInfo.cxx +++ b/tools/clitkDicomInfo.cxx @@ -29,8 +29,10 @@ // itk (gdcm) include #include "gdcmFile.h" #if GDCM_MAJOR_VERSION == 2 - #include "gdcmReader.h" - #include "gdcmPrinter.h" +#include "gdcmReader.h" +#include "gdcmPrinter.h" +#include "gdcmDict.h" +#include "gdcmStringFilter.h" #endif //-------------------------------------------------------------------- @@ -43,8 +45,46 @@ int main(int argc, char * argv[]) // check arg if (args_info.inputs_num == 0) return 0; + // Study ID + #if GDCM_MAJOR_VERSION == 2 + if (args_info.studyID_flag) { + std::set l; + for(unsigned int i=0; i tags; + gdcm::Tag StudyInstanceUIDTag(0x0020, 0x000d); + gdcm::Tag SeriesDateTag(0x0008, 0x0021); + tags.insert(StudyInstanceUIDTag); + tags.insert(SeriesDateTag); + if (reader.ReadSelectedTags(tags)) { + gdcm::StringFilter sf; + sf.SetFile(reader.GetFile()); + std::pair p = sf.ToStringPair(StudyInstanceUIDTag); + std::pair d = sf.ToStringPair(SeriesDateTag); + if (args_info.uniq_flag) { + if (l.insert(p.second).second == true) { + if (args_info.filename_flag) + std::cout << args_info.inputs[i] << " " << p.second << " " << d.second << std::endl; + else + std::cout << p.second << std::endl; + } + } + else { + if (args_info.filename_flag) + std::cout << args_info.inputs[i] << " " << p.second << " " << d.second << std::endl; + else + std::cout << p.second << std::endl; + } + } // tag not found + } + } +#endif + // Loop files + if (!args_info.studyID_flag) for(unsigned int i=0; i