]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
authorDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Thu, 18 Jul 2013 08:52:25 +0000 (10:52 +0200)
committerDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Thu, 18 Jul 2013 08:52:25 +0000 (10:52 +0200)
13 files changed:
README.md [new file with mode: 0644]
cluster_tools/gate_make_release.sh
common/vvImageWriter.txx
segmentation/clitkExtractLung.ggo
segmentation/clitkExtractLungFilter.h
segmentation/clitkExtractLungFilter.txx
segmentation/clitkExtractLungGenericFilter.txx
tools/CMakeLists.txt
tools/clitkAffineTransformGenericFilter.h
tools/clitkAffineTransformGenericFilter.txx
tools/clitkDicom2Image.cxx
tools/clitkDicomInfo.cxx
tools/clitkDicomInfo.ggo

diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..8f03a23
--- /dev/null
+++ b/README.md
@@ -0,0 +1,4 @@
+
+
+VV, a 4D image viewer, see : http://vv.creatis.insa-lyon.fr
+
index d50b2fec6393f745cda272f84459ec944f0e508e..363d583a435b118d214a354b3cf1f30c90ce24d2 100755 (executable)
@@ -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
 
 
index 0705197fd49b4f4d1394eb864c2175e2681464f2..81e45ee03b91344b0f60f7829b1aa0c2ac5997bd 100644 (file)
@@ -38,6 +38,8 @@ void vvImageWriter::UpdateWithDim(std::string OutputPixelType)
     UpdateWithDimAndOutputPixelType<unsigned char,VImageDimension>();
   } else if (OutputPixelType == "int") {
     UpdateWithDimAndOutputPixelType<int,VImageDimension>();
+  } else if (OutputPixelType == "unsigned_int") {
+    UpdateWithDimAndOutputPixelType<unsigned int,VImageDimension>();
   } else if (OutputPixelType == "double") {
     UpdateWithDimAndOutputPixelType<double,VImageDimension>();
   } else if (OutputPixelType == "float") {
index 44b99a201f468840b8a1e9c12c5154562f098699..f31f71812fa60c3bb4eca17f348c93b9f18cc9c3 100644 (file)
@@ -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
index 6f31cee1626a334d53f8042684bf8bbdb62a96d6..6c50b1c2d96c85e3c9b8485d970d9ad6e0a261b3 100644 (file)
@@ -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<InternalIndexType> & GetSeeds() { return  m_Seeds; }
 
     itkSetMacro(TracheaVolumeMustBeCheckedFlag, bool);
@@ -252,6 +253,7 @@ namespace clitk {
     InputImagePixelType m_ThresholdStepSizeForTrachea;
     double m_MultiplierForTrachea;
     std::vector<InternalIndexType> m_Seeds;
+    std::vector<InputImagePointType> m_SeedsInMM;
     int m_NumberOfSlicesToSkipBeforeSearchingSeed;
     bool m_TracheaVolumeMustBeCheckedFlag;
     bool m_VerboseRegionGrowingFlag;
index a0acdd5ad2ab48aa3669d58f8d9d22171b74d329..b76001f0491397c36648ddb86653c120ddcfb49c 100644 (file)
@@ -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 <class ImageType>
 void 
 clitk::ExtractLungFilter<ImageType>::
-AddSeed(InternalIndexType s) 
+//AddSeed(InternalIndexType s) 
+AddSeed(InputImagePointType s) 
+{ 
+  m_SeedsInMM.push_back(s);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template <class ImageType>
+void 
+clitk::ExtractLungFilter<ImageType>::
+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<MaskImageType, MaskImageType> 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; i<m_Seeds.size();i++) {
     f->AddSeed(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; i<m_SeedsInMM.size(); i++) {
+      InputImageIndexType index;
+      working_input->TransformPhysicalPointToIndex(m_SeedsInMM[i], index);
+      m_Seeds.push_back(index);
+    }
+  }
+
   bool has_seed;
   bool stop = false;
   double volume = 0.0;
index b9a94d86aeef3b3b273ff9176786eb5ba214bc50..01455c84c3ba65d77ecb811da8e8a8afa442e029 100644 (file)
@@ -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);
index 1db0dcce834968e82f91fdfe4bb380eb1e106669..77f12f9f863e301e089cc28c49aab05a20276fe8 100644 (file)
@@ -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)
index 6cd2a91f17127ac6c3e3195440a319046100324c..39506326f572a2bb614da44524c64547879eda41 100644 (file)
@@ -87,6 +87,11 @@ namespace clitk
     //----------------------------------------  
     void Update();
 
