diff --git a/Modules/PhotoacousticsAlgorithms/mitkPhotoacousticImage.cpp b/Modules/PhotoacousticsAlgorithms/mitkPhotoacousticImage.cpp index 390b8fb2a6..07f7fc4655 100644 --- a/Modules/PhotoacousticsAlgorithms/mitkPhotoacousticImage.cpp +++ b/Modules/PhotoacousticsAlgorithms/mitkPhotoacousticImage.cpp @@ -1,154 +1,153 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkPhotoacousticImage.h" -#include "mitkUSDiPhASBModeImageFilter.h" #include "Algorithms/ITKUltrasound/itkBModeImageFilter.h" #include "Algorithms/itkPhotoacousticBModeImageFilter.h" #include "mitkImageCast.h" #include "mitkITKImageImport.h" // itk dependencies #include "itkImage.h" #include "itkResampleImageFilter.h" #include "itkCastImageFilter.h" #include "itkCropImageFilter.h" #include "itkRescaleIntensityImageFilter.h" #include "itkIntensityWindowingImageFilter.h" #include #include "itkMultiplyImageFilter.h" mitk::PhotoacousticImage::PhotoacousticImage() { MITK_INFO << "[PhotoacousticImage Debug] created that image"; } mitk::PhotoacousticImage::~PhotoacousticImage() { MITK_INFO << "[PhotoacousticImage Debug] destroyed that image"; } mitk::Image::Pointer mitk::PhotoacousticImage::ApplyBmodeFilter(mitk::Image::Pointer inputImage, bool UseLogFilter, float resampleSpacing) { // we use this seperate ApplyBmodeFilter Method for processing of two-dimensional images // the image needs to be of floating point type for the envelope filter to work; the casting is done automatically by the CastToItkImage typedef itk::Image< float, 3 > itkFloatImageType; typedef itk::BModeImageFilter < itkFloatImageType, itkFloatImageType > BModeFilterType; BModeFilterType::Pointer bModeFilter = BModeFilterType::New(); // LogFilter typedef itk::PhotoacousticBModeImageFilter < itkFloatImageType, itkFloatImageType > PhotoacousticBModeImageFilter; PhotoacousticBModeImageFilter::Pointer photoacousticBModeFilter = PhotoacousticBModeImageFilter::New(); // No LogFilter typedef itk::ResampleImageFilter < itkFloatImageType, itkFloatImageType > ResampleImageFilter; ResampleImageFilter::Pointer resampleImageFilter = ResampleImageFilter::New(); itkFloatImageType::Pointer itkImage; mitk::CastToItkImage(inputImage, itkImage); itkFloatImageType::Pointer bmode; if (UseLogFilter) { bModeFilter->SetInput(itkImage); bModeFilter->SetDirection(1); bmode = bModeFilter->GetOutput(); } else { photoacousticBModeFilter->SetInput(itkImage); photoacousticBModeFilter->SetDirection(1); bmode = photoacousticBModeFilter->GetOutput(); } // resampleSpacing == 0 means: do no resampling if (resampleSpacing == 0) { return mitk::GrabItkImageMemory(bmode); } itkFloatImageType::SpacingType outputSpacing; itkFloatImageType::SizeType inputSize = itkImage->GetLargestPossibleRegion().GetSize(); itkFloatImageType::SizeType outputSize = inputSize; outputSize[0] = 256; outputSpacing[0] = itkImage->GetSpacing()[0] * (static_cast(inputSize[0]) / static_cast(outputSize[0])); outputSpacing[1] = resampleSpacing; outputSpacing[2] = 0.6; outputSize[1] = inputSize[1] * itkImage->GetSpacing()[1] / outputSpacing[1]; typedef itk::IdentityTransform TransformType; resampleImageFilter->SetInput(bmode); resampleImageFilter->SetSize(outputSize); resampleImageFilter->SetOutputSpacing(outputSpacing); resampleImageFilter->SetTransform(TransformType::New()); resampleImageFilter->UpdateLargestPossibleRegion(); return mitk::GrabItkImageMemory(resampleImageFilter->GetOutput()); } //mitk::Image::Pointer mitk::PhotoacousticImage::ApplyScatteringCompensation(mitk::Image::Pointer inputImage, int scattering) //{ // typedef itk::Image< float, 3 > itkFloatImageType; // typedef itk::MultiplyImageFilter MultiplyImageFilterType; // itkFloatImageType::Pointer itkImage; // mitk::CastToItkImage(inputImage, itkImage); // MultiplyImageFilterType::Pointer multiplyFilter = MultiplyImageFilterType::New(); // multiplyFilter->SetInput1(itkImage); // multiplyFilter->SetInput2(m_FluenceCompResizedItk.at(m_ScatteringCoefficient)); // return mitk::GrabItkImageMemory(multiplyFilter->GetOutput()); //} mitk::Image::Pointer mitk::PhotoacousticImage::ApplyResampling(mitk::Image::Pointer inputImage, mitk::Vector3D outputSpacing, unsigned int outputSize[3]) { typedef itk::Image< double, 3 > itkFloatImageType; typedef itk::ResampleImageFilter < itkFloatImageType, itkFloatImageType > ResampleImageFilter; ResampleImageFilter::Pointer resampleImageFilter = ResampleImageFilter::New(); itkFloatImageType::Pointer itkImage; mitk::CastToItkImage(inputImage, itkImage); itkFloatImageType::SpacingType outputSpacingItk; itkFloatImageType::SizeType inputSizeItk = itkImage->GetLargestPossibleRegion().GetSize(); itkFloatImageType::SizeType outputSizeItk = inputSizeItk; itkFloatImageType::SpacingType inputSpacing = itkImage->GetSpacing(); outputSizeItk[0] = outputSize[0]; outputSizeItk[1] = (inputSizeItk[1] * outputSize[0] / inputSizeItk[1]); outputSizeItk[2] = 1; outputSpacingItk[0] = inputSpacing[0] * (double)inputSizeItk[0] / (double)outputSize[0]; outputSpacingItk[1] = inputSpacing[1] * (double)inputSizeItk[1] / (double)outputSize[1]; outputSpacingItk[2] = outputSpacing[2]; typedef itk::IdentityTransform TransformType; resampleImageFilter->SetInput(itkImage); resampleImageFilter->SetSize(outputSizeItk); resampleImageFilter->SetOutputSpacing(outputSpacingItk); resampleImageFilter->SetTransform(TransformType::New()); resampleImageFilter->UpdateLargestPossibleRegion(); return mitk::GrabItkImageMemory(resampleImageFilter->GetOutput()); } diff --git a/Modules/PhotoacousticsAlgorithms/mitkUSDiPhASBModeImageFilter.h b/Modules/PhotoacousticsAlgorithms/mitkUSDiPhASBModeImageFilter.h deleted file mode 100644 index bfed014095..0000000000 --- a/Modules/PhotoacousticsAlgorithms/mitkUSDiPhASBModeImageFilter.h +++ /dev/null @@ -1,147 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -/*========================================================================= -* -* Copyright Insight Software Consortium -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0.txt -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*=========================================================================*/ -#ifndef itkPhotoacousticBModeImageFilter_h -#define itkPhotoacousticBModeImageFilter_h - -#include "itkComplexToModulusImageFilter.h" -#include "itkConstantPadImageFilter.h" -#include "itkImageToImageFilter.h" -#include "itkImage.h" - -#include "Algorithms/ITKUltrasound/itkRegionFromReferenceImageFilter.h" -#include "Algorithms/ITKUltrasound/itkAnalyticSignalImageFilter.h" - -namespace itk -{ - - /** - * \class PhotoacousticBModeImageFilter - * - * \brief Create an Photoacoustic B-Mode (Brightness-Mode) image from raw - * "RF" data. The RF's envelope is calculated from the analytic signal and - * logarithmic intensity transform is NOT applied. This is for now the only - * difference to the "normal" BModeImageFilter. - * - * Use SetDirection() to define the axis of propagation. - * - */ - template < typename TInputImage, typename TOutputImage = TInputImage, typename TComplexImage = Image< std::complex< typename TInputImage::PixelType >, TInputImage::ImageDimension > > - class PhotoacousticBModeImageFilter : - public ImageToImageFilter< TInputImage, TOutputImage > - { - public: - /** Standard class typedefs. */ - typedef PhotoacousticBModeImageFilter Self; - typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass; - typedef SmartPointer< Self > Pointer; - typedef SmartPointer< const Self > ConstPointer; - - /** The type of input image. */ - typedef TInputImage InputImageType; - - /** Dimension of the input and output images. */ - itkStaticConstMacro(ImageDimension, unsigned int, - TInputImage::ImageDimension); - - /** Typedef support for the input image scalar value type. */ - typedef typename InputImageType::PixelType InputPixelType; - - /** The type of output image. */ - typedef TOutputImage OutputImageType; - - /** Typedef support for the output image scalar value type. */ - typedef typename OutputImageType::PixelType OutputPixelType; - - /** Typedef of the image used for internal computations that has - * std::complex pixels. */ - typedef TComplexImage ComplexImageType; - - /** Other convenient typedefs */ - typedef typename InputImageType::RegionType InputRegionType; - typedef typename InputImageType::SizeType InputSizeType; - typedef typename InputImageType::IndexType InputIndexType; - - /** Run-time type information (and related methods) */ - itkTypeMacro(PhotoacousticBModeImageFilter, ImageToImageFilter); - - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** Set the direction in which the envelope is to be calculated. */ - virtual void SetDirection(unsigned int direction) - { - this->m_AnalyticFilter->SetDirection(direction); - this->Modified(); - } - - /** Get the direction in which the envelope is to be calculated. */ - virtual unsigned int GetDirection() const - { - return m_AnalyticFilter->GetDirection(); - } - - protected: - PhotoacousticBModeImageFilter(); - ~PhotoacousticBModeImageFilter() {} - - virtual void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE; - - virtual void GenerateData() ITK_OVERRIDE; - - // These behave like their analogs in FFT1DRealToComplexConjugateImageFilter. - virtual void GenerateInputRequestedRegion() ITK_OVERRIDE; - virtual void EnlargeOutputRequestedRegion(DataObject *output) ITK_OVERRIDE; - - /** Component filters. */ - typedef AnalyticSignalImageFilter< InputImageType, ComplexImageType > AnalyticType; - typedef ComplexToModulusImageFilter< typename AnalyticType::OutputImageType, OutputImageType > ComplexToModulusType; - typedef ConstantPadImageFilter< InputImageType, InputImageType > PadType; - typedef RegionFromReferenceImageFilter< OutputImageType, OutputImageType > ROIType; - - private: - PhotoacousticBModeImageFilter(const Self&); // purposely not implemented - void operator=(const Self&); // purposely not implemented - - typename AnalyticType::Pointer m_AnalyticFilter; - typename ComplexToModulusType::Pointer m_ComplexToModulusFilter; - typename PadType::Pointer m_PadFilter; - typename ROIType::Pointer m_ROIFilter; - }; - -} // end namespace itk - -#ifndef ITK_MANUAL_INSTANTIATION -#include "mitkUSDiPhASBModeImageFilter.hxx" -#endif - -#endif // itkPhotoacousticBModeImageFilter_h diff --git a/Modules/PhotoacousticsAlgorithms/mitkUSDiPhASBModeImageFilter.hxx b/Modules/PhotoacousticsAlgorithms/mitkUSDiPhASBModeImageFilter.hxx deleted file mode 100644 index d7ccf510b1..0000000000 --- a/Modules/PhotoacousticsAlgorithms/mitkUSDiPhASBModeImageFilter.hxx +++ /dev/null @@ -1,207 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ -/*========================================================================= -* -* Copyright Insight Software Consortium -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0.txt -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*=========================================================================*/ -#ifndef itkPhotoacousticBModeImageFilter_hxx -#define itkPhotoacousticBModeImageFilter_hxx - -#include "mitkUSDiPhASBModeImageFilter.h" - -#include "itkMetaDataDictionary.h" - -#include -#include -#include - -namespace itk -{ - - template < typename TInputImage, typename TOutputImage, typename TComplexImage > - PhotoacousticBModeImageFilter< TInputImage, TOutputImage, TComplexImage > - ::PhotoacousticBModeImageFilter() - { - m_AnalyticFilter = AnalyticType::New(); - m_ComplexToModulusFilter = ComplexToModulusType::New(); - m_PadFilter = PadType::New(); - m_ROIFilter = ROIType::New(); - - m_PadFilter->SetConstant(0.); - m_ComplexToModulusFilter->SetInput(m_AnalyticFilter->GetOutput()); - m_ROIFilter->SetInput(m_ComplexToModulusFilter->GetOutput()); - } - - - template < typename TInputImage, typename TOutputImage, typename TComplexImage > - void - PhotoacousticBModeImageFilter< TInputImage, TOutputImage, TComplexImage > - ::PrintSelf(std::ostream& os, Indent indent) const - { - Superclass::PrintSelf(os, indent); - } - - - template < typename TInputImage, typename TOutputImage, typename TComplexImage > - void - PhotoacousticBModeImageFilter< TInputImage, TOutputImage, TComplexImage > - ::GenerateInputRequestedRegion() - { - // call the superclass' implementation of this method - Superclass::GenerateInputRequestedRegion(); - - // get pointers to the inputs - InputImageType * inputPtr = const_cast (this->GetInput()); - OutputImageType * outputPtr = this->GetOutput(); - - // we need to compute the input requested region (size and start index) - typedef const typename OutputImageType::SizeType& OutputSizeType; - OutputSizeType outputRequestedRegionSize = - outputPtr->GetRequestedRegion().GetSize(); - typedef const typename OutputImageType::IndexType& OutputIndexType; - OutputIndexType outputRequestedRegionStartIndex = - outputPtr->GetRequestedRegion().GetIndex(); - - //// the regions other than the fft direction are fine - typename InputImageType::SizeType inputRequestedRegionSize = outputRequestedRegionSize; - typename InputImageType::IndexType inputRequestedRegionStartIndex = outputRequestedRegionStartIndex; - - // we but need all of the input in the fft direction - const unsigned int direction = this->GetDirection(); - const typename InputImageType::SizeType& inputLargeSize = - inputPtr->GetLargestPossibleRegion().GetSize(); - inputRequestedRegionSize[direction] = inputLargeSize[direction]; - const typename InputImageType::IndexType& inputLargeIndex = - inputPtr->GetLargestPossibleRegion().GetIndex(); - inputRequestedRegionStartIndex[direction] = inputLargeIndex[direction]; - - typename InputImageType::RegionType inputRequestedRegion; - inputRequestedRegion.SetSize(inputRequestedRegionSize); - inputRequestedRegion.SetIndex(inputRequestedRegionStartIndex); - - inputPtr->SetRequestedRegion(inputRequestedRegion); - } - - - template < typename TInputImage, typename TOutputImage, typename TComplexImage > - void - PhotoacousticBModeImageFilter< TInputImage, TOutputImage, TComplexImage > - ::EnlargeOutputRequestedRegion(DataObject *output) - { - OutputImageType* outputPtr = dynamic_cast< OutputImageType* >(output); - - // we need to enlarge the region in the fft direction to the - // largest possible in that direction - typedef const typename OutputImageType::SizeType& ConstOutputSizeType; - ConstOutputSizeType requestedSize = - outputPtr->GetRequestedRegion().GetSize(); - ConstOutputSizeType outputLargeSize = - outputPtr->GetLargestPossibleRegion().GetSize(); - typedef const typename OutputImageType::IndexType& ConstOutputIndexType; - ConstOutputIndexType requestedIndex = - outputPtr->GetRequestedRegion().GetIndex(); - ConstOutputIndexType outputLargeIndex = - outputPtr->GetLargestPossibleRegion().GetIndex(); - - typename OutputImageType::SizeType enlargedSize = requestedSize; - typename OutputImageType::IndexType enlargedIndex = requestedIndex; - const unsigned int direction = this->GetDirection(); - enlargedSize[direction] = outputLargeSize[direction]; - enlargedIndex[direction] = outputLargeIndex[direction]; - - typename OutputImageType::RegionType enlargedRegion; - enlargedRegion.SetSize(enlargedSize); - enlargedRegion.SetIndex(enlargedIndex); - outputPtr->SetRequestedRegion(enlargedRegion); - } - - - template < typename TInputImage, typename TOutputImage, typename TComplexImage > - void - PhotoacousticBModeImageFilter< TInputImage, TOutputImage, TComplexImage > - ::GenerateData() - { - this->AllocateOutputs(); - - const InputImageType * inputPtr = this->GetInput(); - OutputImageType * outputPtr = this->GetOutput(); - - const unsigned int direction = m_AnalyticFilter->GetDirection(); - typename InputImageType::SizeType size = inputPtr->GetLargestPossibleRegion().GetSize(); - - // Zero padding. FFT direction should be factorable by 2 for all FFT - // implementations to work. - unsigned int n = size[direction]; - while (n % 2 == 0) - { - n /= 2; - } - bool doPadding; - if (n == 1) - { - doPadding = false; - } - else - { - doPadding = true; - } - if (doPadding) - { - n = size[direction]; - unsigned int newSizeDirection = 1; - while (newSizeDirection < n) - { - newSizeDirection *= 2; - } - typename InputImageType::SizeType padSize; - padSize.Fill(0); - padSize[direction] = newSizeDirection - size[direction]; - size[direction] = newSizeDirection; - m_PadFilter->SetPadUpperBound(padSize); - m_PadFilter->SetInput(inputPtr); - m_AnalyticFilter->SetInput(m_PadFilter->GetOutput()); - m_ROIFilter->SetReferenceImage(inputPtr); - m_ROIFilter->SetInput(m_ComplexToModulusFilter->GetOutput()); - m_ROIFilter->GraftOutput(outputPtr); - m_ROIFilter->Update(); - this->GraftOutput(m_ROIFilter->GetOutput()); - } - else // padding is not required - { - m_AnalyticFilter->SetInput(inputPtr); - m_ComplexToModulusFilter->GraftOutput(outputPtr); - m_ComplexToModulusFilter->Update(); - this->GraftOutput(m_ComplexToModulusFilter->GetOutput()); - } - - } - -} // end namespace itk - -#endif \ No newline at end of file diff --git a/Modules/USUI/Qmitk/QmitkUSControlsCustomDiPhASDeviceWidget.ui.autosave b/Modules/USUI/Qmitk/QmitkUSControlsCustomDiPhASDeviceWidget.ui.autosave new file mode 100644 index 0000000000..02666a19c6 --- /dev/null +++ b/Modules/USUI/Qmitk/QmitkUSControlsCustomDiPhASDeviceWidget.ui.autosave @@ -0,0 +1,527 @@ + + + QmitkUSControlsCustomDiPhASDeviceWidget + + + + 0 + 0 + 579 + 903 + + + + Form + + + + + + + + + 0 + 50 + + + + QFrame::WinPanel + + + QFrame::Raised + + + Started + + + Qt::AlignCenter + + + + + + + + + <html><head/><body><p><span style=" font-weight:600;">General Settings</span></p></body></html> + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Use BMode Envelope Filter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 100 + 50 + + + + Start Recording + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 25 + + + + Qt::ScrollBarAlwaysOff + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Transmit Parameters</span></p></body></html> + + + + + + + + + 15.000000000000000 + + + 0.100000000000000 + + + 5.000000000000000 + + + + + + + 1 + + + 2 + + + + + + + Transmit Events + + + + + + + 1 + + + 0.100000000000000 + + + 10000.000000000000000 + + + 1.000000000000000 + + + + + + + Transmit Phase Length [us] + + + + + + + Excitation Frequency [MHz] + + + + + + + + Interleaved + + + + + Ultrasound only + + + + + + + + 5 + + + 75 + + + 70 + + + + + + + Voltage [V] + + + + + + + Mode + + + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Receive Parameters</span></p></body></html> + + + + + + + + + Scan Depth [mm] + + + + + + + 1 + + + 10000 + + + 1 + + + + + + + Averaging Count + + + + + + + 42 + + + 10 + + + + + + + TimeGainCompensationMin + + + + + + + 42 + + + 24 + + + + + + + TimeGainCompensationMax + + + + + + + false + + + + Image Data + + + + + Beamformed Data + + + + + + + + DataType + + + + + + + 1000.000000000000000 + + + 50.000000000000000 + + + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Beamforming Parameters</span></p></body></html> + + + + + + + + + 256 + + + 4096 + + + 256 + + + 2048 + + + + + + + Pitch of Transducer [mm] + + + + + + + 128 + + + 1024 + + + 128 + + + 128 + + + + + + + Reconstructed Samples per Line + + + + + + + 0.100000000000000 + + + 0.300000000000000 + + + + + + + Speed of Sound [m/s] + + + + + + + 1000000 + + + 1540 + + + + + + + Reconstructed Lines + + + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Bandpass Parameters</span></p></body></html> + + + + + + + + + High Cut [MHz] + + + + + + + Low Cut [MHz] + + + + + + + Bandpass Enabled + + + + + + + + + + 5.000000000000000 + + + + + + + + Off + + + + + On + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.imageprocessing/src/internal/PAImageProcessing.cpp b/Plugins/org.mitk.gui.qt.photoacoustics.imageprocessing/src/internal/PAImageProcessing.cpp index f8e40246a2..38088e66ea 100644 --- a/Plugins/org.mitk.gui.qt.photoacoustics.imageprocessing/src/internal/PAImageProcessing.cpp +++ b/Plugins/org.mitk.gui.qt.photoacoustics.imageprocessing/src/internal/PAImageProcessing.cpp @@ -1,109 +1,143 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Blueberry #include #include // Qmitk #include "PAImageProcessing.h" // Qt #include //mitk image #include #include "mitkPhotoacousticImage.h" const std::string PAImageProcessing::VIEW_ID = "org.mitk.views.paimageprocessing"; +PAImageProcessing::PAImageProcessing() : m_ResampleSpacing(0), m_UseLogfilter(false) +{ + +} + void PAImageProcessing::SetFocus() { m_Controls.buttonApplyBModeFilter->setFocus(); } void PAImageProcessing::CreateQtPartControl( QWidget *parent ) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); connect( m_Controls.buttonApplyBModeFilter, SIGNAL(clicked()), this, SLOT(ApplyBModeFilter()) ); + connect(m_Controls.DoResampling, SIGNAL(clicked()), this, SLOT(UseResampling())); + connect(m_Controls.Logfilter, SIGNAL(clicked()), this, SLOT(UseLogfilter())); + connect(m_Controls.ResamplingValue, SIGNAL(valueChanged(double)), this, SLOT(SetResampling())); + + m_Controls.DoResampling->setChecked(false); + m_Controls.ResamplingValue->setEnabled(false); } void PAImageProcessing::OnSelectionChanged( berry::IWorkbenchPart::Pointer /*source*/, const QList& nodes ) { // iterate all selected objects, adjust warning visibility foreach( mitk::DataNode::Pointer node, nodes ) { if( node.IsNotNull() && dynamic_cast(node->GetData()) ) { m_Controls.labelWarning->setVisible( false ); m_Controls.buttonApplyBModeFilter->setEnabled( true ); return; } } - m_Controls.labelWarning->setVisible( true ); m_Controls.buttonApplyBModeFilter->setEnabled( false ); } +void PAImageProcessing::UseResampling() +{ + if (m_Controls.DoResampling->isChecked()) + { + m_Controls.ResamplingValue->setEnabled(true); + m_ResampleSpacing = m_Controls.ResamplingValue->value(); + } + else + { + m_Controls.ResamplingValue->setEnabled(false); + m_ResampleSpacing = 0; + } +} + +void PAImageProcessing::UseLogfilter() +{ + m_UseLogfilter = m_Controls.Logfilter->isChecked(); +} + +void PAImageProcessing::SetResampling() +{ + m_ResampleSpacing = m_Controls.ResamplingValue->value(); +} void PAImageProcessing::ApplyBModeFilter() { QList nodes = this->GetDataManagerSelection(); if (nodes.empty()) return; mitk::DataNode::Pointer node = nodes.front(); if (!node) { // Nothing selected. Inform the user and return QMessageBox::information( NULL, "Template", "Please load and select an image before starting image processing."); return; } mitk::BaseData* data = node->GetData(); if (data) { // test if this data item is an image or not (could also be a surface or something totally different) mitk::Image* image = dynamic_cast(data); if (image) { std::stringstream message; std::string name; message << "Performing image processing for image "; if (node->GetName(name)) { // a property called "name" was found for this DataNode message << "'" << name << "'"; } message << "."; MITK_INFO << message.str(); mitk::PhotoacousticImage::Pointer filterbank = mitk::PhotoacousticImage::New(); - node->SetData(filterbank->ApplyBmodeFilter(image, false, 0.15)); + node->SetData(filterbank->ApplyBmodeFilter(image, m_UseLogfilter, m_ResampleSpacing)); + // update level window for the current dynamic range mitk::LevelWindow levelWindow; node->GetLevelWindow(levelWindow); data = node->GetData(); levelWindow.SetAuto(dynamic_cast(data),true,true); node->SetLevelWindow(levelWindow); // update rendering mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } } diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.imageprocessing/src/internal/PAImageProcessing.h b/Plugins/org.mitk.gui.qt.photoacoustics.imageprocessing/src/internal/PAImageProcessing.h index 1d7c2fdafe..6ae138643f 100644 --- a/Plugins/org.mitk.gui.qt.photoacoustics.imageprocessing/src/internal/PAImageProcessing.h +++ b/Plugins/org.mitk.gui.qt.photoacoustics.imageprocessing/src/internal/PAImageProcessing.h @@ -1,56 +1,63 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef PAImageProcessing_h #define PAImageProcessing_h #include #include #include "ui_PAImageProcessingControls.h" class PAImageProcessing : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; + PAImageProcessing(); + protected slots: /// \brief Called when the user clicks the GUI button void ApplyBModeFilter(); + void UseResampling(); + void UseLogfilter(); + void SetResampling(); protected: - virtual void CreateQtPartControl(QWidget *parent) override; virtual void SetFocus() override; /// \brief called by QmitkFunctionality when DataManager's selection has changed virtual void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, const QList& nodes ) override; Ui::PAImageProcessingControls m_Controls; + float m_ResampleSpacing; + bool m_UseLogfilter; + }; #endif // PAImageProcessing_h diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.imageprocessing/src/internal/PAImageProcessingControls.ui b/Plugins/org.mitk.gui.qt.photoacoustics.imageprocessing/src/internal/PAImageProcessingControls.ui index 68b1af3b40..a954fb2ec7 100644 --- a/Plugins/org.mitk.gui.qt.photoacoustics.imageprocessing/src/internal/PAImageProcessingControls.ui +++ b/Plugins/org.mitk.gui.qt.photoacoustics.imageprocessing/src/internal/PAImageProcessingControls.ui @@ -1,64 +1,159 @@ PAImageProcessingControls 0 0 - 222 - 161 + 615 + 678 0 0 QmitkTemplate - - - QLabel { color: rgb(255, 0, 0) } - - - Please select an image! - - - - - - - Do image processing - - - Apply B-mode Filter - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 220 - - - + + + + + <html><head/><body><p><span style=" font-size:10pt; font-weight:600;">B-mode Filter</span></p></body></html> + + + + + + + + + <html><head/><body><p><span style=" font-weight:600;">Filter Settings</span></p></body></html> + + + + + + + + + Do Resampling + + + + + + + + + 0.010000000000000 + + + 1.000000000000000 + + + 0.010000000000000 + + + 0.150000000000000 + + + + + + + Resample Spacing [mm] + + + + + + + + + Add Logfilter + + + + + + + + + QLabel { color: rgb(255, 0, 0) } + + + <html><head/><body><p align="center"><span style=" font-size:10pt; font-weight:600;">Please select an image!</span></p></body></html> + + + + + + + Do image processing + + + Apply B-mode Filter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + <html><head/><body><p><span style=" font-size:10pt; font-weight:600;">Beamforming</span></p></body></html> + + + + + + + + + Dummy + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + +