]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
authorBenoît Presles <benoit.presles@creatis.insa-lyon.fr>
Tue, 12 Nov 2013 09:30:52 +0000 (10:30 +0100)
committerBenoît Presles <benoit.presles@creatis.insa-lyon.fr>
Tue, 12 Nov 2013 09:30:52 +0000 (10:30 +0100)
cluster_tools/gate_merge_merges.sh [new file with mode: 0755]
cluster_tools/gate_power_merge.sh
tools/CMakeLists.txt
tools/clitkImageConvert.cxx
tools/clitkImageConvert.ggo
tools/clitkImageConvertGenericFilter.cxx
tools/clitkImageConvertGenericFilter.h
tools/clitkMatrixMultiply.cxx [new file with mode: 0644]
tools/clitkMatrixMultiply.ggo [new file with mode: 0644]

diff --git a/cluster_tools/gate_merge_merges.sh b/cluster_tools/gate_merge_merges.sh
new file mode 100755 (executable)
index 0000000..72fcbcc
--- /dev/null
@@ -0,0 +1,7 @@
+mkdir run.merge
+for i in $(ls -d results.????)
+do
+       ln -s ../$i run.merge/output_${i}
+done
+gate_power_merge.sh run.merge
index 3a9bba6b23b01002bb32dd303a9d3259dd787475..c35d67d6b4238389d1e2ff7af17c483f6077730b 100755 (executable)
@@ -314,7 +314,7 @@ function merge_dispatcher {
     local outputfile="${1:?"provide output filename"}"
     echo "merging ${outputfile}"
 
-    local partialoutputfiles="$(find "${rundir}" -mindepth 2 -type f -name "${outputfile}")"
+    local partialoutputfiles="$(find -L "${rundir}" -mindepth 2 -type f -name "${outputfile}")"
     local nboutputfiles="$(echo "${partialoutputfiles}" | wc -l)"
     if test ${nboutputdirs} -ne ${nboutputfiles}
     then
@@ -431,7 +431,7 @@ function merge_dispatcher_uncertainty {
     local indent="  ** "
     local outputfile="${1:?"provide output filename"}"
 
-    local partialoutputfiles="$(find "${rundir}" -mindepth 2 -type f -name "${outputfile}")"
+    local partialoutputfiles="$(find -L "${rundir}" -mindepth 2 -type f -name "${outputfile}")"
     local nboutputfiles="$(echo "${partialoutputfiles}" | wc -l)"
     if test ${nboutputdirs} -ne ${nboutputfiles}
     then
@@ -466,7 +466,7 @@ function merge_dispatcher_uncertainty {
             echo "${indent}${squared_merged_file} found"
             ## search for NumberOfEvent
             totalEvents=0;
-            for outputfile in $(find "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq)
+            for outputfile in $(find -L "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq)
             do
                 #echo $outputfile
                 if grep -q 'NumberOfEvent' "${outputdir}/${outputfile}"
@@ -496,7 +496,7 @@ echo "!!!! this is $0 v0.3k !!!!"
 
 rundir="${1?"provide run dir"}"
 rundir="$(echo "${rundir}" | sed 's|/*$||')"
-nboutputdirs="$(find "${rundir}" -mindepth 1 -type d -name 'output*' | wc -l)"
+nboutputdirs="$(find "${rundir}" -mindepth 1 -type d -o -type l -name 'output*' | wc -l)"
 
 test ${nboutputdirs} -gt 0 || error "no output dir found"
 echo "found ${nboutputdirs} partial output dirs"
@@ -511,15 +511,15 @@ echo "output dir is ${outputdir}"
 
 test -d "${outputdir}" && rm -r "${outputdir}"
 mkdir "${outputdir}"
-
-for outputfile in $(find "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq)
+ls ${rundir}/
+for outputfile in $(find -L "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq)
 do
     merge_dispatcher "${outputfile}"
 done
 
 echo ""
 echo "Merging done. Special case for statistical uncertainty"
-for outputfile in $(find "${outputdir}" -regextype 'posix-extended' -type f -regex "${outputdir}/.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq)
+for outputfile in $(find -L "${outputdir}" -regextype 'posix-extended' -type f -regex "${outputdir}/.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq)
 do
     merge_dispatcher_uncertainty "${outputfile}"
 done
index a0e8846432f681dd3c75f0a238f58773db79230e..478b8173b76f8d8ac1fcfdd7353caade239b11e4 100644 (file)
@@ -120,6 +120,11 @@ IF (CLITK_BUILD_TOOLS)
   TARGET_LINK_LIBRARIES(clitkMatrixToElastixTransform clitkCommon )
   SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMatrixToElastixTransform)
 
+  WRAP_GGO(clitkMatrixMultiply_GGO_C clitkMatrixMultiply.ggo)
+  ADD_EXECUTABLE(clitkMatrixMultiply clitkMatrixMultiply.cxx ${clitkMatrixMultiply_GGO_C})
+  TARGET_LINK_LIBRARIES(clitkMatrixMultiply clitkCommon )
+  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMatrixMultiply)
+
   WRAP_GGO(clitkMatrixInverse_GGO_C clitkMatrixInverse.ggo)
   ADD_EXECUTABLE(clitkMatrixInverse clitkMatrixInverse.cxx ${clitkMatrixInverse_GGO_C})
   TARGET_LINK_LIBRARIES(clitkMatrixInverse clitkCommon )
index abedc61a800310e4a951ae64fe5bb63ccf46b156..3a9beaf4a25406dbfd0d5ece95bf5b04d7a8db59 100644 (file)
@@ -67,6 +67,7 @@ int main(int argc, char * argv[])
   filter->SetInputFilenames(l);
   filter->SetIOVerbose(args_info.verbose_flag);
   filter->SetOutputFilename(output);
+  filter->SetVV(args_info.vv_flag);
   filter->EnableWriteCompression(args_info.compression_flag);
   if (args_info.type_given) filter->SetOutputPixelType(args_info.type_arg);
 
index 837ee03bb6c75e5ef39e9b489eeb4929bcf95dd2..b6f003c8f9fb9ad6339afbf8e0500a23799d31c0 100644 (file)
@@ -3,9 +3,10 @@ package "clitkImageConvert"
 version "1.0"
 purpose "Convert an image into another image.\n\tAllow to change the file format and/or the pixel type. \n\tKnown file formats 2D: jpeg png bmp tif mhd hdr vox dcm \n\tKnown file formats 3D: mhd vox hdr dcm\n\tKnown file formats 4D: mhd \n\tKnown images: 2D 3D or 4D, schar, uchar, short, ushort, int, float and double\n\nIf the -o option is not given, the last parameter of the command line is used as output."
 
-option "config"      - "Config file"                     string no
-option "input"       i "Input image filename"            string no
-option "output"      o "Output image filename"           string no
-option "type"        t "Output type (float, ushort ...)" string no
-option "verbose"     v "Verbose"                         flag   off
-option "compression" c "Compress output"                 flag   off
+option "config"      - "Config file"                                                string no
+option "input"       i "Input image filename"                                       string no
+option "output"      o "Output image filename"                                      string no
+option "type"        t "Output type (float, ushort ...)"                            string no
+option "verbose"     v "Verbose"                                                    flag   off
+option "compression" c "Compress output"                                            flag   off
+option "vv"          - "Read image as in vv and save transform in meta information" flag   off
index e8d8efb79d9f8c6a54d9cc1b5f37e0401d613c75..2783053fdb2d7546c4096948e621c38a7a4fdeb2 100644 (file)
@@ -19,6 +19,8 @@
 #define CLITKIMAGECONVERTGENERICFILTER_CXX
 
 #include "clitkImageConvertGenericFilter.h"
+#include "vvImageReader.h"
+#include "vvImageWriter.h"
 
 //--------------------------------------------------------------------
 clitk::ImageConvertGenericFilter::ImageConvertGenericFilter():
@@ -70,7 +72,24 @@ void clitk::ImageConvertGenericFilter::UpdateWithInputImageType()
     }
   }
 
-  if ((m_PixelTypeName == mOutputPixelTypeName) || (mOutputPixelTypeName == "NotSpecified")) {
+  if(mVV) {
+    if (mOutputPixelTypeName != "NotSpecified" || m_WriteCompression) {
+      std::cerr << "--vv is not compatible with --compression and --type options." << std::endl;
+      exit(-1);
+    }
+
+    vvImageReader::Pointer reader = vvImageReader::New();
+    reader->SetInputFilenames(m_InputFilenames);
+    reader->Update(vvImageReader::IMAGE);
+
+    vvImageWriter::Pointer writer = vvImageWriter::New();
+    writer->SetOutputFileName(m_OutputFilenames.front());
+    writer->SetSaveTransform(true);
+    writer->SetInput(reader->GetOutput());
+    writer->Update();
+    return;
+  }
+  else if ((m_PixelTypeName == mOutputPixelTypeName) || (mOutputPixelTypeName == "NotSpecified")) {
     typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
     this->SetNextOutput<InputImageType>(input);
   } else {
index 20717144431725a5f793d061467e10f170dc61bb..8ffb360596833d0225c6b022cc9dd04711dc544d 100644 (file)
@@ -73,6 +73,7 @@ namespace clitk {
     std::string GetInputPixelTypeName() { return m_PixelTypeName; }
     std::string GetOutputPixelTypeName() { return mOutputPixelTypeName; }
     void SetOutputPixelType(std::string p) { mOutputPixelTypeName = p; }
+    void SetVV(bool b) { mVV = b; }
     bool IsWarningOccur() { return mWarningOccur; }
     std::string & GetWarning() { return mWarning; }
     void EnableDisplayWarning(bool b) { mDisplayWarning = b; }
@@ -92,6 +93,7 @@ namespace clitk {
     std::string mWarning;
     bool mWarningOccur;
     bool mDisplayWarning;
+    bool mVV;
 
   private:
     template <class InputImageType, bool isVector>
diff --git a/tools/clitkMatrixMultiply.cxx b/tools/clitkMatrixMultiply.cxx
new file mode 100644 (file)
index 0000000..95e1a40
--- /dev/null
@@ -0,0 +1,59 @@
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to:
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
+
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
+
+  It is distributed under dual licence
+
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+
+// clitk
+#include "clitkMatrixMultiply_ggo.h"
+#include "clitkTransformUtilities.h"
+#include "clitkIO.h"
+#include "clitkMatrix.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+  // Init command line
+  GGO(clitkMatrixMultiply, args_info);
+  CLITK_INIT;
+
+  // Read matrix
+  itk::Matrix<double, 4, 4> matrix1, matrix2;
+  try {
+    matrix1 = clitk::ReadMatrix3D(args_info.input1_arg);
+    matrix2 = clitk::ReadMatrix3D(args_info.input2_arg);
+  }
+  catch (itk::ExceptionObject & err) {
+    std::cerr << "Error reading "
+              << args_info.input1_arg
+              << " and "
+              << args_info.input2_arg
+              << std::endl;
+    std::cerr << err.GetDescription() << std::endl;
+    exit(-1);
+  }
+
+  itk::Matrix<double, 4, 4> matrix(matrix2.GetVnlMatrix() * matrix1.GetVnlMatrix());
+
+  // Print matrix
+  std::ofstream os;
+  clitk::openFileForWriting(os, args_info.output_arg);
+  os << clitk::Get4x4MatrixDoubleAsString(matrix, 16);
+  os.close();
+
+  return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
diff --git a/tools/clitkMatrixMultiply.ggo b/tools/clitkMatrixMultiply.ggo
new file mode 100644 (file)
index 0000000..5463bdd
--- /dev/null
@@ -0,0 +1,8 @@
+package "clitkMatrixMultiply"
+version "1.0"
+purpose "Multiply two 4x4 matrices. In matrice notations, does input2*input"
+
+option "config"  - "Config file"            string optional
+option "input1"  i "Input matrix filename"  string required
+option "input2"  j "Input matrix filename"  string required
+option "output"  o "Output matrix filename" string required