]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
authorDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Mon, 20 Jan 2014 15:50:37 +0000 (16:50 +0100)
committerDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Mon, 20 Jan 2014 15:50:37 +0000 (16:50 +0100)
cluster_tools/gate_power_merge.sh
cluster_tools/gate_run_submit_cluster.sh
common/clitkXdrImageIOWriter.cxx
tools/clitkImageInfo.cxx
tools/clitkImageInfo.ggo
vv/QTreePushButton.h
vv/vvMainWindow.cxx
vv/vvToolROIManager.cxx

index c35d67d6b4238389d1e2ff7af17c483f6077730b..df46813513a2947539338c24dd20dbdb70f5eae4 100755 (executable)
@@ -290,7 +290,7 @@ function merge_mhd_image {
         then
             update_bar ${count} "copying first partial result ${partial}"
             cp "${partial}" "${merged}"
-            if test "$last_character" = "d" 
+            if test "$last_character" = "d"
             then
                 cp "${partial_bin}" "${merged_bin%.*}.${partial_bin##*.}"
             fi
@@ -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 -o -type l -name 'output*' | wc -l)"
+nboutputdirs="$(find "${rundir}" -mindepth 1 -name 'output*' -type d -o -type l  | wc -l)"
 
 test ${nboutputdirs} -gt 0 || error "no output dir found"
 echo "found ${nboutputdirs} partial output dirs"
index 0248a1ec007262561431d49f9ccf4db00de59f93..4df0be78dbad8d0b307f796bd68c5eddadb2047a 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash 
+#!/usr/bin/env bash
 
 set -u
 SCRIPTNAME="$(basename "${0}")"
@@ -74,10 +74,19 @@ echo "njobs = ${NJOBS}" >> "${PARAMFILE}"
 echo "macro = ${MACROFILE}" >> "${PARAMFILE}"
 test -z "${PARAM}" || echo "param = ${PARAM}" >> "${PARAMFILE}"
 
+# Copy macros files (for log)
+mkdir ${OUTPUTDIR}/mac
+cp ${MACROFILE} ${OUTPUTDIR}/mac
+files=`grep "control/execute" ${MACROFILE} | cut -d " " -f 2`
+for i in $files
+do
+    cp $i ${OUTPUTDIR}/mac
+done
+
 while test $NJOBS -gt 0; do
 
     if test "${QSUB}" = "noqsub"
-    then 
+    then
         echo "Launching Gate log in ${OUTPUTDIR}/gate_${NJOBS}.log"
         PARAM=\"${PARAM}\" INDEX=${NJOBS} INDEXMAX=${NJOBSMAX} SCRIPTDIR=${SCRIPTDIR} OUTPUTDIR=${OUTPUTDIR}  RELEASEDIR=${RELEASEDIR} MACROFILE=${MACROFILE} MACRODIR=${MACRODIR} PBS_JOBID="local_${NJOBS}" bash "${JOBFILE}" > ${OUTPUTDIR}/gate_${NJOBS}.log &
     else
index 19567aaec1c58ac98895460d945fa6c5f71e0f77..d769b3df2b4bcf2d00bf7716ae7cce76f44d0303 100644 (file)
@@ -41,6 +41,7 @@
 //From portdefs.h
 #if defined(unix) || defined(__APPLE__)
 #define O_BINARY 0
+//#define setmode(a,b) 0 // comment by ds
 #endif
 
 #ifndef __LARGE__