+    template<unsigned int Dimension, class PixelType>
+      static
+      typename itk::Matrix<double, Dimension+1, Dimension+1>
+      createMatrixFromElastixFile(std::vector<std::string> & filename, bool verbose=true);
+
   protected:
 
     //----------------------------------------  
@@ -103,13 +108,9 @@ namespace clitk
     template <unsigned int Dimension, class PixelType>  void UpdateWithDimAndPixelType();
     template <unsigned int Dimension, class PixelType>  void UpdateWithDimAndVectorType();
 
-    template<unsigned int Dimension, class PixelType>
-      typename itk::Matrix<double, Dimension+1, Dimension+1>
-      createMatrixFromElastixFile(std::vector<std::string> & filename);
-
-    bool GetElastixValueFromTag(std::ifstream & is, std::string tag, std::string & value); 
-    void GetValuesFromValue(const std::string & s, 
-                            std::vector<std::string> & values);
+    static bool GetElastixValueFromTag(std::ifstream & is, std::string tag, std::string & value); 
+    static void GetValuesFromValue(const std::string & s, 
+                                   std::vector<std::string> & values);
 
     //----------------------------------------  
     // Data members
index d3cd19e265a84b411ffd27a0791672502ca1d0d2..03cf862e2ee261548d6707761648821823b9e1fb 100644 (file)
@@ -183,7 +183,7 @@ namespace clitk
           if (m_ArgsInfo.elastix_given) {
             std::vector<std::string> s;
             for(uint i=0; i<m_ArgsInfo.elastix_given; i++) s.push_back(m_ArgsInfo.elastix_arg[i]);
-            matrix = createMatrixFromElastixFile<Dimension,PixelType>(s);
+            matrix = createMatrixFromElastixFile<Dimension,PixelType>(s, m_Verbose);
           }
           else 
             matrix.SetIdentity();
@@ -497,7 +497,7 @@ namespace clitk
   template<class args_info_type>
   template<unsigned int Dimension, class PixelType>
   typename itk::Matrix<double, Dimension+1, Dimension+1>
-                                                           AffineTransformGenericFilter<args_info_type>::createMatrixFromElastixFile(std::vector<std::string> & filename)
+                                                           AffineTransformGenericFilter<args_info_type>::createMatrixFromElastixFile(std::vector<std::string> & filename, bool verbose)
   {
     if (Dimension != 3) {
       FATAL("Only 3D yet" << std::endl);
@@ -509,7 +509,7 @@ namespace clitk
     for(uint j=0; j<filename.size(); j++) {
       
       // Open file
-      if (m_Verbose) std::cout << "Read elastix parameters in " << filename[j] << std::endl;
+      if (verbose) std::cout << "Read elastix parameters in " << filename[j] << std::endl;
       std::ifstream is;
       clitk::openFileForReading(is, filename[j]);
       
@@ -553,7 +553,7 @@ namespace clitk
         p[i+6] = atof(results[i+3].c_str()); // Translation
       mat->SetParameters(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;
index c7b2e23f076420ecac828eba3bde2a5aa541dd0e..b25b001dea3a19c75edec04b1bcf790891c5cf6a 100644 (file)
@@ -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
   }
 
index fe2d869d8bbf2e756068ae0b488c30dc45641583..202afc762feab842659b4421915b6faf74a4e275 100644 (file)
 // 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<std::string> l;
+    for(unsigned int i=0; i<args_info.inputs_num; i++) {
+      gdcm::Reader reader;
+      reader.SetFileName(args_info.inputs[i]);
+      std::set<gdcm::Tag> 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<std::string, std::string> p = sf.ToStringPair(StudyInstanceUIDTag);
+        std::pair<std::string, std::string> 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<args_info.inputs_num; i++) {
+    if (args_info.filename_flag) std::cout << args_info.inputs[i] << std::endl;
 #if GDCM_MAJOR_VERSION == 2
     gdcm::Reader reader;
     reader.SetFileName(args_info.inputs[i]);
index 27786a47ff23be29fa932db58789fd4046eacab9..064fa29ca67ede1aaa9a450dd9e35fd6ce0fdb41 100644 (file)
@@ -3,3 +3,6 @@ package "clitk"
 version "read and print Dicom header"
 
 option "config"                 -      "Config file"            string         no
+option "studyID"        s      "Only display Study UID" flag           off
+option "uniq"           u      "Do not display if same study UID"      flag           off
+option "filename"       f      "Display filename"       flag           off