]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of /home/dsarrut/clitk3.server
authorSimon Rit <simon.rit@creatis.insa-lyon.fr>
Tue, 7 Jun 2011 15:01:04 +0000 (17:01 +0200)
committerSimon Rit <simon.rit@creatis.insa-lyon.fr>
Tue, 7 Jun 2011 15:01:04 +0000 (17:01 +0200)
common/vvImageReader.h
common/vvImageReader.txx
registration/clitkGenericMetric.txx
vv/qt_ui/vvMainWindow.ui
vv/vvMainWindow.cxx
vv/vvOverlayPanel.cxx
vv/vvOverlayPanel.h
vv/vvSlicerManager.cxx

index a646a01384cbfb9c675d71e89502bcea1e9516c1..2f1de53537794d937e16c4770ff8828eeddeddd5 100644 (file)
@@ -35,6 +35,7 @@ public:
   IMAGEWITHTIME,
   MERGEDWITHTIME,
   VECTORFIELD,
+  VECTORFIELDWITHTIME,
   UNDEFINEDIMAGETYPE
   } LoadedImageType;
 
index 3a38719c2d4a16eedaed620bccd77ebb3aa58510..2d7d5b573f3c9a2985bfef023c21f4a542c53537 100644 (file)
@@ -34,7 +34,7 @@
 template<unsigned int VImageDimension>
 void vvImageReader::UpdateWithDim(std::string InputPixelType)
 {
-  if (mType == VECTORFIELD)
+  if (mType == VECTORFIELD || mType == VECTORFIELDWITHTIME)
     UpdateWithDimAndInputPixelType<itk::Vector<float,3>,VImageDimension>();
   else if (InputPixelType == "short")
     UpdateWithDimAndInputPixelType<short,VImageDimension>();
@@ -162,7 +162,7 @@ void vvImageReader::UpdateWithDimAndInputPixelType()
       reader->ReleaseDataFlagOn();
 
       try {
-        if (mType == IMAGEWITHTIME)
+        if (mType == IMAGEWITHTIME || mType == VECTORFIELDWITHTIME)
           mImage=vvImageFromITK<VImageDimension,InputPixelType>(reader->GetOutput(),true);
         else
           mImage=vvImageFromITK<VImageDimension,InputPixelType>(reader->GetOutput());
index 6f10e72a1ee1e04744927727c70dbfe31b800056..e73644c5dc80f496861710400c526a2228ca4579 100644 (file)
@@ -35,7 +35,7 @@ GenericMetric<args_info_type, FixedImageType, MovingImageType>::GenericMetric()
   m_Maximize=false;
   m_Verbose=false;
   m_FixedImageRegionGiven=false;
-#ifdef ITK_USE_OPTIMISED_REGISTRATION_METHODS
+#ifdef ITK_USE_OPTIMIZED_REGISTRATION_METHODS
   m_FixedImageSamplesIntensityThreshold=0;
   m_UseFixedImageSamplesIntensityThreshold=false;
 #endif
@@ -256,11 +256,15 @@ GenericMetric<args_info_type,FixedImageType, MovingImageType>::GetMetricPointer(
   }
 
 
-  //typedef itk::ImageMaskSpatialObject<itkGetStaticConstMacro(FixedImageDimension)> ImageMaskSpatialObjectType;
-  //typename ImageMaskSpatialObjectType::ConstPointer mask = dynamic_cast<const ImageMaskSpatialObjectType*>(m_FixedImageMask.GetPointer());
+  typedef itk::ImageMaskSpatialObject<itkGetStaticConstMacro(FixedImageDimension)> ImageMaskSpatialObjectType;
+  typename ImageMaskSpatialObjectType::ConstPointer mask = NULL;
+  if (m_FixedImageMask.IsNotNull())
+    mask = dynamic_cast<const ImageMaskSpatialObjectType*>(m_FixedImageMask.GetPointer());
 
-  //typedef typename ImageMaskSpatialObjectType::RegionType ImageMaskRegionType;
-  //ImageMaskRegionType mask_region = mask->GetAxisAlignedBoundingBoxRegion();
+  typedef typename ImageMaskSpatialObjectType::RegionType ImageMaskRegionType;
+  ImageMaskRegionType mask_region;
+  if (mask.IsNotNull())
+    mask_region = mask->GetAxisAlignedBoundingBoxRegion();
 
   // Common properties
   if( m_FixedImageMask.IsNotNull() )
@@ -300,7 +304,7 @@ GenericMetric<args_info_type,FixedImageType, MovingImageType>::GetMetricPointer(
 
     // Calculate the number
     const unsigned int totalNumberOfPixels = m_FixedImageRegion.GetNumberOfPixels();
-    //const unsigned int totalNumberOfPixels = mask_region.GetNumberOfPixels();
+    const unsigned int totalNumberOfMaskPixels = mask_region.GetNumberOfPixels();
     const unsigned int numberOfDemandedPixels =  static_cast< unsigned int >( (double) totalNumberOfPixels *m_ArgsInfo.samples_arg );
 
     // --------------------------------------------------
@@ -333,11 +337,13 @@ GenericMetric<args_info_type,FixedImageType, MovingImageType>::GetMetricPointer(
         }
 
         // Intensity?
+        /*
         if( m_UseFixedImageSamplesIntensityThreshold &&
             ( regionIter.Get() < m_FixedImageSamplesIntensityThreshold) ) {
           ++regionIter; // jump to next pixel
           continue;
         }
+        */
 
         // Add point to the numbers
         fiic.push_back(index);
@@ -359,7 +365,7 @@ GenericMetric<args_info_type,FixedImageType, MovingImageType>::GetMetricPointer(
       //RandomIterator randIter( m_FixedImage, mask_region );
       
       if (m_Verbose) std::cout << "Search region " << m_FixedImageRegion << std::endl;
-      //if (m_Verbose) std::cout << "Mask search region " << mask_region << std::endl;
+      if (m_Verbose) std::cout << "Mask search region " << mask_region << std::endl;
 
       // Randomly sample the image
       short att = 1;
@@ -396,13 +402,13 @@ GenericMetric<args_info_type,FixedImageType, MovingImageType>::GetMetricPointer(
           }
 
           // Intensity?
-          if( m_UseFixedImageSamplesIntensityThreshold &&
-              randIter.Get() < m_FixedImageSamplesIntensityThreshold ) {
-            ++randIter;
-              //if (m_Verbose) std::cout << "not in threshold" << std::endl;
-              count_not_thres++;
-            continue;
-          }
+//           if( m_UseFixedImageSamplesIntensityThreshold &&
+//               randIter.Get() < m_FixedImageSamplesIntensityThreshold ) {
+//             ++randIter;
+//               //if (m_Verbose) std::cout << "not in threshold" << std::endl;
+//               count_not_thres++;
+//             continue;
+//           }
 
           // Add point to the numbers
           fiic.push_back(index);
@@ -427,6 +433,7 @@ GenericMetric<args_info_type,FixedImageType, MovingImageType>::GetMetricPointer(
     if (m_Verbose) std::cout<<"A fraction of "<<m_ArgsInfo.samples_arg<<" spatial samples was requested..."<<std::endl;
     double fraction=(double)numberOfValidPixels/ (double) totalNumberOfPixels;
     if (m_Verbose) std::cout<<"Found "<<numberOfValidPixels <<" valid pixels for a total of "<<totalNumberOfPixels<<" (a fraction of "<<fraction<<")..."<<std::endl;
+    if (m_Verbose) std::cout<<"number of mask pixels "<<totalNumberOfMaskPixels<<std::endl;
 
   }
 
index 7215e621aaf9d7e83bc6ec336c9a38ae09a4e057..6c7c3f8c1a41d59a97f4af5ca49b551571663c22 100644 (file)
            <string>Cold</string>
           </property>
          </item>
+         <item>
+          <property name="text">
+           <string>Dosimetry</string>
+          </property>
+         </item>
          <item>
           <property name="text">
            <string>Full Color</string>
            <number>2</number>
           </property>
           <item row="0" column="0">
-           <widget class="QVTKWidget" name="NOViewWidget" native="true">
+           <widget class="QVTKWidget" name="NOViewWidget">
             <property name="mouseTracking">
              <bool>true</bool>
             </property>
            <number>2</number>
           </property>
           <item row="0" column="0">
-           <widget class="QVTKWidget" name="SOViewWidget" native="true">
+           <widget class="QVTKWidget" name="SOViewWidget">
             <property name="mouseTracking">
              <bool>true</bool>
             </property>
            <number>2</number>
           </property>
           <item row="0" column="0">
-           <widget class="QVTKWidget" name="NEViewWidget" native="true">
+           <widget class="QVTKWidget" name="NEViewWidget">
             <property name="mouseTracking">
              <bool>true</bool>
             </property>
            <number>2</number>
           </property>
           <item row="0" column="0">
-           <widget class="QVTKWidget" name="SEViewWidget" native="true">
+           <widget class="QVTKWidget" name="SEViewWidget">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
               <horstretch>0</horstretch>
index 7117da868c2126a5ebf529ea92dc9b0bf08df72b..d965069f7a356fc6778e65fa9d755bae6c0e55a5 100644 (file)
@@ -1163,6 +1163,7 @@ void vvMainWindow::ImageInfoChanged()
       overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str());
       overlayPanel->getOverlayProperty(-1);
     }
+    
     if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
       overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
       overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(),
@@ -2136,9 +2137,9 @@ void vvMainWindow::SetFusionProperty(int opacity, int thresOpacity, int colormap
 {
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
+    mSlicerManagers[index]->SetFusionColorMap(colormap);
     mSlicerManagers[index]->SetFusionOpacity(opacity);
     mSlicerManagers[index]->SetFusionThresholdOpacity(thresOpacity);
-    mSlicerManagers[index]->SetFusionColorMap(colormap);
     mSlicerManagers[index]->SetFusionWindow(window);
     mSlicerManagers[index]->SetFusionLevel(level);
     mSlicerManagers[index]->SetColorMap(0);
index f19e13b0cc167325b3b9b87826a91ac3a098ead9..bc3a7d0180ffa93dcc024c5e14766fe5f3a7daa2 100644 (file)
@@ -49,6 +49,8 @@ vvOverlayPanel::vvOverlayPanel(QWidget * parent):QWidget(parent)
   connect(fusionColorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(setFusionProperty()));
   connect(windowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
   connect(levelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
+  
+  disableFusionSignals = false;
 }
 
 void vvOverlayPanel::getCurrentImageName(QString name)
@@ -167,18 +169,24 @@ void vvOverlayPanel::getFusionName(QString name)
 void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level)
 {
   if (opacity > -1) {
+    //first disable signals generated by each setValue() call
+    disableFusionSignals = true;
     fusionFrame->show();
     fusionFrame->setEnabled(1);
+    fusionColorMapComboBox->setEnabled(1);
+    fusionColorMapComboBox->setCurrentIndex(colormap);
     opacityHorizontalSlider->setEnabled(1);
     opacityHorizontalSlider->setValue(opacity);
     thresOpacityHorizontalSlider->setEnabled(1);
     thresOpacityHorizontalSlider->setValue(thresOpacity);
-    fusionColorMapComboBox->setEnabled(1);
-    fusionColorMapComboBox->setCurrentIndex(colormap);
     windowSpinBox->setEnabled(1);
     levelSpinBox->setEnabled(1);
     windowSpinBox->setValue(window);
     levelSpinBox->setValue(level);
+    
+    // re-enable signals and trigger slot function
+    disableFusionSignals = false;
+    setFusionProperty();
   } else {
     fusionFrame->hide();
     fusionFrame->setEnabled(0);
@@ -195,6 +203,9 @@ void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colorm
 
 void vvOverlayPanel::setFusionProperty()
 {
+  if (disableFusionSignals)
+    return;
+  
   emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
                              windowSpinBox->value(), levelSpinBox->value());
 }
index ef0dcf1f352178b5bf9d16c194a0d0ca359f9d42..5000e6444b83ef3248c33b732a3044475b842022 100644 (file)
@@ -58,6 +58,11 @@ signals:
     void VFPropertyUpdated(int subsampling, int scale, int log, int width, double r, double g, double b);
     void OverlayPropertyUpdated(int color);
     void FusionPropertyUpdated(int opacity, int thresOpacity, int colormap, double window, double level);
+
+    
+private:
+    bool disableFusionSignals;
+    
 }; // end class vvOverlayPanel
 //====================================================================
 
index 871c818a64acf3083e4706a5519ce56ae5d6eb33..987162cc6b420a0d3c8d25e557174c5b5e27945e 100644 (file)
@@ -305,7 +305,11 @@ bool vvSlicerManager::SetVF(std::string filename)
   if (mVectorReader.IsNull())
     mVectorReader = vvImageReader::New();
   mVectorReader->SetInputFilename(filename);
-  mVectorReader->Update(vvImageReader::VECTORFIELD);
+  
+  if (mType == vvImageReader::IMAGEWITHTIME)
+    mVectorReader->Update(vvImageReader::VECTORFIELDWITHTIME);
+  else
+    mVectorReader->Update(vvImageReader::VECTORFIELD);
   if (mVectorReader->GetLastError().size() != 0) {
     mLastError = mVectorReader->GetLastError();
     return false;
@@ -1076,6 +1080,13 @@ void vvSlicerManager::SetColorMap(int colormap)
     LUT->SetHueRange(0.4,0.80);
     break;
   case 3:
+    if (LUT == NULL)
+      LUT = vtkLookupTable::New();
+    LUT->SetValueRange(0.5,1);
+    LUT->SetSaturationRange(1,1);
+    LUT->SetHueRange(0.666,0);
+    break;
+  case 4:
     if (LUT == NULL)
       LUT = vtkLookupTable::New();
     LUT->SetValueRange(0,1);
@@ -1096,7 +1107,7 @@ void vvSlicerManager::SetColorMap(int colormap)
     LUT->Build();
   }
   vtkWindowLevelLookupTable* fusLUT = NULL;
-  if (mSlicers[0]->GetFusion()) { // && mFusionColorMap != 0) {
+  if (mSlicers[0]->GetFusion()) { // && mFusionColorMap >= 0) {
     fusLUT = vtkWindowLevelLookupTable::New();
     double fusRange [2];
     fusRange[0] = mFusionLevel - mFusionWindow/2;
@@ -1119,7 +1130,7 @@ void vvSlicerManager::SetColorMap(int colormap)
     }
     else if (mFusionColorMap == 4)
       fusLUT->SetHueRange(0,1);
-    else if (mFusionColorMap == 0)
+    else if (mFusionColorMap <= 0)
     {
       fusLUT->SetValueRange(0,1);
       fusLUT->SetSaturationRange(0,0);
@@ -1127,7 +1138,7 @@ void vvSlicerManager::SetColorMap(int colormap)
     
     fusLUT->ForceBuild();
     
-    // set color table transparancy
+    // set color table transparency
     double alpha_range_end = frange[0] + (double)mFusionThresOpacity*(frange[1] - frange[0])/100;
     for (double i = frange[0]; i < alpha_range_end; i++) {
       double v[4];
@@ -1167,8 +1178,8 @@ void vvSlicerManager::SetColorMap(int colormap)
     }
     
     if (mSlicers[i]->GetFusion()) {
-      mSlicers[i]->GetFusionActor()->SetOpacity(double(mFusionOpacity)/100);
       mSlicers[i]->GetFusionMapper()->SetLookupTable(fusLUT);
+      mSlicers[i]->GetFusionActor()->SetOpacity(double(mFusionOpacity)/100);
     }
   }
   if (fusLUT)