]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
authorRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Tue, 26 Feb 2013 10:51:04 +0000 (11:51 +0100)
committerRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Tue, 26 Feb 2013 10:51:04 +0000 (11:51 +0100)
12 files changed:
cmake/FindRoot.cmake [deleted file]
common/clitkIO.cxx
segmentation/clitkMorphoMath.ggo
tools/clitkMaskLandmarks.cxx [new file with mode: 0644]
tools/clitkMaskLandmarks.ggo [new file with mode: 0644]
tools/clitkPadImage.ggo
vv/qt_ui/vvOverlayPanel.ui
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvOverlayPanel.cxx
vv/vvOverlayPanel.h
vv/vvSlicerManager.h

diff --git a/cmake/FindRoot.cmake b/cmake/FindRoot.cmake
deleted file mode 100644 (file)
index 2e3d19e..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-# - Find ROOT instalation
-# This module tries to find the ROOT installation on your system.
-# It tries to find the root-config script which gives you all the needed information.
-# If the system variable ROOTSYS is set this is straight forward.
-# If not the module uses the pathes given in ROOT_CONFIG_SEARCHPATH.
-# If you need an other path you should add this path to this varaible.  
-# The root-config script is then used to detect basically everything else.
-# This module defines a number of key variables and macros.
-
-
-MESSAGE(STATUS "Looking for Root...")
-
-SET(ROOT_CONFIG_SEARCHPATH
-  ${SIMPATH}/tools/root/bin
-  $ENV{ROOTSYS}/bin
-)
-
-SET(ROOT_DEFINITIONS "")
-
-SET(ROOT_INSTALLED_VERSION_TOO_OLD FALSE)
-
-SET(ROOT_CONFIG_EXECUTABLE ROOT_CONFIG_EXECUTABLE-NOTFOUND)
-
-FIND_PROGRAM(ROOT_CONFIG_EXECUTABLE NAMES root-config PATHS
-   ${ROOT_CONFIG_SEARCHPATH}
-   NO_SYSTEM_ENVIRONMENT_PATH)
-    
-IF (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
-  MESSAGE( FATAL_ERROR "ROOT not installed in the searchpath and ROOTSYS is not set. Please
- set ROOTSYS or add the path to your ROOT installation in the Macro FindROOT.cmake in the
- subdirectory cmake/modules.")
-ELSE (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
-  STRING(REGEX REPLACE "(^.*)/bin/root-config" "\\1" test ${ROOT_CONFIG_EXECUTABLE}) 
-  SET( ENV{ROOTSYS} ${test})
-  set( ROOTSYS ${test})
-ENDIF (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")  
-
-IF (ROOT_CONFIG_EXECUTABLE)
-   
-  SET(ROOT_FOUND FALSE)
-
-  EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE} ARGS "--version" OUTPUT_VARIABLE ROOTVERSION)
-
-  MESSAGE(STATUS "Looking for Root... - found $ENV{ROOTSYS}/bin/root")
-  MESSAGE(STATUS "Looking for Root... - version ${ROOTVERSION} ")   
-
-  # we need at least version 5.00/00
-  IF (NOT ROOT_MIN_VERSION)
-    SET(ROOT_MIN_VERSION "5.00/00")
-  ENDIF (NOT ROOT_MIN_VERSION)
-   
-  # now parse the parts of the user given version string into variables
-  STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+" "\\1" req_root_major_vers "${ROOT_MIN_VERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" req_root_minor_vers "${ROOT_MIN_VERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+)" "\\1" req_root_patch_vers "${ROOT_MIN_VERSION}")
-   
-  # and now the version string given by qmake
-  STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" found_root_major_vers "${ROOTVERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" found_root_minor_vers "${ROOTVERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" found_root_patch_vers "${ROOTVERSION}")
-
-  IF (found_root_major_vers LESS 5)
-    MESSAGE( FATAL_ERROR "Invalid ROOT version \"${ROOTERSION}\", at least major version 4 is required, e.g. \"5.00/00\"")
-  ENDIF (found_root_major_vers LESS 5)
-
-  # compute an overall version number which can be compared at once
-  MATH(EXPR req_vers "${req_root_major_vers}*10000 + ${req_root_minor_vers}*100 + ${req_root_patch_vers}")
-  MATH(EXPR found_vers "${found_root_major_vers}*10000 + ${found_root_minor_vers}*100 + ${found_root_patch_vers}")
-   
-  IF (found_vers LESS req_vers)
-    SET(ROOT_FOUND FALSE)
-    SET(ROOT_INSTALLED_VERSION_TOO_OLD TRUE)
-  ELSE (found_vers LESS req_vers)
-    SET(ROOT_FOUND TRUE)
-  ENDIF (found_vers LESS req_vers)
-
-ENDIF (ROOT_CONFIG_EXECUTABLE)
-
-
-IF (ROOT_FOUND)
-
-  # ask root-config for the library dir
-  # Set ROOT_LIBRARY_DIR
-
-  EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
-    ARGS "--libdir"
-    OUTPUT_VARIABLE ROOT_LIBRARY_DIR_TMP )
-
-  IF(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
-    SET(ROOT_LIBRARY_DIR ${ROOT_LIBRARY_DIR_TMP} )
-  ELSE(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
-    MESSAGE("Warning: ROOT_CONFIG_EXECUTABLE reported ${ROOT_LIBRARY_DIR_TMP} as library path,")
-    MESSAGE("Warning: but ${ROOT_LIBRARY_DIR_TMP} does NOT exist, ROOT must NOT be installed correctly.")
-  ENDIF(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
-    
-  # ask root-config for the binary dir
-  EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE}
-    ARGS "--bindir"
-    OUTPUT_VARIABLE root_bins )
-  SET(ROOT_BINARY_DIR ${root_bins})
-
-  # ask root-config for the include dir
-  EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
-    ARGS "--incdir" 
-    OUTPUT_VARIABLE root_headers )
-  SET(ROOT_INCLUDE_DIR ${root_headers})
-      # CACHE INTERNAL "")
-
-  # ask root-config for the library varaibles
-  EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
-#    ARGS "--noldflags --noauxlibs --libs" 
-    ARGS "--glibs" 
-    OUTPUT_VARIABLE root_flags )
-
-#  STRING(REGEX MATCHALL "([^ ])+"  root_libs_all ${root_flags})
-#  STRING(REGEX MATCHALL "-L([^ ])+"  root_library ${root_flags})
-#  REMOVE_FROM_LIST(root_flags "${root_libs_all}" "${root_library}")
-
-  SET(ROOT_LIBRARIES ${root_flags})
-
-  # Make variables changeble to the advanced user
-  MARK_AS_ADVANCED( ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS)
-
-  # Set ROOT_INCLUDES
-  SET( ROOT_INCLUDES ${ROOT_INCLUDE_DIR})
-
-  SET(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR})
-
-  #######################################
-  #
-  #       Check the executables of ROOT 
-  #          ( rootcint ) 
-  #
-  #######################################
-
-  FIND_PROGRAM(ROOT_CINT_EXECUTABLE
-    NAMES rootcint
-    PATHS ${ROOT_BINARY_DIR}
-    NO_DEFAULT_PATH
-    )
-
-ENDIF (ROOT_FOUND)
-
-
-
-  ###########################################
-  #
-  #       Macros for building ROOT dictionary
-  #
-  ###########################################
-
-MACRO (ROOT_GENERATE_DICTIONARY_OLD )
-   set(INFILES "")    
-
-   foreach (_current_FILE ${ARGN})
-
-     IF (${_current_FILE} MATCHES "^.*\\.h$")
-       IF (${_current_FILE} MATCHES "^.*Link.*$")
-         set(LINKDEF_FILE ${_current_FILE})
-       ELSE (${_current_FILE} MATCHES "^.*Link.*$")
-         set(INFILES ${INFILES} ${_current_FILE})
-       ENDIF (${_current_FILE} MATCHES "^.*Link.*$")
-     ELSE (${_current_FILE} MATCHES "^.*\\.h$")
-       IF (${_current_FILE} MATCHES "^.*\\.cxx$")
-         set(OUTFILE ${_current_FILE})
-       ELSE (${_current_FILE} MATCHES "^.*\\.cxx$")
-         set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})   
-       ENDIF (${_current_FILE} MATCHES "^.*\\.cxx$")
-     ENDIF (${_current_FILE} MATCHES "^.*\\.h$")
-     
-   endforeach (_current_FILE ${ARGN})
-   
-#  MESSAGE("INFILES: ${INFILES}")
-#  MESSAGE("OutFILE: ${OUTFILE}")
-#  MESSAGE("LINKDEF_FILE: ${LINKDEF_FILE}")
-#  MESSAGE("INCLUDE_DIRS: ${INCLUDE_DIRS}")
-
-   STRING(REGEX REPLACE "(^.*).cxx" "\\1.h" bla "${OUTFILE}")
-#   MESSAGE("BLA: ${bla}")
-   SET (OUTFILES ${OUTFILE} ${bla})
-
-   ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES}
-      COMMAND ${ROOT_CINT_EXECUTABLE}
-      ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES})
-
-#   MESSAGE("ROOT_CINT_EXECUTABLE has created the dictionary ${OUTFILE}")
-
-ENDMACRO (ROOT_GENERATE_DICTIONARY_OLD)
-
-  ###########################################
-  #
-  #       Macros for building ROOT dictionary
-  #
-  ###########################################
-
-MACRO (ROOT_GENERATE_DICTIONARY INFILES LINKDEF_FILE OUTFILE INCLUDE_DIRS_IN)
-  set(INCLUDE_DIRS)
-
-  foreach (_current_FILE ${INCLUDE_DIRS_IN})
-    set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})   
-  endforeach (_current_FILE ${INCLUDE_DIRS_IN})
-
-#  MESSAGE("INFILES: ${INFILES}")
-#  MESSAGE("OutFILE: ${OUTFILE}")
-#  MESSAGE("LINKDEF_FILE: ${LINKDEF_FILE}")
-#  MESSAGE("INCLUDE_DIRS: ${INCLUDE_DIRS}")
-
-  STRING(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" bla "${OUTFILE}")
-#  MESSAGE("BLA: ${bla}")
-  SET (OUTFILES ${OUTFILE} ${bla})
-
-  ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES}
-     COMMAND ${ROOT_CINT_EXECUTABLE}
-     ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES})
-
-ENDMACRO (ROOT_GENERATE_DICTIONARY)
index 8b159e7828bb13cbca487c20f517c7586ce47c1a..07af298b5563c35cbe99d62c1f30edf7fd4bf81f 100644 (file)
   #include "clitkUSVoxImageIOFactory.h"
   #include "clitkSvlImageIOFactory.h"
 #endif
