From: Simon Rit Date: Tue, 7 Jun 2011 15:01:04 +0000 (+0200) Subject: Merge branch 'master' of /home/dsarrut/clitk3.server X-Git-Tag: v1.3.0~321^2~3^2~2^2~6 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9abaa6b134ff9d8d87ec6752faa1152cc8869c07;hp=4e8939cad4521503fc448378dd148373bd4d129e;p=clitk.git Merge branch 'master' of /home/dsarrut/clitk3.server --- diff --git a/common/vvImageReader.h b/common/vvImageReader.h index a646a01..2f1de53 100644 --- a/common/vvImageReader.h +++ b/common/vvImageReader.h @@ -35,6 +35,7 @@ public: IMAGEWITHTIME, MERGEDWITHTIME, VECTORFIELD, + VECTORFIELDWITHTIME, UNDEFINEDIMAGETYPE } LoadedImageType; diff --git a/common/vvImageReader.txx b/common/vvImageReader.txx index 3a38719..2d7d5b5 100644 --- a/common/vvImageReader.txx +++ b/common/vvImageReader.txx @@ -34,7 +34,7 @@ template void vvImageReader::UpdateWithDim(std::string InputPixelType) { - if (mType == VECTORFIELD) + if (mType == VECTORFIELD || mType == VECTORFIELDWITHTIME) UpdateWithDimAndInputPixelType,VImageDimension>(); else if (InputPixelType == "short") UpdateWithDimAndInputPixelType(); @@ -162,7 +162,7 @@ void vvImageReader::UpdateWithDimAndInputPixelType() reader->ReleaseDataFlagOn(); try { - if (mType == IMAGEWITHTIME) + if (mType == IMAGEWITHTIME || mType == VECTORFIELDWITHTIME) mImage=vvImageFromITK(reader->GetOutput(),true); else mImage=vvImageFromITK(reader->GetOutput()); diff --git a/registration/clitkGenericMetric.txx b/registration/clitkGenericMetric.txx index 6f10e72..e73644c 100644 --- a/registration/clitkGenericMetric.txx +++ b/registration/clitkGenericMetric.txx @@ -35,7 +35,7 @@ GenericMetric::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::GetMetricPointer( } - //typedef itk::ImageMaskSpatialObject ImageMaskSpatialObjectType; - //typename ImageMaskSpatialObjectType::ConstPointer mask = dynamic_cast(m_FixedImageMask.GetPointer()); + typedef itk::ImageMaskSpatialObject ImageMaskSpatialObjectType; + typename ImageMaskSpatialObjectType::ConstPointer mask = NULL; + if (m_FixedImageMask.IsNotNull()) + mask = dynamic_cast(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::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::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::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::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::GetMetricPointer( if (m_Verbose) std::cout<<"A fraction of "<Cold + + + Dosimetry + + Full Color @@ -621,7 +626,7 @@ 2 - + true @@ -661,7 +666,7 @@ 2 - + true @@ -703,7 +708,7 @@ 2 - + true @@ -740,7 +745,7 @@ 2 - + 0 diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 7117da8..d965069 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -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); diff --git a/vv/vvOverlayPanel.cxx b/vv/vvOverlayPanel.cxx index f19e13b..bc3a7d0 100644 --- a/vv/vvOverlayPanel.cxx +++ b/vv/vvOverlayPanel.cxx @@ -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()); } diff --git a/vv/vvOverlayPanel.h b/vv/vvOverlayPanel.h index ef0dcf1..5000e64 100644 --- a/vv/vvOverlayPanel.h +++ b/vv/vvOverlayPanel.h @@ -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 //==================================================================== diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 871c818..987162c 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -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)