]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
authorDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Mon, 4 Mar 2013 15:44:55 +0000 (16:44 +0100)
committerDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Mon, 4 Mar 2013 15:44:55 +0000 (16:44 +0100)
22 files changed:
cmake/dependencies.cmake
common/CMakeLists.txt
common/clitkDicomRTDoseIO.cxx
common/clitkIO.cxx
registration/CMakeLists.txt
segmentation/CMakeLists.txt
segmentation/clitkMorphoMath.ggo
superbuild/CMakeLists.txt
tools/CMakeLists.txt
tools/clitkMaskLandmarks.cxx [new file with mode: 0644]
tools/clitkMaskLandmarks.ggo [new file with mode: 0644]
tools/clitkPadImage.ggo
vv/CMakeLists.txt
vv/qt_ui/vvMainWindow.ui
vv/qt_ui/vvOverlayPanel.ui
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvOverlayPanel.cxx
vv/vvOverlayPanel.h
vv/vvSlicer.cxx
vv/vvSlicer.h
vv/vvSlicerManager.h

index 065469736579253f50c44b57c55730da2d518617..4396d093127c0ee6016ff35c72a67ff288097d85 100644 (file)
@@ -44,11 +44,13 @@ FIND_PACKAGE(Gengetopt)
 
 #=========================================================
 # Find libstatgrab is installed, add clitkMemoryUsage.cxx in the library