+#if ITK_VERSION_MAJOR >= 4
+  #include "itkGDCMImageIOFactory.h"
+#endif
 
 //--------------------------------------------------------------------
 // Register factories
 void clitk::RegisterClitkFactories()
 {
+#if ITK_VERSION_MAJOR >= 4
+  std::list< itk::ObjectFactoryBase * > fl = itk::GDCMImageIOFactory::GetRegisteredFactories();
+  for (std::list< itk::ObjectFactoryBase * >::iterator it = fl.begin(); it != fl.end(); ++it)
+    if (dynamic_cast<itk::GDCMImageIOFactory *>(*it))
+    {
+      itk::GDCMImageIOFactory::UnRegisterFactory(*it);
+      break;
+    }
+#endif
 #if CLITK_PRIVATE_FEATURES
   clitk::UsfImageIOFactory::RegisterOneFactory();
   clitk::USVoxImageIOFactory::RegisterOneFactory();
@@ -65,5 +77,8 @@ void clitk::RegisterClitkFactories()
   rtk::EdfImageIOFactory::RegisterOneFactory();
   rtk::ImagXImageIOFactory::RegisterOneFactory();
   clitk::EsrfHstImageIOFactory::RegisterOneFactory();
+#if ITK_VERSION_MAJOR >= 4
+  itk::GDCMImageIOFactory::RegisterOneFactory();
+#endif
 } ////
 