@@ -956,7 +957,7 @@ void clitk::XdrImageIO::WriteImage(const char* file, char* headerinfo, char* hea
 
   for (i=0; i<GetNumberOfDimensions(); i++) {
     if (!raw) {
-      sprintf(temp, "dim%d=%d\n", i+1, GetDimensions(i));
+      sprintf(temp, "dim%d=%lu\n", i+1, GetDimensions(i));
       slen = strlen(temp);
       if (!checked_write(f, temp, slen, buffer)) {
         free(pCompressed);
index a7c70798abc215bf4de9ab9dc357f04ae8939862..33d80cbf3551bdaae3af0b0934411d9df8e06aa6 100644 (file)
@@ -30,6 +30,7 @@
 #include "clitkIO.h"
 #include "clitkImageCommon.h"
 #include "clitkCommon.h"
+#include "vvImageReader.h"
 
 //====================================================================
 int main(int argc, char * argv[])
@@ -61,7 +62,29 @@ int main(int argc, char * argv[])
     else {
       std::cerr << "*** Warning : I could not read '" << args_info.inputs[i] << "' ***" << std::endl;
     }
-  }
+
+    if (args_info.matrix_flag) {
+      vvImageReader::Pointer r = vvImageReader::New();
+      r->SetInputFilename(args_info.inputs[i]);
+      r->Update(vvImageReader::IMAGE);
+      vtkMatrix4x4 * m = r->GetOutput()->GetTransform()[0]->GetMatrix();
+      for(int i=0; i<4; i++) {
+        for(int j=0; j<4; j++)
+          std::cout << m->GetElement(i,j) << " ";
+        std::cout << std::endl;
+      }
+
+      // inverse
+      m->Invert();
+      for(int i=0; i<4; i++) {
+        for(int j=0; j<4; j++)
+          std::cout << m->GetElement(i,j) << " ";
+        std::cout << std::endl;
+      }
+
+    }
+  } // end for
+
 
   // this is the end my friend
   return 0;
index 53bdc05f66518eff9940be1cb1b9701503479853..36283d16a28efc39693c1de6131a18355a54757c 100644 (file)
@@ -7,4 +7,4 @@ option "config"          - "Config file"                 string            no
 option "long"           l "Long line output (1 or 2)"   int default = "1" no
 option "verbose"        v "Same as -l 1"                flag off
 option "name"           n "Display filename"            flag off
-
+option "matrix"                 m "Display matrix"              flag off
index 290e0a2d230c2930ebe90e98b5caefdf2a5f7461..518d289880758c3077375996e291ae82f812bb1b 100644 (file)
@@ -1,7 +1,7 @@
 /*=========================================================================
   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
 
-  Authors belong to: 
+  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
index e4a6c55588ff316817db7d4af74713c27805a730..d2c732f707baee8022495499f8973304d38994ce 100644 (file)
@@ -103,9 +103,9 @@ 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 *.svl)"
+#define EXTENSIONS "Images ( *.bmp *.dcm *.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)"
+#define EXTENSIONS "Images ( *.bmp *.dcm *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz)"
 #endif
 
 
@@ -1005,7 +1005,7 @@ void vvMainWindow::CurrentImageChanged(std::string id)
                                       mSlicerManagers[selected]->GetTSlice());
   landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
   landmarksPanel->SetCurrentImage(mSlicerManagers[selected]->GetFileName().c_str());
-  
+
   emit SelectedImageHasChanged(mSlicerManagers[selected]);
 }
 //------------------------------------------------------------------------------
@@ -1168,12 +1168,12 @@ void vvMainWindow::ImageInfoChanged()
 //     infoPanel->setOrigin(GetVectorDoubleAsString(origin));
 //     infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
 //     infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
-// 
+//
 //     landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
 //                                         mSlicerManagers[index]->GetTSlice());
 //     landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
 //     landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str());
-// 
+//
 //     overlayPanel->getCurrentImageName(mSlicerManagers[index]->GetFileName().c_str());
 //     for (int i = 0; i < 4; i++) {
 //       if (DataTree->selectedItems()[0]->data(i+1,Qt::CheckStateRole).toInt() > 0 || i == 3) {
@@ -1444,7 +1444,7 @@ void vvMainWindow::DisplayChanged(QTreeWidgetItem *clickedItem, int column)
       clickedParentItem->setData(column, Qt::CheckStateRole, vis?2:0);
 
       // Children
-      std::map<std::string, int> actorTypeCounts;      
+      std::map<std::string, int> actorTypeCounts;
       for (int iChild = 0; iChild < clickedParentItem->childCount(); iChild++) {
         QTreeWidgetItem* currentChildItem = clickedParentItem->child(iChild);
         std::string actorType = currentChildItem->data(1,Qt::UserRole).toString().toStdString();
@@ -1562,7 +1562,7 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column)
         if (DataTree->topLevelItem(index)->child(child) == item) break;
       }
       if (overlay_type=="fusionSequence") {
-        //removing the overlay sequence in a fusion sequence visualization mode 
+        //removing the overlay sequence in a fusion sequence visualization mode
         //reset the transforms
         overlayPanel->getFusionSequenceProperty(-1, false, 0, false);
 
@@ -1684,12 +1684,12 @@ void vvMainWindow::ReloadImage(QTreeWidgetItem* item, int column)
   else if (role == "fusionSequence") {
     //both versions of the secondary sequence must be updated.
     mSlicerManagers[index]->ReloadFusionSequence();
-    mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->Reload(); 
+    mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->Reload();
   }
   else {
     mSlicerManagers[index]->Reload();
     //if we update the secondary sequence, then the overlay of the main sequence should also be updated
-    if (mSlicerManagers[index]->IsSecondarySequenceOfFusionSequence()) mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->ReloadFusionSequence(); 
+    if (mSlicerManagers[index]->IsSecondarySequenceOfFusionSequence()) mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->ReloadFusionSequence();
   }
   // Update view and info
   ImageInfoChanged();
@@ -1758,7 +1758,7 @@ void vvMainWindow::WindowLevelChanged()
       mSlicerManagers[index]->GetFusionLevel());
     if (mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) {
       overlayPanel->getFusionSequenceProperty(mSlicerManagers[index]->GetFusionSequenceFrameIndex(),
-        mSlicerManagers[index]->GetFusionSequenceSpatialSyncFlag(), 
+        mSlicerManagers[index]->GetFusionSequenceSpatialSyncFlag(),
         mSlicerManagers[index]->GetFusionSequenceNbFrames(),
         mSlicerManagers[index]->GetFusionSequenceTemporalSyncFlag());
     }
@@ -1772,7 +1772,7 @@ void vvMainWindow::WindowLevelChanged()
       mSlicerManagers[ind]->GetFusionWindow(),
       mSlicerManagers[ind]->GetFusionLevel());
     overlayPanel->getFusionSequenceProperty(mSlicerManagers[ind]->GetFusionSequenceFrameIndex(),
-      mSlicerManagers[ind]->GetFusionSequenceSpatialSyncFlag(), 
+      mSlicerManagers[ind]->GetFusionSequenceSpatialSyncFlag(),
       mSlicerManagers[ind]->GetFusionSequenceNbFrames(),
       mSlicerManagers[ind]->GetFusionSequenceTemporalSyncFlag());
   }
@@ -2230,7 +2230,7 @@ void vvMainWindow::AddLandmarks(int index, std::vector<std::string> files)
 {
     if (!landmarksPanel->LoadFromFile(files))
       QMessageBox::information(this,tr("Problem reading Landmarks !"),"File doesn't exist!");
-    
+
     landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
     landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str());
 }
@@ -2249,12 +2249,12 @@ void vvMainWindow::OpenField()
       return;
     }
 
-    QString Extensions = "Images ( *.mhd)";
-    Extensions += ";;Images ( *.mha)";
-    Extensions += ";;VF Images ( *.vf)";
-    Extensions += ";;nii Images ( *.nii)";
-    Extensions += ";;nrrd Images ( *.nrrd)";
-    Extensions += ";;nhdr Images ( *.nhdr)";
+    QString Extensions = "Images ( *.mhd *.mha *.vf *.nii *.nrrd *.nhdr)";
+    // Extensions += ";;Images ( *.mha)";
+    // Extensions += ";;VF Images ( *.vf)";
+    // Extensions += ";;nii Images ( *.nii)";
+    // Extensions += ";;nrrd Images ( *.nrrd)";
+    // Extensions += ";;nhdr Images ( *.nhdr)";
     Extensions += ";;All Files (*)";
     QString file = QFileDialog::getOpenFileName(this,tr("Load deformation field"),mInputPathName,Extensions);
     if (!file.isEmpty())
@@ -2489,8 +2489,8 @@ std::cout<<"nbFrameMain = "<<nbFrameMain<<", nbFrameSecondary= "<<nbFrameSeconda
       }
       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 { signalOK=false; break; } //pointing outside the secondary sequence...
+      }
     }
   }
   else {signalOK=false;}
@@ -2639,7 +2639,7 @@ void vvMainWindow::SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool
 {
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
 
-  if (!mSlicerManagers[index]->IsInvolvedInFusionSequence()) return; 
+  if (!mSlicerManagers[index]->IsInvolvedInFusionSequence()) return;
 
   //check if the focus moved to the linked sequence, and in this case, select the master sequence instead
   if (!mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) {
@@ -2647,8 +2647,8 @@ void vvMainWindow::SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool
   }
   int secondaryIndex = mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager();
   if (secondaryIndex==-1) return; //this should never happen
-  if ( (!mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) || 
-    (!mSlicerManagers[secondaryIndex]->IsSecondarySequenceOfFusionSequence()) ) 
+  if ( (!mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) ||
+    (!mSlicerManagers[secondaryIndex]->IsSecondarySequenceOfFusionSequence()) )
   {return;} //this should never happen, raise an exception?
 
   if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
@@ -2688,7 +2688,7 @@ void vvMainWindow::SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool
         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... 
+        //warning, there is a loopback, and modification of the TSlice in main sequence forces an update of the TSlice in secondary, etc...
       }
 
 
@@ -2937,16 +2937,16 @@ void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index)
       //i is the SlicerManager that is in charge of this slicer.
       if (mSlicerManagers[i]->IsInvolvedInFusionSequence()) {
         //if the slicerManager is involved in a fusionSequence as the secondary sequence, then update the slider position in the overlay panel and everything accordingly
-        if (mSlicerManagers[i]->IsSecondarySequenceOfFusionSequence()) { 
-          overlayPanel->updateFusionSequenceSliderValueFromWindow(value, true); 
+        if (mSlicerManagers[i]->IsSecondarySequenceOfFusionSequence()) {
+          overlayPanel->updateFusionSequenceSliderValueFromWindow(value, true);
         }
         else { //if this is the primary sequence that has been modified
-          if (mSlicerManagers[i]->GetFusionSequenceTemporalSyncFlag()) {            
+          if (mSlicerManagers[i]->GetFusionSequenceTemporalSyncFlag()) {
             //WARNING: for some obscure reason, there are problems when accessing mSlicerManagers[mSlicerManagers[i]->GetFusionSequenceIndexOfLinkedManager()]->GetFusionSequenceFrameIndex();
 
             int estimatedValue=0;
             //estimate a corresponding time index for the secondary (US) sequence, and update it accordingly.
-            estimatedValue = mSlicerManagers[i]->GetFusionSequenceCorrespondances()[ value ];       
+            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.
@@ -3245,9 +3245,9 @@ void vvMainWindow::SaveScreenshotAllSlices()
     // Change the slice
     slicer->SetSlice(i); // -> change the slice of the current slicer
     SM->UpdateSlice(0); // --> this one emit UpdateSlice
-    QCoreApplication::flush(); // -> needed to force display of contours 
+    QCoreApplication::flush(); // -> needed to force display of contours
 
-    // Screenshot  
+    // Screenshot
     vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter = vtkSmartPointer<vtkWindowToImageFilter>::New();
     windowToImageFilter->SetInput(renderWindow);
     windowToImageFilter->SetMagnification(1);
@@ -3261,7 +3261,7 @@ void vvMainWindow::SaveScreenshotAllSlices()
     if (i<100) num = "0"+num;
     if (i<1000) num = "0"+num;
 
-    fn = itksys::SystemTools::GetFilenamePath(filename.toStdString()) + "/"+ fn 
+    fn = itksys::SystemTools::GetFilenamePath(filename.toStdString()) + "/"+ fn
       + "_" + num + itksys::SystemTools::GetFilenameLastExtension(filename.toStdString());
     writer->SetFileName(fn.c_str());
     writer->SetInput(windowToImageFilter->GetOutput());
@@ -3657,4 +3657,3 @@ void vvMainWindow::UpdateCurrentSlicer()
   mSlicerManagerCurrentIndex = index;
 }
 //------------------------------------------------------------------------------
-
index c02516f94dde6c9cca9cff898d4543ab1cdfccb7..ec69e4ee95665914fc9279888f8cca0fc5c591f9 100644 (file)
@@ -38,7 +38,7 @@
 #include <QColorDialog>
 #include <QAbstractEventDispatcher>
 #include <QXmlStreamReader>
+
 // vtk
 #include <vtkLookupTable.h>
 #include <vtkRenderWindow.h>
@@ -51,13 +51,13 @@ ADD_TOOL(vvToolROIManager);
 
 //------------------------------------------------------------------------------
 vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f):
-  QWidget(parent->GetTab()), 
+  QWidget(parent->GetTab()),
   vvToolBase<vvToolROIManager>(parent),
   Ui::vvToolROIManager()
 {
   // Store parent
   mMainWindow = parent;
-  
+
   // Assume the initial tab ROI index is 2
   mIndexFirstTab = 2;
 
@@ -67,7 +67,7 @@ vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f)
   mTree->clear();
   mTree->header()->resizeSection(0, 30);
   mGroupBoxROI->setEnabled(false);
-  
+
   // Disable "Load dicom" button -> not useful
   frame_4->hide();
 
@@ -114,7 +114,7 @@ void vvToolROIManager::Initialize() {
 
 
 //------------------------------------------------------------------------------
-void  vvToolROIManager::InitializeNewTool(bool ReadStateFlag) 
+void  vvToolROIManager::InitializeNewTool(bool ReadStateFlag)
 {
   // Check if we need to start a new tool or read in the state file to load
   if (ReadStateFlag == false) {
@@ -132,21 +132,21 @@ void  vvToolROIManager::InitializeNewTool(bool ReadStateFlag)
 
     // Read all information in the XML
     ReadXMLInformation();
-    
-    // Check that a ROI is not already present 
+
+    // Check that a ROI is not already present
     mInitialImageIndex += mImageIndex;
     if (mInitialImageIndex >= mMainWindow->GetSlicerManagers().size()) {
       QMessageBox::warning(this, "ROIManager tool", QString("Image index %1 not found, abort.").arg(mInitialImageIndex));
       close();
       return;
     }
-    
+
     // Set the attached image
     mCurrentSlicerManager = mMainWindow->GetSlicerManagers()[mInitialImageIndex];
   }
 
   // Tab insertion, check that another tool does not already exist for this image
-  std::vector<vvToolBaseBase*> & tools = 
+  std::vector<vvToolBaseBase*> & tools =
     vvToolManager::GetInstance()->GetToolCreatorFromName(GetToolName())->GetListOfTool();
   if (tools.size() > 0) {
     for(uint i=0; i<tools.size()-1; i++) { // current tool is last
@@ -162,10 +162,10 @@ void  vvToolROIManager::InitializeNewTool(bool ReadStateFlag)
   // Display tool in the correct tab
   QWidget * tab = qFindChild<QWidget*>(mMainWindow->GetTab(), "ROItab");
   tab->layout()->addWidget(this);
+
   // If not read in a file we start automatically the browser to load
   // a roi file (binary image)
-  if (ReadStateFlag) {    
+  if (ReadStateFlag) {
     mOpenFileBrowserFlag = false;
     InputIsSelected(mCurrentSlicerManager);
     mOpenFileBrowserFlag = true;
@@ -188,18 +188,18 @@ void  vvToolROIManager::InitializeNewTool(bool ReadStateFlag)
                         roi->GetROI()->GetDisplayColor()[2]*255));
     brush.setStyle(Qt::SolidPattern);
     w->setBackground(2, brush);
-    w->setText(3, QString("%1").arg(roi->GetDepth()));  
+    w->setText(3, QString("%1").arg(roi->GetDepth()));
     roi->UpdateColor();
   }
 
   // Display the ROI
   UpdateAllContours();
-  UpdateAllROIStatus(); 
+  UpdateAllROIStatus();
 
   // Connect event from mainwindow to this widget
-  connect(mMainWindow, SIGNAL(AnImageIsBeingClosed(vvSlicerManager *)), 
+  connect(mMainWindow, SIGNAL(AnImageIsBeingClosed(vvSlicerManager *)),
           this, SLOT(AnImageIsBeingClosed(vvSlicerManager *)));
-  connect(mMainWindow, SIGNAL(SelectedImageHasChanged(vvSlicerManager *)), 
+  connect(mMainWindow, SIGNAL(SelectedImageHasChanged(vvSlicerManager *)),
           this, SLOT(SelectedImageHasChanged(vvSlicerManager *)));
   connect(mOpenBinaryButton, SIGNAL(clicked()), this, SLOT(Open()));
   //  connect(mOpenDicomButton, SIGNAL(clicked()), this, SLOT(OpenDicomImage()));
@@ -207,7 +207,7 @@ void  vvToolROIManager::InitializeNewTool(bool ReadStateFlag)
   connect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
   connect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
   connect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
-  connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));  
+  connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));
   connect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
   connect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
   connect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
@@ -228,15 +228,15 @@ void vvToolROIManager::InputIsSelected(vvSlicerManager *m)
 
   // Refuse if non 3D image
   if (mCurrentImage->GetNumberOfDimensions() != 3) {
-    QMessageBox::information(this,tr("Sorry only 3D yet"), tr("Sorry only 3D yet"));
-    close();
-    return;
+    QMessageBox::information(this,tr("Warning"), tr("Warning 3D ROI on a 4D image will results in some display bugs"));
+    //close();
+    //return;
   }
 
   // Change gui
   mLabelInputInfo->setText(QString("%1").arg(m->GetFileName().c_str()));
 
-  // Auto display browser to select new contours 
+  // Auto display browser to select new contours
   if (mOpenFileBrowserFlag) Open();
 }
 //------------------------------------------------------------------------------
@@ -245,7 +245,7 @@ void vvToolROIManager::InputIsSelected(vvSlicerManager *m)
 //------------------------------------------------------------------------------
 void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m)
 {
-  if (m == mCurrentSlicerManager) { 
+  if (m == mCurrentSlicerManager) {
     close();
     return;
   }
@@ -260,7 +260,7 @@ void vvToolROIManager::close()
   disconnect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
   disconnect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
   disconnect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
-  disconnect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));  
+  disconnect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));
   disconnect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
   disconnect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
   disconnect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
@@ -284,7 +284,7 @@ void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) {
 
   if (mCurrentSlicerManager == NULL) return;
   if (m == NULL) return;
-  if (m != mCurrentSlicerManager) hide(); 
+  if (m != mCurrentSlicerManager) hide();
   else {
     show();
   }
@@ -293,7 +293,7 @@ void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) {
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::Open() 
+void vvToolROIManager::Open()
 {
   // Open images
   QString Extensions = "Images or Dicom-Struct files ( *.mha *.mhd *.hdr *.his *.dcm RS*)";
@@ -314,16 +314,16 @@ void vvToolROIManager::Open()
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::OpenBinaryImage(QStringList & filename) 
+void vvToolROIManager::OpenBinaryImage(QStringList & filename)
 {
   if (filename.size() == 0) return;
+
   vvProgressDialog p("Reading ROI ...", true);
   p.SetCancelButtonEnabled(false);
   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-  
+
   // For each selected file, open the image
-  for(int i=0; i<filename.size(); i++) { 
+  for(int i=0; i<filename.size(); i++) {
     p.SetProgress(i, filename.size());
 
     // Open Image
@@ -332,7 +332,7 @@ void vvToolROIManager::OpenBinaryImage(QStringList & filename)
     filenames.push_back(filename[i].toStdString());
     reader->SetInputFilenames(filenames);
     reader->Update(vvImageReader::IMAGE);
-  
+
     if (reader->GetLastError().size() != 0) {
       std::cerr << "Error while reading " << filename[i].toStdString() << std::endl;
       QString error = "Cannot open file \n";
@@ -352,23 +352,23 @@ void vvToolROIManager::OpenBinaryImage(QStringList & filename)
   QApplication::restoreOverrideCursor();
 
   // Update the contours
-  UpdateAllContours(); 
+  UpdateAllContours();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::OpenDicomImage(std::string filename) 
+void vvToolROIManager::OpenDicomImage(std::string filename)
 {
   // GUI selector of roi
   vvMeshReader reader;
   reader.SetFilename(filename);
-  
+
   vvStructSelector selector;
   selector.SetStructures(reader.GetROINames());
   selector.SetPropagationCheckBoxFlag(false);
-  
-  if (selector.exec()) { 
+
+  if (selector.exec()) {
     vvProgressDialog p("Reading ROI...", true);
     p.SetCancelButtonEnabled(false);
     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
@@ -380,19 +380,19 @@ void vvToolROIManager::OpenDicomImage(std::string filename)
     // Loop on selected struct
     std::vector<int> list = selector.getSelectedItems();
     for (uint i=0; i<list.size(); i++) {
-      p.SetProgress(i, list.size());      
-       
+      p.SetProgress(i, list.size());
+
       clitk::DicomRTStruct2ImageFilter filter;
       filter.SetCropMaskEnabled(true);
       filter.SetImage(mCurrentImage);
-      filter.SetROI(s->GetROIFromROINumber(list[i])); 
+      filter.SetROI(s->GetROIFromROINumber(list[i]));
       filter.SetWriteOutputFlag(false);
-      filter.Update();  
+      filter.Update();
 
       // Get image
       vvImage::Pointer binaryImage = vvImage::New();
       binaryImage->AddVtkImage(filter.GetOutput());
-    
+
       // Add to gui
       AddImage(binaryImage, s->GetROIFromROINumber(list[i])->GetName(), "", 0, true); // "" = no filename
       mOpenedBinaryImageFilenames.push_back(filename.c_str());
@@ -401,16 +401,16 @@ void vvToolROIManager::OpenDicomImage(std::string filename)
     QApplication::restoreOverrideCursor();
   }
   // Update the contours
-  UpdateAllContours(); 
+  UpdateAllContours();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::AddImage(vvImage * binaryImage, 
-                                std::string name, 
-                                std::string filename, 
-                                double BG, bool modeBG) 
+void vvToolROIManager::AddImage(vvImage * binaryImage,
+                                std::string name,
+                                std::string filename,
+                                double BG, bool modeBG)
 {
   // Check Dimension
   int dim = mCurrentImage->GetNumberOfDimensions();
@@ -422,15 +422,15 @@ void vvToolROIManager::AddImage(vvImage * binaryImage,
     QMessageBox::information(this,tr("Reading problem"),os.str().c_str());
     return;
   }
-  
+
   // Compute roi index
   int n = mROIList.size();
-  
+
   // Compute the name of the new ROI
   // std::ostringstream oss;
   // oss << vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(filename));
   // std::string name = oss.str();
-  
+
   // Set color
   std::vector<double> color;
   color.push_back(1);
@@ -443,19 +443,19 @@ void vvToolROIManager::AddImage(vvImage * binaryImage,
 
   // Add a new roi to the list
   mROIList.push_back(roi);
+
   // Set BG or FG mode
-  if (modeBG) 
+  if (modeBG)
     roi->SetBackgroundValueLabelImage(BG);
-  else 
+  else
     roi->SetForegroundValueLabelImage(BG);
-  
+
   // Change color
   if (n<mDefaultLUTColor->GetNumberOfTableValues ()) {
     double * color = mDefaultLUTColor->GetTableValue(n % mDefaultLUTColor->GetNumberOfTableValues ());
     roi->SetDisplayColor(color[0], color[1], color[2]);
   }
-  
+
   // Add a new roi actor
   QSharedPointer<vvROIActor> actor = QSharedPointer<vvROIActor>(new vvROIActor);
   actor->SetBGMode(modeBG);
@@ -463,19 +463,19 @@ void vvToolROIManager::AddImage(vvImage * binaryImage,
   actor->SetSlicerManager(mCurrentSlicerManager);
   actor->Initialize(n+1); // depth is n+1 to start at 1
   mROIActorsList.push_back(actor);
-  
+
   // CheckBox for "All"
   if (actor->IsVisible()) mNumberOfVisibleROI++;
   if (actor->IsContourVisible()) mNumberOfVisibleContourROI++;
-  
+
   // Add ROI in tree
   mTreeWidgetList.push_back(QSharedPointer<QTreeWidgetItem>(new QTreeWidgetItem(mTree)));
   QTreeWidgetItem * w = mTreeWidgetList.back().data();
   w->setText(0, QString("%1").arg(roi->GetROINumber()));
   w->setText(1, QString("%1").arg(roi->GetName().c_str()));
-  w->setText(3, QString("%1").arg(actor->GetDepth()));  
-  QBrush brush(QColor(roi->GetDisplayColor()[0]*255, 
-                      roi->GetDisplayColor()[1]*255, 
+  w->setText(3, QString("%1").arg(actor->GetDepth()));
+  QBrush brush(QColor(roi->GetDisplayColor()[0]*255,
+                      roi->GetDisplayColor()[1]*255,
                       roi->GetDisplayColor()[2]*255));
   brush.setStyle(Qt::SolidPattern);
   w->setBackground(2, brush);
@@ -484,14 +484,14 @@ void vvToolROIManager::AddImage(vvImage * binaryImage,
   mTree->resizeColumnToContents(0);
   mTree->resizeColumnToContents(1);
 
-  // Update 
-  UpdateAllROIStatus(); 
+  // Update
+  UpdateAllROIStatus();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::UpdateAllContours() 
+void vvToolROIManager::UpdateAllContours()
 {
   if (mCurrentSlicerManager == NULL) return;
   // Render loaded ROIs (the first is sufficient)
@@ -514,7 +514,7 @@ void vvToolROIManager::UpdateAllROIStatus() {
   }
 
   // change the states
-  disconnect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));  
+  disconnect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
   disconnect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
   if (nbVisible == nb) mCheckBoxShowAll->setCheckState(Qt::Checked);
   else {
@@ -556,13 +556,13 @@ void vvToolROIManager::SelectedItemChangedInTree() {
   mCurrentROI = roi;
   mCurrentROIActor = actor;
 
-  // Warning -> avoid unuseful Render here by disconnect slider 
+  // Warning -> avoid unuseful Render here by disconnect slider
   // Update GUI
   disconnect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
   disconnect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
   disconnect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
   disconnect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
-  disconnect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));  
+  disconnect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));
   disconnect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
   disconnect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
   disconnect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
@@ -580,12 +580,12 @@ void vvToolROIManager::SelectedItemChangedInTree() {
   connect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
   connect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
   connect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
-  connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));  
+  connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));
   connect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
   connect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
   connect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
 
-  
+
   // Set the current color to the selected ROI name
   mROInameLabel->setAutoFillBackground(true);// # This is important!!
   // mROInameLabel->setStyleSheet("QLabel { background-color : red; color : blue; }");
@@ -601,7 +601,7 @@ void vvToolROIManager::SelectedItemChangedInTree() {
                           (1-mCurrentROI->GetDisplayColor()[2])*255);
   palette->setColor(QPalette::WindowText,colorFG);
   palette->setColor(QPalette::Background, color);
-  mROInameLabel->setPalette(*palette); 
+  mROInameLabel->setPalette(*palette);
 
   // Enable the group box (in case no selection before)
   mGroupBoxROI->setEnabled(true);
@@ -615,7 +615,7 @@ void vvToolROIManager::VisibleROIToggled(bool b) {
   if (b == mCurrentROIActor->IsVisible()) return; // nothing to do
   mCurrentROIActor->SetVisible(b);
   UpdateAllROIStatus();
-  mCurrentSlicerManager->Render(); 
+  mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
@@ -626,7 +626,7 @@ void vvToolROIManager::VisibleContourROIToggled(bool b) {
   if (mCurrentROIActor->IsContourVisible() == b) return; // nothing to do
   mCurrentROIActor->SetContourVisible(b);
   mCurrentROIActor->UpdateColor();
-  mCurrentSlicerManager->Render(); 
+  mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
@@ -636,7 +636,7 @@ void vvToolROIManager::OpacityChanged(int v) {
   if (mCurrentROIActor == NULL) return;
   mCurrentROIActor->SetOpacity((double)v/100.0);
   mCurrentROIActor->UpdateColor();
-  mCurrentSlicerManager->Render(); 
+  mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
@@ -653,7 +653,7 @@ void vvToolROIManager::AllVisibleROIToggled(int b) {
   if (status) mCheckBoxShowAll->setCheckState(Qt::Checked);
   else  mCheckBoxShowAll->setCheckState(Qt::Unchecked);
   mCheckBoxShow->setChecked(status);
-  mCurrentSlicerManager->Render(); 
+  mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
@@ -663,7 +663,7 @@ void vvToolROIManager::AllVisibleContourROIToggled(bool b) {
   bool status = false;
   if ((mContourCheckBoxShowAll->checkState() == Qt::Checked) ||
       (mContourCheckBoxShowAll->checkState() == Qt::PartiallyChecked))  status = true;
-  // Update current 
+  // Update current
   for(uint i=0; i<mROIActorsList.size(); i++) {
     mROIActorsList[i]->SetContourVisible(status);
   }
@@ -671,7 +671,7 @@ void vvToolROIManager::AllVisibleContourROIToggled(bool b) {
   if (status) mContourCheckBoxShowAll->setCheckState(Qt::Checked);
   else  mContourCheckBoxShowAll->setCheckState(Qt::Unchecked);
   mContourCheckBoxShow->setChecked(status);
-  mCurrentSlicerManager->Render(); 
+  mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
@@ -705,8 +705,8 @@ void vvToolROIManager::ChangeColor() {
 void vvToolROIManager::ChangeContourColor() {
   if (mCurrentROIActor == NULL) return;
   QColor color;
-  color.setRgbF(mCurrentROIActor->GetContourColor()[0], 
-               mCurrentROIActor->GetContourColor()[1], 
+  color.setRgbF(mCurrentROIActor->GetContourColor()[0],
+               mCurrentROIActor->GetContourColor()[1],
                mCurrentROIActor->GetContourColor()[2]);
   //  QColorDialog d(color);
   QColor c = QColorDialog::getColor(color, this, "Choose the contour color");
@@ -732,7 +732,7 @@ void vvToolROIManager::ChangeContourWidth(int n) {
 void vvToolROIManager::ChangeDepth(int n) {
   if (mCurrentROIActor == NULL) return;
   mCurrentROIActor->SetDepth(n);
-  // mCurrentROIActor->UpdateImage(); // FIXME  
+  // mCurrentROIActor->UpdateImage(); // FIXME
   mCurrentSlicerManager->Render();
   QList<QTreeWidgetItem *> l = mTree->selectedItems();
   QTreeWidgetItem * w = l[0];
@@ -753,14 +753,14 @@ void vvToolROIManager::ReloadCurrentROI() {
   mCurrentROIActor->SetVisible(false);
   mCurrentROIActor->SetContourVisible(false);
   mCurrentSlicerManager->Render();
-  
+
   // Reload image
   vvImageReader::Pointer reader = vvImageReader::New();
   reader->SetInputFilename(mCurrentROI->GetFilename());
   reader->Update(vvImageReader::IMAGE);
   if (reader->GetLastError() != "") {
     // No message just ignore (because can be from dicom)
-    // QMessageBox::information(mMainWindowBase, tr("Sorry, error. Could not reload"), 
+    // QMessageBox::information(mMainWindowBase, tr("Sorry, error. Could not reload"),
     //                          reader->GetLastError().c_str());
     return;
   }
@@ -776,7 +776,7 @@ void vvToolROIManager::ReloadCurrentROI() {
   mCurrentROIActor->UpdateImage();
   mCurrentROIActor->SetVisible(visible);
   mCurrentROIActor->SetContourVisible(cvisible);
-  mCurrentSlicerManager->Render();    
+  mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
@@ -812,7 +812,7 @@ void  vvToolROIManager::SaveState(std::auto_ptr<QXmlStreamWriter> & m_XmlWriter)
     m_XmlWriter->writeAttribute("Opacity", QString("%1").arg(roi->GetOpacity()));
     m_XmlWriter->writeAttribute("Depth", QString("%1").arg(roi->GetDepth()));
     m_XmlWriter->writeEndElement();
-   
+
     m_XmlWriter->writeStartElement("Contour");
     m_XmlWriter->writeAttribute("Red",  QString("%1").arg(roi->GetContourColor()[0]));
     m_XmlWriter->writeAttribute("Green",QString("%1").arg(roi->GetContourColor()[1]));
@@ -828,21 +828,21 @@ void  vvToolROIManager::SaveState(std::auto_ptr<QXmlStreamWriter> & m_XmlWriter)
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::ReadXMLInformation() 
+void vvToolROIManager::ReadXMLInformation()
 {
   std::string value="";
   mInitialImageIndex = -1;
-  while (!(m_XmlReader->isEndElement() && value == GetToolName().toStdString())) { 
+  while (!(m_XmlReader->isEndElement() && value == GetToolName().toStdString())) {
     m_XmlReader->readNext();
     value = m_XmlReader->qualifiedName().toString().toStdString();
-    
-    if (value == "Image_Index") 
+
+    if (value == "Image_Index")
       mInitialImageIndex = m_XmlReader->readElementText().toInt();
-    
+
     if (m_XmlReader->isStartElement()) {
       if (value == "ROI") {
         ReadXMLInformation_ROI();
-      }      
+      }
     }
   }
 }
@@ -850,7 +850,7 @@ void vvToolROIManager::ReadXMLInformation()
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::ReadXMLInformation_ROI() 
+void vvToolROIManager::ReadXMLInformation_ROI()
 {
   QString s;
   std::string value="";
@@ -868,13 +868,13 @@ void vvToolROIManager::ReadXMLInformation_ROI()
   int width = 1;
   int depth=1;
 
-  while (!(m_XmlReader->isEndElement() && value == "ROI")) { 
+  while (!(m_XmlReader->isEndElement() && value == "ROI")) {
     m_XmlReader->readNext();
     value = m_XmlReader->qualifiedName().toString().toStdString();
     if (value == "Image") {
       s = m_XmlReader->readElementText();
     }
-    
+
     if (value == "Overlay" && m_XmlReader->isStartElement()) {
       QXmlStreamAttributes attributes = m_XmlReader->attributes();
       if (!m_XmlReader->hasError())
@@ -907,8 +907,8 @@ void vvToolROIManager::ReadXMLInformation_ROI()
     }
     param->SetOverlayColor(r,g,b);
     param->SetVisible(visible);
-    param->SetOpacity(opacity); 
-    param->SetDepth(depth); 
+    param->SetOpacity(opacity);
+    param->SetDepth(depth);
 
     param->SetContourColor(cr,cg,cb);
     param->SetContourVisible(cvisible);