-FIND_LIBRARY(LIBSTATGRAB NAMES statgrab PATHS)
-IF (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND")
+IF (NOT DEFINED CLITK_MEMORY_INFO OR CLITK_MEMORY_INFO)
+  FIND_LIBRARY(LIBSTATGRAB NAMES statgrab PATHS)
+  IF (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND")
 #  MESSAGE("Install libstatgrab (http://www.i-scream.org/libstatgrab/) for memory usage information")
-  SET(CLITK_MEMORY_INFO OFF)
-ELSE (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND")
-  SET(CLITK_MEMORY_INFO ON)
-ENDIF (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND")  
+    SET(CLITK_MEMORY_INFO OFF)
+  ELSE (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND")
+    SET(CLITK_MEMORY_INFO ON)
+  ENDIF (${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND")  
+ENDIF()
 #=========================================================
index 3c7a5803ed801494be97bbb0580604cb7d42a50a..ed51fd85016860a3db0f38be51a3eb1441ab903a 100644 (file)
@@ -55,9 +55,9 @@ ENDIF(CLITK_PRIVATE_FEATURES)
 ### Declare clitkCommon library
 ADD_LIBRARY(clitkCommon STATIC ${clitkCommon_SRC})
 
-IF(NOT ${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND")
+IF(CLITK_MEMORY_INFO)
   TARGET_LINK_LIBRARIES(clitkCommon statgrab)
-ENDIF(NOT ${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND")
+ENDIF(CLITK_MEMORY_INFO)
 
 ### Check if ITK was compiled with SYSTEM_GDCM = ON and set the gdcm libraries accordingly
 SET(CLITK_USE_SYSTEM_GDCM FALSE)
index 960cb1d72cb2a50f8905fd62b79d4abefafe7a20..88e1289351a2badbd15979a7e634aa9849192ed9 100644 (file)
@@ -281,10 +281,28 @@ void clitk::DicomRTDoseIO::Read(void * buffer)
   /* PixelData */
 #if GDCM_MAJOR_VERSION == 2
   gdcm::Image &i = m_GdcmImageReader.GetImage();
-  i.GetBuffer((char*)buffer);
-  // WARNING: GetBuffer return the pixel values as stored on disk not the real pixel value
-  // we still need to multiply by m_DoseScaling
-  // An alternate solution would be to use vtkGDCMImageReader...
+  
+  char* image_data = new char[i.GetBufferLength()];
+  i.GetBuffer(image_data);
+
+  gdcm::DataSet& ds = m_GdcmImageReader.GetFile().GetDataSet();
+  float *img = (float*) buffer;
+  
+  gdcm::Attribute<0x28, 0x100> pixel_size;
+  pixel_size.SetFromDataSet(ds);
+  if (pixel_size.GetValue() == 16)  {
+    unsigned short* image_data2 = (unsigned short*) image_data ;
+    dose_copy_raw (img, image_data2, npix, m_DoseScaling);
+  }
+  else if (pixel_size.GetValue() == 32)  {
+    unsigned long* image_data2 = (unsigned long*) image_data;
+    dose_copy_raw (img, image_data2, npix, m_DoseScaling);
+  } else {
+    itkExceptionMacro(<< "Error RTDOSE not type 16U and 32U (type="
+                      << pixel_size.GetValue() << ")");
+  }
+  
+  delete [] image_data;
 #else
   float *img = (float*) buffer;
 
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 64b55dccfa0e71a6b33e3be2e333980bf52db9a9..1bf1bf5796824bcb03dda629fd1f898580f7a618 100644 (file)
@@ -44,7 +44,6 @@ IF(CLITK_BUILD_REGISTRATION)
     TARGET_LINK_LIBRARIES(clitkConvertBSplineDeformableTransformToVF clitkCommon  ${ITK_LIBRARIES})
     SET(REGISTRATION_INSTALL ${REGISTRATION_INSTALL} clitkConvertBSplineDeformableTransformToVF)
 
-#    SET_TARGET_PROPERTIES(${REGISTRATION_INSTALL} PROPERTIES INSTALL_RPATH "${VTK_DIR}:${ITK_DIR}" )  
     INSTALL (TARGETS ${REGISTRATION_INSTALL} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
 
 ENDIF(CLITK_BUILD_REGISTRATION)
index c9dc11447f329475f0c0111c0ad74082d2b912d9..7e635ddf9332386f97d8678b2c33bd65f5a2aaeb 100644 (file)
@@ -51,7 +51,6 @@ IF(CLITK_BUILD_SEGMENTATION)
     ADD_EXECUTABLE(clitkRegionGrowing clitkRegionGrowing.cxx ${clitkRegionGrowing_GGO_C} ${clitkRelativePosition_GGO_C})
     TARGET_LINK_LIBRARIES(clitkRegionGrowing clitkCommon ${ITK_LIBRARIES})
 
-#    SET_TARGET_PROPERTIES(${SEGMENTATION_INSTALL} PROPERTIES INSTALL_RPATH "${VTK_DIR}:${ITK_DIR}" )  
     INSTALL (TARGETS ${SEGMENTATION_INSTALL} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
 
 ENDIF(CLITK_BUILD_SEGMENTATION)
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"
index e62c63030667614439e14b7fbe5b236b9385a3c3..df237735199d9f4b85e38aecd2708c94bdd79ea8 100644 (file)
@@ -62,6 +62,7 @@ ExternalProject_Add(
                                                   -no-libtiff
                                                   -no-libjpeg
                                                   -no-libmng
+                                                  -no-glib
   INSTALL_COMMAND ""
 )
 SET(qmake_executable "${build_prefix}/QT/bin/qmake")
index 71937728a25aea7f049db5e22bf1a9dbed95b14e..862148a10ee91817ef96abeae275f205147beb49 100644 (file)
@@ -223,6 +223,11 @@ IF (CLITK_BUILD_TOOLS)
   TARGET_LINK_LIBRARIES(clitkTransformLandmarks clitkCommon ${ITK_LIBRARIES})
   SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkTransformLandmarks)
 
+  WRAP_GGO(clitkMaskLandmarks_GGO_C clitkMaskLandmarks.ggo)
+  ADD_EXECUTABLE(clitkMaskLandmarks clitkMaskLandmarks.cxx ${clitkMaskLandmarks_GGO_C})
+  TARGET_LINK_LIBRARIES(clitkMaskLandmarks clitkCommon ${ITK_LIBRARIES})
+  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMaskLandmarks)
+
   ADD_EXECUTABLE(clitkMakeSphereImage clitkMakeSphereImage.cxx) # clitkLineProfileGenericFilter.cxx ${clitkLineProfile_GGO_C})
   TARGET_LINK_LIBRARIES(clitkMakeSphereImage clitkCommon ${ITK_LIBRARIES})
   SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMakeSphereImage)
@@ -268,7 +273,6 @@ IF (CLITK_BUILD_TOOLS)
     SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkDicomRTPlan2Gate)
   ENDIF(ITK_VERSION_MAJOR VERSION_LESS 4)
 
-#   SET_TARGET_PROPERTIES(${TOOLS_INSTALL} PROPERTIES INSTALL_RPATH "${VTK_DIR}:${ITK_DIR}" )  
   INSTALL (TARGETS ${TOOLS_INSTALL} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
 
 ENDIF(CLITK_BUILD_TOOLS)
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 c37c3f606bebc1cc2d3386b0a6227b90d324eabb..1fbbe282a15b63648ffb8b829df184b88f192e52 100644 (file)
@@ -236,8 +236,6 @@ TARGET_LINK_LIBRARIES(vv vvLib)
 #=========================================================
 # Install options (also used by CPack)
 IF(UNIX OR APPLE)
-#   SET_TARGET_PROPERTIES(vv
-#     PROPERTIES INSTALL_RPATH "${VTK_DIR}:${ITK_DIR}")
   INSTALL (TARGETS vv DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
   #  INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/icons/ducky.png DESTINATION .)
 
@@ -267,7 +265,11 @@ SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
 SET(CPACK_PACKAGE_VERSION_MAJOR "1")
 SET(CPACK_PACKAGE_VERSION_MINOR "3")
 SET(CPACK_PACKAGE_VERSION_PATCH "0")
-SET(CPACK_PACKAGE_INSTALL_DIRECTORY "vv")
+IF(NIGHTLY)
+  SET(CPACK_PACKAGE_INSTALL_DIRECTORY "vv-nightly")
+ELSE(NIGHTLY)
+  SET(CPACK_PACKAGE_INSTALL_DIRECTORY "vv")
+ENDIF(NIGHTLY)
 SET(CPACK_STRIP_FILES TRUE)
 
 IF(WIN32)
index 67a467dd820c0f681cba79b8806956c7f61b6770..b80a782fc5bf38ab4ffc8a5d368be9db249eda0d 100644 (file)
          </sizepolicy>
         </property>
         <property name="currentIndex">
-         <number>1</number>
+         <number>0</number>
         </property>
         <widget class="QWidget" name="DataTab">
          <attribute name="title">
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 bff6700b3141f1af531d45d85768876d5850c6b1..325287b314b04c8848e54ec7c33b7fe1c7671525 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 30a8f1034931e169815e884c2ada69129a72ae4c..ed53d2c83b138c600eeabf680da7edd775854cbc 100644 (file)
@@ -155,6 +155,7 @@ vvSlicer::vvSlicer()
   mConcatenatedTransform = vtkSmartPointer<vtkTransform>::New();
   mConcatenatedFusionTransform = vtkSmartPointer<vtkTransform>::New();
   mConcatenatedOverlayTransform = vtkSmartPointer<vtkTransform>::New();
+  mFirstSetSliceOrientation = true;
 }
 //------------------------------------------------------------------------------
 
@@ -853,15 +854,17 @@ void vvSlicer::SetSliceOrientation(int orientation)
   // DDV(cursorPos, 3);
   // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
 
-  if (this->Renderer && this->GetInput()) {
+  if (mFirstSetSliceOrientation) {
+    int *range = this->GetSliceRange();
+    if (range)
+      this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
+    mFirstSetSliceOrientation = false;
+  }
+  else if (this->Renderer && this->GetInput()) {
     double s = mCursor[orientation];
     double sCursor = (s - this->GetInput()->GetOrigin()[orientation])/this->GetInput()->GetSpacing()[orientation];
     this->Slice = static_cast<int>(sCursor);
   }
-  
-//   int *range = this->GetSliceRange();
-//   if (range)
-//     this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
 
   this->UpdateOrientation();
   this->UpdateDisplayExtent();
index 570c43ddcbd83b027fab6b7ac7f2a87f7e0c453a..0bffd1f36abcc46f92d5b43a3c51aab519685e59 100644 (file)
@@ -297,5 +297,6 @@ private:
   bool mOverlayVisibility;
   bool mFusionVisibility;
   bool mVFVisibility;
+  bool mFirstSetSliceOrientation;
 };
 #endif
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;