index 7959bc950c9af0b50971af86ffa83ff0f0d6eb48..9a888231e601f1c3b2931da03dd5ba471b3cd52a 100644 (file)
@@ -11,8 +11,8 @@ option "imagetypes" - "Display allowed image types"     flag          off
 
 section "Input"
 
-option "input"  i "Input grid filename"  string yes
-option "output" o "Output grid filename" string yes
+option "input"  i "Input image filename"  string yes
+option "output" o "Output image filename" string yes
 
 
 section "Processing Parameters"
diff --git a/tools/clitkMaskLandmarks.cxx b/tools/clitkMaskLandmarks.cxx
new file mode 100644 (file)
index 0000000..a63c85f
--- /dev/null
@@ -0,0 +1,104 @@
+/*=========================================================================
+  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
+===========================================================================*/
+#include "clitkMaskLandmarks_ggo.h"
+
+#include <string>
+#include <vector>
+#include <iostream>
+#include <fstream>
+
+#include <clitkCommon.h>
+#include <clitkImageCommon.h>
+
+typedef itk::Point<double, 3> PointType;
+typedef std::vector<PointType> PointArrayType;
+
+static void read_points_pts(const std::string& fileName, PointArrayType& points, bool verbose)
+{
+  std::ifstream landmarksFile(fileName.c_str());
+  if (landmarksFile.fail())
+  {
+    std::cerr << "ERROR: could not open '" << fileName << "'" << std::endl;
+    exit(-2);
+  }
+
+  std::string line;
+  std::getline(landmarksFile, line);
+  if (line.find("#X") != 0)
+  {
+    std::cerr << "ERROR: invalid landmarks file '" << fileName << "'" << std::endl;
+    exit(-3);
+  }
+
+  PointType p;
+  while (!landmarksFile.eof())
+  {
+    landmarksFile >> p[0] >> p[1] >> p[2];
+    if (landmarksFile.fail())
+      break;
+    if (verbose)
+      std::cout << "point " << p << std::endl;
+    points.push_back(p);
+  }
+}
+
+void write_points_pts(const std::string& fileName, const PointArrayType& points, bool verbose)
+{
+  std::ofstream landmarksFile(fileName.c_str());
+
+  landmarksFile << "#X\tY\tZ" << std::endl;
+  for (size_t i = 0; i < points.size(); i++)
+    landmarksFile << points[i][0] << "\t" << points[i][1] << "\t" << points[i][2] << "\t" << std::endl;
+}
+
+int main(int argc, char** argv)
+{
+  typedef itk::Image<unsigned char, 3>  MaskType;
+  typedef MaskType::Pointer             MaskPointer;
+  GGO(clitkMaskLandmarks, args_info);
+
+  if (args_info.input_given != args_info.output_given)
+  {
+    std::cerr << "The number of inputs must be equal to the number of outputs" << std::endl;;
+    exit(1);
+  }
+
+  std::vector<PointArrayType> inputs(args_info.input_given);
+  for (unsigned i = 0; i < args_info.input_given; ++i)
+  {
+    read_points_pts(args_info.input_arg[i], inputs[i], args_info.verbose_flag);
+    if (inputs[i].size() != inputs[0].size())
+    {
+      std::cerr << "All input files must contain the same amount of points" << std::endl;
+      exit(2);
+    }
+  }
+
+  MaskPointer mask = clitk::readImage<MaskType>(args_info.mask_arg, args_info.verbose_flag);
+  std::vector<PointArrayType> outputs(args_info.input_given);
+  for (unsigned i = 0; i < inputs[0].size(); ++i)
+  {
+    MaskType::IndexType idx;
+    if (mask->TransformPhysicalPointToIndex(inputs[0][i], idx) && (*mask)[idx])
+      for (unsigned j = 0; j < args_info.input_given; j++)
+        outputs[j].push_back(inputs[j][i]);
+  }
+
+  for (unsigned i = 0; i < args_info.input_given; ++i)
+    write_points_pts(args_info.output_arg[i], outputs[i], args_info.verbose_flag);
+}
diff --git a/tools/clitkMaskLandmarks.ggo b/tools/clitkMaskLandmarks.ggo
new file mode 100644 (file)
index 0000000..82cfcc3
--- /dev/null
@@ -0,0 +1,10 @@
+package "clitkMaskLandmarks"
+version "1.0"
+purpose "Remove landmarks outside of a given mask also remove their corresponding points if multiple input are given."
+
+option "config"     - "Config file"       string    no
+option "verbose"    v     "Verbose"       flag    off
+
+option "input"  i   "Input landmarks filename"      string  yes     multiple
+option "mask"   m   "Input mask"                    string  yes
+option "output" o   "Output landmarks filename"            string  yes     multiple
index c83dfff55060f73b8b006788562387175573f1d9..90d0b7e4669e3c9e028465e1ad6be20aca982ccc 100644 (file)
@@ -12,8 +12,9 @@ option "input"                i       "Input image filename"            string        yes
 option "output"        o       "Output image filename"           string        yes
 
 section "Used determined padding"
