diff --git a/Modules/PhotoacousticsAlgorithms/CMakeLists.txt b/Modules/PhotoacousticsAlgorithms/CMakeLists.txt index 4a47e80aba..a0ceb37154 100644 --- a/Modules/PhotoacousticsAlgorithms/CMakeLists.txt +++ b/Modules/PhotoacousticsAlgorithms/CMakeLists.txt @@ -1,8 +1,8 @@ MITK_CREATE_MODULE( SUBPROJECTS DEPENDS MitkCore MitkAlgorithmsExt #AUTOLOAD_WITH MitkCore - INCLUDE_DIRS PUBLIC Algorithms/ITKUltrasound + INCLUDE_DIRS PUBLIC Algorithms/ITKUltrasound Algorithms INTERNAL_INCLUDE_DIRS ${INCLUDE_DIRS_INTERNAL} PACKAGE_DEPENDS ITK|ITKFFT+ITKImageCompose+ITKImageIntensity ) diff --git a/Modules/PhotoacousticsAlgorithms/mitkPhotoacousticImage.cpp b/Modules/PhotoacousticsAlgorithms/mitkPhotoacousticImage.cpp index be9835e6f0..b5362fa7bb 100644 --- a/Modules/PhotoacousticsAlgorithms/mitkPhotoacousticImage.cpp +++ b/Modules/PhotoacousticsAlgorithms/mitkPhotoacousticImage.cpp @@ -1,292 +1,292 @@ /*=================================================================== 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 "Algorithms/ITKUltrasound/itkBModeImageFilter.h" -#include "Algorithms/itkPhotoacousticBModeImageFilter.h" +#include "itkBModeImageFilter.h" +#include "itkPhotoacousticBModeImageFilter.h" #include "mitkImageCast.h" #include "mitkITKImageImport.h" -#include "Algorithms/mitkPhotoacousticBeamformingDASFilter.h" -#include "Algorithms/mitkPhotoacousticBeamformingDMASFilter.h" +#include "mitkPhotoacousticBeamformingDASFilter.h" +#include "mitkPhotoacousticBeamformingDMASFilter.h" #include #include // itk dependencies #include "itkImage.h" #include "itkResampleImageFilter.h" #include "itkCastImageFilter.h" #include "itkCropImageFilter.h" #include "itkRescaleIntensityImageFilter.h" #include "itkIntensityWindowingImageFilter.h" #include #include "itkMultiplyImageFilter.h" #include "itkBSplineInterpolateImageFunction.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, unsigned int outputSize[3]) { typedef itk::Image< double, 3 > itkFloatImageType; typedef itk::ResampleImageFilter < itkFloatImageType, itkFloatImageType > ResampleImageFilter; ResampleImageFilter::Pointer resampleImageFilter = ResampleImageFilter::New(); typedef itk::LinearInterpolateImageFunction T_Interpolator; itkFloatImageType::Pointer itkImage; mitk::CastToItkImage(inputImage, itkImage); itkFloatImageType::SpacingType inputSpacing = itkImage->GetSpacing(); itkFloatImageType::SpacingType outputSpacingItk; itkFloatImageType::SizeType inputSizeItk = itkImage->GetLargestPossibleRegion().GetSize(); itkFloatImageType::SizeType outputSizeItk = inputSizeItk; outputSizeItk[0] = outputSize[0]; outputSizeItk[1] = outputSize[1]; outputSizeItk[2] = outputSize[2]; outputSpacingItk[0] = itkImage->GetSpacing()[0] * (static_cast(inputSizeItk[0]) / static_cast(outputSizeItk[0])); outputSpacingItk[1] = itkImage->GetSpacing()[1] * (static_cast(inputSizeItk[1]) / static_cast(outputSizeItk[1])); outputSpacingItk[2] = itkImage->GetSpacing()[2] * (static_cast(inputSizeItk[2]) / static_cast(outputSizeItk[2])); typedef itk::IdentityTransform TransformType; T_Interpolator::Pointer _pInterpolator = T_Interpolator::New(); resampleImageFilter->SetInput(itkImage); resampleImageFilter->SetSize(outputSizeItk); resampleImageFilter->SetOutputSpacing(outputSpacingItk); resampleImageFilter->SetTransform(TransformType::New()); resampleImageFilter->SetInterpolator(_pInterpolator); resampleImageFilter->UpdateLargestPossibleRegion(); return mitk::GrabItkImageMemory(resampleImageFilter->GetOutput()); } mitk::Image::Pointer mitk::PhotoacousticImage::ApplyCropping(mitk::Image::Pointer inputImage, int above, int below, int right, int left) { double* inputData = new double[inputImage->GetDimension(0)*inputImage->GetDimension(1)*inputImage->GetDimension(2)]; double* outputData = new double[(inputImage->GetDimension(0) - left - right)*(inputImage->GetDimension(1) - above - below)*inputImage->GetDimension(2)]; unsigned int inputDim[3] = { inputImage->GetDimension(0), inputImage->GetDimension(1), inputImage->GetDimension(2) }; unsigned int outputDim[3] = { inputImage->GetDimension(0) - left - right, inputImage->GetDimension(1) - above - below, inputImage->GetDimension(2) }; ImageReadAccessor acc(inputImage); if (inputImage->GetPixelType().GetTypeAsString() == "scalar (double)" || inputImage->GetPixelType().GetTypeAsString() == " (double)") { inputData = (double*)acc.GetData(); } else if (inputImage->GetPixelType().GetTypeAsString() == "scalar (short)" || inputImage->GetPixelType().GetTypeAsString() == " (short)") { short* inputPuffer = (short*)acc.GetData(); for (int sl = 0; sl < inputDim[2]; ++sl) { for (int l = 0; l < inputDim[0]; ++l) { for (int s = 0; s < inputDim[1]; ++s) { inputData[l*inputDim[1] + s + sl*inputDim[0]*inputDim[1]] = (double)inputPuffer[l*inputDim[1] + s + sl*inputDim[0]*inputDim[1]]; } } } } else if (inputImage->GetPixelType().GetTypeAsString() == "scalar (float)" || inputImage->GetPixelType().GetTypeAsString() == " (float)") { float* inputPuffer = (float*)acc.GetData(); for (int sl = 0; sl < inputDim[2]; ++sl) { for (int l = 0; l < inputDim[0]; ++l) { for (int s = 0; s < inputDim[1]; ++s) { inputData[l*inputDim[1] + s + sl*inputDim[0]*inputDim[1]] = (double)inputPuffer[l*inputDim[1] + s + sl*inputDim[0]*inputDim[1]]; } } } } else { MITK_INFO << "Could not determine pixel type"; } for (int sl = 0; sl < outputDim[2]; ++sl) { for (int l = 0; l < outputDim[0]; ++l) { for (int s = 0; s < outputDim[1]; ++s) { outputData[l + s*(unsigned short)outputDim[0] +sl*outputDim[0]*outputDim[1]] = inputData[(l + left) + (s + above)*(unsigned short)inputDim[0] + sl*inputDim[0]*inputDim[1]]; } } } mitk::Image::Pointer output = mitk::Image::New(); output->Initialize(mitk::MakeScalarPixelType(), 3, outputDim); output->SetSpacing(inputImage->GetGeometry()->GetSpacing()); for (int slice = 0; slice < outputDim[2]; ++slice) { output->SetSlice(&outputData[slice*outputDim[0] * outputDim[1]], slice); } return output; /*mitk::AutoCropImageFilter::Pointer cropFilter = mitk::AutoCropImageFilter::New(); itk::ImageRegion<3> cropRegion; itk::Index<3> index = { left, above, 0 }; itk::Size<3> size = { inputImage->GetDimension(0) - left - right, inputImage->GetDimension(1) - above - below, inputImage->GetDimension(2) }; cropRegion.SetIndex(index); cropRegion.SetSize(size); cropFilter->SetInput(inputImage); cropFilter->SetCroppingRegion(cropRegion); cropFilter->Update(); return cropFilter->GetOutput();*/ } mitk::Image::Pointer mitk::PhotoacousticImage::ApplyBeamformingDAS(mitk::Image::Pointer inputImage, BeamformingDASFilter::beamformingSettings config, int cutoff, std::function progressHandle) { config.RecordTime = config.RecordTime - cutoff / inputImage->GetDimension(1) * config.RecordTime; // adjust the recorded time lost by cropping Image::Pointer croppedImage = ApplyCropping(inputImage, cutoff, 0, 0, 0); Image::Pointer resizedImage = croppedImage; if (inputImage->GetDimension(0) != config.ReconstructionLines) { auto begin = std::chrono::high_resolution_clock::now(); unsigned int dim[3] = { config.ReconstructionLines, croppedImage->GetDimension(1), croppedImage->GetDimension(2) }; resizedImage = ApplyResampling(croppedImage, dim); auto end = std::chrono::high_resolution_clock::now(); MITK_INFO << "Upsampling from " << inputImage->GetDimension(0) << " to " << config.ReconstructionLines << " lines completed in " << ((double)std::chrono::duration_cast(end - begin).count()) / 1000000 << "ms" << std::endl; } BeamformingDASFilter::Pointer Beamformer = BeamformingDASFilter::New(); Beamformer->SetInput(resizedImage); Beamformer->Configure(config); Beamformer->SetProgressHandle(progressHandle); Beamformer->UpdateLargestPossibleRegion(); return Beamformer->GetOutput(); } mitk::Image::Pointer mitk::PhotoacousticImage::ApplyBeamformingDMAS(mitk::Image::Pointer inputImage, BeamformingDMASFilter::beamformingSettings config, int cutoff, std::function progressHandle) { config.RecordTime = config.RecordTime - cutoff / inputImage->GetDimension(1) * config.RecordTime; // adjust the recorded time lost by cropping Image::Pointer croppedImage = ApplyCropping(inputImage, cutoff, 0, 0, 0); Image::Pointer resizedImage = croppedImage; if(inputImage->GetDimension(0) != config.ReconstructionLines) { auto begin = std::chrono::high_resolution_clock::now(); unsigned int dim[3] = { config.ReconstructionLines, croppedImage->GetDimension(1), croppedImage->GetDimension(2) }; resizedImage = ApplyResampling(croppedImage, dim); auto end = std::chrono::high_resolution_clock::now(); MITK_INFO << "Upsampling from " << inputImage->GetDimension(0) << " to " << config.ReconstructionLines << " lines completed in " << ((double)std::chrono::duration_cast(end - begin).count()) / 1000000 << "ms" << std::endl; } BeamformingDMASFilter::Pointer Beamformer = BeamformingDMASFilter::New(); Beamformer->SetInput(resizedImage); Beamformer->Configure(config); Beamformer->SetProgressHandle(progressHandle); Beamformer->UpdateLargestPossibleRegion(); return Beamformer->GetOutput(); -} \ No newline at end of file +} 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 b2f989509c..85617f597c 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,405 +1,405 @@ /*=================================================================== 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 #include //mitk image #include #include "mitkPhotoacousticImage.h" -#include "Algorithms\mitkPhotoacousticBeamformingDASFilter.h" -#include "Algorithms\mitkPhotoacousticBeamformingDMASFilter.h" +#include "mitkPhotoacousticBeamformingDASFilter.h" +#include "mitkPhotoacousticBeamformingDMASFilter.h" //other #include #include 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())); connect(m_Controls.buttonApplyBeamforming, SIGNAL(clicked()), this, SLOT(ApplyBeamforming())); connect(m_Controls.UseImageSpacing, SIGNAL(clicked()), this, SLOT(UseImageSpacing())); connect(m_Controls.ScanDepth, SIGNAL(valueChanged(double)), this, SLOT(UpdateFrequency())); connect(m_Controls.SpeedOfSound, SIGNAL(valueChanged(double)), this, SLOT(UpdateFrequency())); connect(m_Controls.Samples, SIGNAL(valueChanged(double)), this, SLOT(UpdateFrequency())); connect(m_Controls.UseImageSpacing, SIGNAL(clicked), this, SLOT(UpdateFrequency())); m_Controls.DoResampling->setChecked(false); m_Controls.ResamplingValue->setEnabled(false); m_Controls.progressBar->setMinimum(0); m_Controls.progressBar->setMaximum(100); m_Controls.progressBar->setVisible(false); UseImageSpacing(); } void PAImageProcessing::UpdateFrequency() { DMASconfig.SpeedOfSound = m_Controls.SpeedOfSound->value(); // [m/s] DMASconfig.SamplesPerLine = m_Controls.Samples->value(); QList nodes = this->GetDataManagerSelection(); if (nodes.empty()) return; mitk::DataNode::Pointer node = nodes.front(); if (!node) { // Nothing selected if (!m_Controls.UseImageSpacing->isChecked()) UpdateRecordTime(mitk::Image::New()); 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) UpdateRecordTime(image); } std::stringstream frequency; frequency << 1 / (DMASconfig.RecordTime / DMASconfig.SamplesPerLine) * DMASconfig.SamplesPerLine / 2 / 2 / 1000; frequency << "Hz"; m_Controls.BPInfoDisplay->setText(frequency.str().c_str()); } 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 ); UpdateFrequency(); 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(); auto newNode = mitk::DataNode::New(); mitk::PhotoacousticImage::Pointer filterbank = mitk::PhotoacousticImage::New(); newNode->SetData(filterbank->ApplyBmodeFilter(image, m_UseLogfilter, m_ResampleSpacing)); // update level window for the current dynamic range mitk::LevelWindow levelWindow; newNode->GetLevelWindow(levelWindow); data = newNode->GetData(); levelWindow.SetAuto(dynamic_cast(data),true,true); newNode->SetLevelWindow(levelWindow); // name the new Data node std::stringstream newNodeName; if (node->GetName(name)) { // a property called "name" was found for this DataNode newNodeName << name << ", "; } newNodeName << "B-Mode"; newNode->SetName(newNodeName.str()); // add new node to data storage this->GetDataStorage()->Add(newNode); // update rendering mitk::RenderingManager::GetInstance()->InitializeViews( dynamic_cast(data)->GetGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } } void PAImageProcessing::ApplyBeamforming() { QList nodes = this->GetDataManagerSelection(); if (nodes.empty()) return; mitk::DataStorage::Pointer storage = this->GetDataStorage(); 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) { UpdateBFSettings(image); std::stringstream message; std::string name; message << "Performing beamforming 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(); auto newNode = mitk::DataNode::New(); m_Controls.progressBar->setValue(0); m_Controls.progressBar->setVisible(true); auto q_app = qApp; std::function progressHandle = [&q_app = q_app, &m_Controls = m_Controls](int progress) { if(progress < 100) m_Controls.progressBar->setValue(progress); else m_Controls.progressBar->setValue(100); q_app->processEvents(); }; if(m_CurrentBeamformingAlgorithm == BeamformingAlgorithms::DAS) newNode->SetData(filterbank->ApplyBeamformingDAS(image, DASconfig, m_Controls.Cutoff->value(), progressHandle)); else if(m_CurrentBeamformingAlgorithm == BeamformingAlgorithms::DMAS) newNode->SetData(filterbank->ApplyBeamformingDMAS(image, DMASconfig, m_Controls.Cutoff->value(), progressHandle)); // name the new Data node std::stringstream newNodeName; if (node->GetName(name)) { // a property called "name" was found for this DataNode newNodeName << name << ", "; } if (m_CurrentBeamformingAlgorithm == BeamformingAlgorithms::DAS) newNodeName << "DAS beamformed, "; else if (m_CurrentBeamformingAlgorithm == BeamformingAlgorithms::DMAS) newNodeName << "DMAS beamformed, "; if (DASconfig.DelayCalculationMethod == mitk::BeamformingDASFilter::beamformingSettings::DelayCalc::Linear) newNodeName << "linear delay"; if (DASconfig.DelayCalculationMethod == mitk::BeamformingDASFilter::beamformingSettings::DelayCalc::QuadApprox) newNodeName << "quadratic delay"; if (DASconfig.DelayCalculationMethod == mitk::BeamformingDASFilter::beamformingSettings::DelayCalc::Spherical) newNodeName << "spherical delay"; newNode->SetName(newNodeName.str()); // update level window for the current dynamic range mitk::LevelWindow levelWindow; newNode->GetLevelWindow(levelWindow); data = newNode->GetData(); levelWindow.SetAuto(dynamic_cast(data), true, true); newNode->SetLevelWindow(levelWindow); // add new node to data storage this->GetDataStorage()->Add(newNode); // disable progress bar m_Controls.progressBar->setVisible(false); // update rendering mitk::RenderingManager::GetInstance()->InitializeViews( dynamic_cast(data)->GetGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } } void PAImageProcessing::UpdateBFSettings(mitk::Image::Pointer image) { if ("Delay and Sum" == m_Controls.BFAlgorithm->currentText()) m_CurrentBeamformingAlgorithm = BeamformingAlgorithms::DAS; else if ("Delay, Multiply and Sum" == m_Controls.BFAlgorithm->currentText()) m_CurrentBeamformingAlgorithm = BeamformingAlgorithms::DMAS; if ("Linear Waves" == m_Controls.DelayCalculation->currentText()) { DASconfig.DelayCalculationMethod = mitk::BeamformingDASFilter::beamformingSettings::DelayCalc::Linear; DMASconfig.DelayCalculationMethod = mitk::BeamformingDMASFilter::beamformingSettings::DelayCalc::Linear; } else if ("Quadratic Approximation to Spherical Waves" == m_Controls.DelayCalculation->currentText()) { DASconfig.DelayCalculationMethod = mitk::BeamformingDASFilter::beamformingSettings::DelayCalc::QuadApprox; DMASconfig.DelayCalculationMethod = mitk::BeamformingDMASFilter::beamformingSettings::DelayCalc::QuadApprox; } else if ("Spherical Waves" == m_Controls.DelayCalculation->currentText()) { DASconfig.DelayCalculationMethod = mitk::BeamformingDASFilter::beamformingSettings::DelayCalc::Spherical; DMASconfig.DelayCalculationMethod = mitk::BeamformingDMASFilter::beamformingSettings::DelayCalc::Spherical; } DASconfig.Pitch = m_Controls.Pitch->value() / 1000; // [m] DASconfig.SpeedOfSound = m_Controls.SpeedOfSound->value(); // [m/s] DASconfig.SamplesPerLine = m_Controls.Samples->value(); DASconfig.ReconstructionLines = m_Controls.Lines->value(); DASconfig.TransducerElements = m_Controls.ElementCount->value(); DASconfig.Angle = m_Controls.Angle->value(); DASconfig.BPHighPass = 1000000 * m_Controls.BPhigh->value(); DASconfig.BPLowPass = 1000000 * (1 / (DMASconfig.RecordTime / DMASconfig.SamplesPerLine) * DMASconfig.SamplesPerLine / 2 / 2 / 1000 / 1000000 - m_Controls.BPlow->value()); DASconfig.BPFalloff = m_Controls.BPFalloff->value(); DASconfig.UseBP = m_Controls.UseBP->isChecked(); DMASconfig.Pitch = m_Controls.Pitch->value() / 1000; // [m] DMASconfig.SpeedOfSound = m_Controls.SpeedOfSound->value(); // [m/s] DMASconfig.SamplesPerLine = m_Controls.Samples->value(); DMASconfig.ReconstructionLines = m_Controls.Lines->value(); DMASconfig.TransducerElements = m_Controls.ElementCount->value(); DMASconfig.Angle = m_Controls.Angle->value(); DMASconfig.BPHighPass = 1000000 * m_Controls.BPhigh->value(); DMASconfig.BPLowPass = 1000000 * (1 / (DMASconfig.RecordTime / DMASconfig.SamplesPerLine) * DMASconfig.SamplesPerLine / 2 / 2 / 1000 /1000000 - m_Controls.BPlow->value()); DMASconfig.BPFalloff = m_Controls.BPFalloff->value(); DMASconfig.UseBP = m_Controls.UseBP->isChecked(); UpdateRecordTime(image); } void PAImageProcessing::UpdateRecordTime(mitk::Image::Pointer image) { if (m_Controls.UseImageSpacing->isChecked()) { DASconfig.RecordTime = image->GetDimension(1)*image->GetGeometry()->GetSpacing()[1] / 1000000; // [s] DMASconfig.RecordTime = image->GetDimension(1)*image->GetGeometry()->GetSpacing()[1] / 1000000; // [s] MITK_INFO << "Calculated Scan Depth of " << DASconfig.RecordTime * DASconfig.SpeedOfSound * 100 << "cm"; } else { DASconfig.RecordTime = m_Controls.ScanDepth->value() / 1000 / DASconfig.SpeedOfSound; // [s] DMASconfig.RecordTime = m_Controls.ScanDepth->value() / 1000 / DMASconfig.SpeedOfSound; // [s] } if ("Ultrasound Image" == m_Controls.ImageType->currentText()) { if (m_Controls.UseImageSpacing->isChecked()) { DASconfig.RecordTime = DASconfig.RecordTime / 2; // [s] DMASconfig.RecordTime = DMASconfig.RecordTime / 2; // [s] } DASconfig.Photoacoustic = false; DMASconfig.Photoacoustic = false; } else { DASconfig.Photoacoustic = true; DMASconfig.Photoacoustic = true; } } void PAImageProcessing::UseImageSpacing() { if (m_Controls.UseImageSpacing->isChecked()) { m_Controls.ScanDepth->setDisabled(true); } else { m_Controls.ScanDepth->setEnabled(true); } -} \ No newline at end of file +} 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 b24bf45e42..2c8ed5aef4 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,80 +1,80 @@ /*=================================================================== 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" -#include "Algorithms\mitkPhotoacousticBeamformingDASFilter.h" -#include "Algorithms\mitkPhotoacousticBeamformingDMASFilter.h" +#include "mitkPhotoacousticBeamformingDASFilter.h" +#include "mitkPhotoacousticBeamformingDMASFilter.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 UseResampling(); void UseLogfilter(); void SetResampling(); void UseImageSpacing(); void UpdateFrequency(); void UpdateRecordTime(mitk::Image::Pointer image); void ApplyBModeFilter(); void ApplyBeamforming(); 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; mitk::BeamformingDMASFilter::beamformingSettings DMASconfig; mitk::BeamformingDASFilter::beamformingSettings DASconfig; enum BeamformingAlgorithms {DAS, DMAS}; BeamformingAlgorithms m_CurrentBeamformingAlgorithm; void UpdateBFSettings(mitk::Image::Pointer image); }; #endif // PAImageProcessing_h