-option "lower"         l       "Size of the lower crop region (multiple values)"         int   no  multiple
-option "upper"         u       "Size of the upper crop region (multiple values)"         int   no  multiple
+option "lower"         l       "Size of the lower bound padding (multiple values=number of image dimension)"     int   no  multiple
+option "upper"         u       "Size of the upper bound padding (multiple values=number of image dimension)"     int   no  multiple
+
 
 section "Pad like another image"
 option "like"          -       "Pad like this image (must have the same spacing and bounding box must be larger)"   string no
index 0e5a01fcac5f9d197b211f7ed0f64c5976a617db..05986d84a313a33c8a50417191d5ceb1920ebe64 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>444</width>
-    <height>612</height>
+    <width>446</width>
+    <height>679</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -65,9 +65,9 @@ p, li { white-space: pre-wrap; }
       </property>
       <property name="geometry">
        <rect>
-        <x>220</x>
+        <x>230</x>
         <y>60</y>
-        <width>80</width>
+        <width>91</width>
         <height>17</height>
        </rect>
       </property>
@@ -78,9 +78,9 @@ p, li { white-space: pre-wrap; }
      <widget class="QCheckBox" name="fCTUSActivateSpaceSyncCheckBox">
       <property name="geometry">
        <rect>
-        <x>220</x>
+        <x>270</x>
         <y>10</y>
-        <width>61</width>
+        <width>81</width>
         <height>17</height>
        </rect>
       </property>
@@ -115,7 +115,7 @@ p, li { white-space: pre-wrap; }
        <rect>
         <x>30</x>
         <y>0</y>
-        <width>171</width>
+        <width>231</width>
         <height>32</height>
        </rect>
       </property>
@@ -141,7 +141,7 @@ p, li { white-space: pre-wrap; }
        <rect>
         <x>130</x>
         <y>36</y>
-        <width>151</width>
+        <width>201</width>
         <height>20</height>
        </rect>
       </property>
@@ -149,17 +149,20 @@ p, li { white-space: pre-wrap; }
        <enum>Qt::Horizontal</enum>
       </property>
      </widget>
-     <widget class="QPushButton" name="fCTUSLoadSignalPushButton">
+     <widget class="QPushButton" name="fCTUSLoadCorrespondancesPushButton">
       <property name="geometry">
        <rect>
         <x>20</x>
         <y>60</y>
-        <width>131</width>
+        <width>171</width>
         <height>23</height>
        </rect>
       </property>
+      <property name="toolTip">
+       <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Load a file indicating the correspondances between time indices between both sequences.&lt;/p&gt;&lt;p&gt;The format needs to be the following:&lt;/p&gt;&lt;p&gt;let nt1 the number of frames in sequence 1, resp. nt2 and seq. 2 &lt;/p&gt;&lt;p&gt;The file must contain nt1 + nt2 entries.&lt;/p&gt;&lt;p&gt;entry i (i&amp;lt;=nt1) indicates for the i-th frame of sequence 1 the index to display for sequence 2.&lt;/p&gt;&lt;p&gt;resp. i&amp;gt;nt1 indicate corresp from seq. 2 to seq. 1&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+      </property>
       <property name="text">
-       <string>Load Fused Seq. Signal</string>
+       <string>Load Correspondances</string>
       </property>
      </widget>
     </widget>
index 5c7bbfd76f3ccb531c54b1ae01fe0b0d0358b33e..a06870f5baf2074d74856776a9b49c36ff9e0adf 100644 (file)
@@ -88,6 +88,7 @@ It is distributed under dual licence
 
 // Standard includes
 #include <iostream>
+#include <fstream>
 #include <sstream>
 #include <iomanip>
 
@@ -101,7 +102,7 @@ It is distributed under dual licence
 #define COLUMN_IMAGE_NAME 7
 
 #ifdef CLITK_PRIVATE_FEATURES
-#define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz *.usf)"
+#define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz *.usf *.svl)"
 #else
 #define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz)"
 #endif
@@ -294,7 +295,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation()));
   connect(actionRegister_vv,SIGNAL(triggered()),this,SLOT(PopupRegisterForm()));
 
-  connect(overlayPanel, SIGNAL(FusionSequenceSignalButtonPressed()), this, SLOT(SelectFusionSequenceTemporalSignal()));
+  connect(overlayPanel, SIGNAL(FusionSequenceCorrespondancesButtonPressed()), this, SLOT(SelectFusionSequenceCorrespondances()));
 
 
   ///////////////////////////////////////////////
@@ -1651,6 +1652,7 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column)
         }
         
         //TODO: also remove the image overlaid with the main sequence, as it is becoming invalid...
+        //this shall be done by calling this->CloseImage() with the correct index;...
       }
 
       linkPanel->removeImage(index);
@@ -2443,7 +2445,7 @@ void vvMainWindow::SelectFusionSequence()
 
 
 //------------------------------------------------------------------------------
-void vvMainWindow::SelectFusionSequenceTemporalSignal() {
+void vvMainWindow::SelectFusionSequenceCorrespondances() {
 
   //make sure the index is right?
   //in the end, I should attach the temporal data to the right sequence!
@@ -2454,35 +2456,51 @@ void vvMainWindow::SelectFusionSequenceTemporalSignal() {
   }
 
   //open a dialog box to find a file
-  QString Extensions = EXTENSIONS;
-  Extensions += ";;All Files (*)";
+  //QString Extensions = EXTENSIONS;
+  QString Extensions = ";;All Files (*)";
   QString fileName = QFileDialog::getOpenFileName(this,tr("Load respiratory signal for fused sequence"),mInputPathName,Extensions);
   if (fileName.isNull())
     return;
 
   //read it as a vector of values
-  std::vector<double> signal;
-  //...TODO, look for itk functions that can do that... vnl in the worst case.
-  signal.push_back(1);signal.push_back(2);
-
-  //TODO: instead: if the loaded signal is longer, just crop it...
-  //this allows loading only the first few frames when testing.
-  //->maybe raise a message that this behavior may be unsafe...
-
-  //if compatible with the fused image sequence (number of images = number of entries), enable the temporalSync
-  if ( signal.size() >= mSlicerManagers[index]->GetFusionSequenceNbFrames()) {
-    //for convenience, associate this sequence to both the current slicer manager, and to the linked one
-    mSlicerManagers[index]->SetFusionSequenceTemporalSignal(signal);
-    mSlicerManagers[ mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager() ]->SetFusionSequenceTemporalSignal(signal);
-    overlayPanel->enableFusionSequenceTemporalSync();
-    QMessageBox::information(this,tr("Adding signal"),"would add the signal from file: "+ fileName);
+  vnl_vector<double> tmpVect;
+
+  std::ifstream file;
+  file.open(fileName.toStdString().c_str());
+  tmpVect.read_ascii(file);
+  file.close();
+
+  //if compatible with the fused image sequence (number of entries = nb of entries in main sequence + nb of entries in joint sequence), enable the temporalSync
+  bool signalOK = true;
+  unsigned nbFrameMain = mSlicerManagers[index]->GetImage()->GetTransform().size();
+  unsigned nbFrameSecondary = mSlicerManagers[index]->GetFusionSequenceNbFrames();
+
+  std::vector<unsigned> temporalCorrespondances;
+  if ( tmpVect.size() == nbFrameMain + nbFrameSecondary ) {
+    for (unsigned i=0 ; i<tmpVect.size() ; i++) {
+      if (i<nbFrameMain) { //first part of the file: i -> index in secondary seq.
+        if ( tmpVect(i)<nbFrameSecondary ) temporalCorrespondances.push_back(tmpVect(i));
+        else { signalOK=false; break; } //pointing outside the secondary sequence...
+      }
+      else { //first part of the file -> index in secondary seq.
+        if ( tmpVect(i)<nbFrameMain ) temporalCorrespondances.push_back(tmpVect(i));
+        else { signalOK=false; break; } //pointing outside the secondary sequence...      
+      }      
+    }
   }
-  else {//else, send a message to signal the failure...
-    QString error = "The provided signal doesn't have the same duration as the sequence\n";
+  else {signalOK=false;}
+  if (!signalOK) {//else, send a message to signal the failure...
+    QString error = "The provided temporal correspondances is invalid - check tooltip.\n";
     error += "Ignoring file: " + fileName;
-    QMessageBox::information(this,tr("Problem adding signal!"),error);
+    QMessageBox::information(this,tr("Problem adding temporal correspondances!"),error);
     return;
   }
+  else {
+    //for convenience, associate this sequence to both the current slicer manager, and to the linked one
+    mSlicerManagers[index]->SetFusionSequenceCorrespondances(temporalCorrespondances);
+    mSlicerManagers[ mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager() ]->SetFusionSequenceCorrespondances(temporalCorrespondances);
+    overlayPanel->enableFusionSequenceTemporalSync();
+  }
 
 }
 //------------------------------------------------------------------------------
@@ -2651,21 +2669,13 @@ void vvMainWindow::SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool
     if (spatialSyncFlag) { //reslice the CT
 
       if (temporalSyncFlag) { //do the temporal synchronisation
-        //TODO: add the temporal synchronisation stuff
-        //if the button is checked, get the phase of the requested US frame from the available signal
-        //and select the corresponding one in the CT. (check the one just before, and the one just after, and select the closest)
-
-        //TODO: do it also the other way around, when modifying the time index related to CT, select a close frame
-        //this should not be done here directly, but the code should be inspired from the one here
-        //->find a good US frame such that when calling this function with this US frame, it produces the expected result
-
-
-        //TODO: select the right CT image to display
         int mainSequenceFrameIndex=0;
         //estimate the TSlice to set to the CT
-
+        unsigned nbFramesMain = mSlicerManagers[index]->GetImage()->GetTransform().size();
+        mainSequenceFrameIndex = mSlicerManagers[index]->GetFusionSequenceCorrespondances()[ nbFramesMain + fusionSequenceFrameIndex];
         //and set it!
         mSlicerManagers[index]->SetTSlice(mainSequenceFrameIndex, false);
+        //warning, there is a loopback, and modification of the TSlice in main sequence forces an update of the TSlice in secondary, etc... 
       }
 
 
@@ -2921,12 +2931,13 @@ void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index)
           if (mSlicerManagers[i]->GetFusionSequenceTemporalSyncFlag()) {            
             //WARNING: for some obscure reason, there are problems when accessing mSlicerManagers[mSlicerManagers[i]->GetFusionSequenceIndexOfLinkedManager()]->GetFusionSequenceFrameIndex();
 
-            //int estimatedValue=mSlicerManagers[mSlicerManagers[i]->GetFusionSequenceIndexOfLinkedManager()]->GetFusionSequenceFrameIndex();
             int estimatedValue=0;
-            //TODO: if temporal sync is active
             //estimate a corresponding time index for the secondary (US) sequence, and update it accordingly.
-            //estimatedValue = ...
-            overlayPanel->updateFusionSequenceSliderValueFromWindow(estimatedValue, true);
+            estimatedValue = mSlicerManagers[i]->GetFusionSequenceCorrespondances()[ value ];       
+            //TODO: at the moment, there is a loop in TSlice modifications
+            //modifying sequence 1 causes seq 2 to update, which in turns update seq1...
+            //I disable control on seq1 at the moment.
+            //overlayPanel->updateFusionSequenceSliderValueFromWindow(estimatedValue, true);
           }
         }
       }
index 15ec68779abf129e1e2f39f987a2d242f275f33e..dd95c0a83fa273f65b6b6ecb4a83052f806424f6 100644 (file)
@@ -161,7 +161,7 @@ public slots:
   void SelectFusionImage();
   //select the file(s) from the disk containing the image sequence to fuse
   void SelectFusionSequence();
-  void SelectFusionSequenceTemporalSignal();
+  void SelectFusionSequenceCorrespondances();
 
   void ResetTransformationToIdentity();
 
index 649f1fd9360f8fb44b9a6c3575141b69f96c4b56..b394bb55de4fc079c9c8e1123f8723d1de27661a 100644 (file)
@@ -65,7 +65,7 @@ vvOverlayPanel::vvOverlayPanel(QWidget * parent):QWidget(parent)
   connect(fCTUSSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionSequenceProperty()));
   connect(fCTUSActivateSpaceSyncCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setFusionSequenceProperty()));
   connect(fCTUSActivateTimeSyncCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setFusionSequenceProperty()));
-  connect(fCTUSLoadSignalPushButton,SIGNAL(clicked()),this,SIGNAL(FusionSequenceSignalButtonPressed()));
+  connect(fCTUSLoadCorrespondancesPushButton,SIGNAL(clicked()),this,SIGNAL(FusionSequenceCorrespondancesButtonPressed()));
 }
 
 void vvOverlayPanel::getCurrentImageName(QString name)
index b0e69db92f2726b0c6aec58314c6462c45b92156..5329bf853cb1a17707ef2b61ce24b6a07664c40f 100644 (file)
@@ -68,7 +68,7 @@ signals:
   void OverlayPropertyUpdated(int color, int linked, double window, double level);
   void FusionPropertyUpdated(int opacity, int thresOpacity, int colormap, double window, double level, bool showLegend);
   void FusionSequencePropertyUpdated(int sequenceFrameIndex, bool spatialSync, unsigned int sequenceLength, bool temporalSync);
-  void FusionSequenceSignalButtonPressed();
+  void FusionSequenceCorrespondancesButtonPressed();
 
 private:
   bool disableFusionSignals;
index 3479dc6c887dfc20d5ea5e844187345261f52f00..60f239219532764c57a2e971f717c691066ba88f 100644 (file)
@@ -177,7 +177,7 @@ class vvSlicerManager : public QObject {
                mFusionSequenceListInitialTransformMatrices.push_back( tmpMat );
   }
   void SetFusionSequenceIndexOfLinkedManager(int index) { mFusionSequenceIndexLinkedManager = index; }
-  void SetFusionSequenceTemporalSignal(std::vector<double> s) { mFusionSequenceTemporalSignal = s; }
+  void SetFusionSequenceCorrespondances(std::vector<unsigned> s) { mFusionSequenceCorrespondances = s; }
   
   void SetFusionSequenceInvolvmentCode(int code) { mFusionSequenceInvolvementCode=code; }
   int GetFusionSequenceInvolvmentCode() { return mFusionSequenceInvolvementCode;}
@@ -195,7 +195,7 @@ class vvSlicerManager : public QObject {
   const vtkSmartPointer<vtkMatrix4x4>& GetFusionSequenceInitialTransformMatrixAtFrame(unsigned i) {
          return mFusionSequenceListInitialTransformMatrices[i];
   }
-  const std::vector<double>& GetFusionSequenceTemporalSignal() {return mFusionSequenceTemporalSignal;}
+  const std::vector<unsigned>& GetFusionSequenceCorrespondances() {return mFusionSequenceCorrespondances;}
 
   double GetColorWindow() const;
   double GetColorLevel() const;
@@ -332,7 +332,7 @@ protected:
   bool mFusionSequenceSpatialSyncFlag, mFusionSequenceTemporalSyncFlag; //flags indicating whether the spatial/temporal synchronization are actives
   vtkSmartPointer<vtkMatrix4x4> mFusionSequenceMainTransform;
   std::vector< vtkSmartPointer<vtkMatrix4x4> > mFusionSequenceListInitialTransformMatrices;
-  std::vector<double> mFusionSequenceTemporalSignal;
+  std::vector<unsigned> mFusionSequenceCorrespondances;
   
   int mPreset;
   SlicingPresetType mSlicingPreset;