diff --git a/Modules/PhotoacousticsLib/include/mitkPASpectralUnmixingFilter.h b/Modules/PhotoacousticsLib/include/mitkPASpectralUnmixingFilter.h index 95b9c3f905..c163cf30ea 100644 --- a/Modules/PhotoacousticsLib/include/mitkPASpectralUnmixingFilter.h +++ b/Modules/PhotoacousticsLib/include/mitkPASpectralUnmixingFilter.h @@ -1,57 +1,59 @@ /*=================================================================== 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 MITKPHOTOACOUSTICSPECTRALUNMIXINGFILTER_H #define MITKPHOTOACOUSTICSPECTRALUNMIXINGFILTER_H #include "mitkImageToImageFilter.h" //Includes for smart pointer usage #include "mitkCommon.h" #include "itkLightObject.h" #include namespace mitk { namespace pa { class MITKPHOTOACOUSTICSLIB_EXPORT SpectralUnmixingFilter : public mitk::ImageToImageFilter { public: mitkClassMacro(SpectralUnmixingFilter, mitk::ImageToImageFilter) itkFactorylessNewMacro(Self) //Contains all (so far) possible chromophores enum ChromophoreType { OXYGENATED, DEOXYGENATED }; - void AddWavelength(int wavelength); void Test(); + + /* for add wavelengths + void AddWavelength(int wavelength); std::vector m_Wavelengths; - int size; + int size; */ protected: SpectralUnmixingFilter(); virtual ~SpectralUnmixingFilter(); private: }; } } #endif // MITKPHOTOACOUSTICSPECTRALUNMIXINGFILTER_H diff --git a/Modules/PhotoacousticsLib/src/SUFilter/mitkPASpectralUnmixingFilter.cpp b/Modules/PhotoacousticsLib/src/SUFilter/mitkPASpectralUnmixingFilter.cpp index ee9249bf9f..f03b1c2a28 100644 --- a/Modules/PhotoacousticsLib/src/SUFilter/mitkPASpectralUnmixingFilter.cpp +++ b/Modules/PhotoacousticsLib/src/SUFilter/mitkPASpectralUnmixingFilter.cpp @@ -1,96 +1,87 @@ /*=================================================================== 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 "mitkPASpectralUnmixingFilter.h" #include #include mitk::pa::SpectralUnmixingFilter::SpectralUnmixingFilter() { } mitk::pa::SpectralUnmixingFilter::~SpectralUnmixingFilter() { } void mitk::pa::SpectralUnmixingFilter::Test() { MITK_INFO << "Test"; } -void mitk::pa::SpectralUnmixingFilter::AddWavelength(int wavelength) -{ - - //MITK_INFO << "m_w" << m_Wavelengths[size]; - - /*if (m_Wavelengths.empty()) - { - size = 0; - }*/ - //MITK_INFO << "size after if empty: " << size; - //MITK_INFO << "ADD WAVELENGTH..."; - MITK_INFO << "begin size: " << size; - m_Wavelengths.push_back(wavelength); - MITK_INFO << "inhalt vector size: " << m_Wavelengths[size]; - MITK_INFO << "inhalt vector 0: " << m_Wavelengths[0]; - MITK_INFO << "inhalt vector 10: " << m_Wavelengths[10]; - int foo = size; - size = foo + 1; - MITK_INFO << "end size: " << size; -} +//// Not correct working alternativ for wavelengths +/*void mitk::pa::SpectralUnmixingFilter::AddWavelength(int wavelength) +{ + // Das ganze klappt noch nicht so! m_wavelengths wird nicht gespeichert ... + if (m_Wavelengths.empty()) + { + size = 0; + } + m_Wavelengths.push_back(wavelength); + size += 1; +}*/ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // VERWORFENES ZEUG: /* void mitk::pa::SpectralUnmixingFilter::GetInputPictures() { MITK_INFO << "GET INPUT PICTURES..."; unsigned int numberOfInputs = GetNumberOfIndexedInputs(); unsigned int numberOfOutputs = GetNumberOfIndexedOutputs(); MITK_INFO << "Inputs: " << numberOfInputs << " Outputs: " << numberOfOutputs; if (m_Wavelengths.empty() || m_Wavelengths.size() != numberOfInputs || numberOfInputs < m_Chromophores.size()) { std::string invalidWavelengthError = "Not enough wavelengths given for calculation."; MITK_ERROR << invalidWavelengthError; mitkThrow() << invalidWavelengthError; } MITK_INFO << "LOADING...[DONE]"; } void mitk::pa::SpectralUnmixingFilter::AddChromophore(int chromophore) { MITK_INFO << "ADD CHROMOPHORE..."; m_Chromophores.push_back(chromophore); } Probably easier to implement in the Plugin like: if (slot x then do algorithm x) void mitk::pa::SpectralUnmixingFilter::ChooseAlgorithm(int algorithm) { MITK_INFO << "CHOOSE ALGORITHM..."; m_Chromophores.push_back(algorithm); }*/ diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.spectralunmixing/src/internal/SpectralUnmixing.cpp b/Plugins/org.mitk.gui.qt.photoacoustics.spectralunmixing/src/internal/SpectralUnmixing.cpp index 975f612306..bee296101c 100644 --- a/Plugins/org.mitk.gui.qt.photoacoustics.spectralunmixing/src/internal/SpectralUnmixing.cpp +++ b/Plugins/org.mitk.gui.qt.photoacoustics.spectralunmixing/src/internal/SpectralUnmixing.cpp @@ -1,150 +1,170 @@ /*=================================================================== 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 "SpectralUnmixing.h" // Qt #include // mitk image #include // to perform Spectral Unmixing #include "mitkPASpectralUnmixingFilter.h" const std::string SpectralUnmixing::VIEW_ID = "org.mitk.views.spectralunmixing"; void SpectralUnmixing::SetFocus() { m_Controls.buttonPerformImageProcessing->setFocus(); } void SpectralUnmixing::CreateQtPartControl(QWidget *parent) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi(parent); connect(m_Controls.buttonPerformImageProcessing, &QPushButton::clicked, this, &SpectralUnmixing::DoImageProcessing); connect(m_Controls.ButtonAddWavelength, &QPushButton::clicked, this, &SpectralUnmixing::Wavelength); - } +} +// Add Wavelength is working, BUT in the Plugin! Not with same implementation at the filter +// probably because the m_wavelengths vector is created new every time and not 'saved'. +// Alternativ as comment here and at the filter. void SpectralUnmixing::Wavelength() +{ + if (m_Wavelengths.empty()) + { + size = 0; + } + + wavelength = m_Controls.spinBoxAddWavelength->value(); + m_Wavelengths.push_back(wavelength); + MITK_INFO << "ADD WAVELENGTH: " << wavelength << "nm"; + size += 1; // size implemented like this because '.size' is const + MITK_INFO << "ALL WAVELENGTHS: "; + + for (int i = 0; i < size; ++i) + { + MITK_INFO << m_Wavelengths[i] << "nm"; + } +} + +// Not correct working alternativ for wavelengths +/*void SpectralUnmixing::Wavelength() { auto m_SpectralUnmixingFilter = mitk::pa::SpectralUnmixingFilter::New(); wavelength = m_Controls.spinBoxAddWavelength->value(); m_SpectralUnmixingFilter->AddWavelength(wavelength); MITK_INFO << wavelength << " nm"; -} +}*/ void SpectralUnmixing::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.buttonPerformImageProcessing->setEnabled(true); return; } } m_Controls.labelWarning->setVisible(true); m_Controls.buttonPerformImageProcessing->setEnabled(false); } void SpectralUnmixing::DoImageProcessing() { QList nodes = this->GetDataManagerSelection(); if (nodes.empty()) return; mitk::DataNode *node = nodes.front(); if (!node) { // Nothing selected. Inform the user and return QMessageBox::information(nullptr, "Template", "Please load and select an image before starting image processing."); return; } // here we have a valid mitk::DataNode // a node itself is not very useful, we need its data item (the image) 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 SPECTRAL UNMIXING (SOON)"; if (node->GetName(name)) { // a property called "name" was found for this DataNode message << "'" << name << "'"; } message << "."; MITK_INFO << message.str(); // actually do something here... // Checking which chromophores wanted for SU if none throw exeption! numberofChromophores = 0; DeOxbool = m_Controls.checkBoxDeOx->isChecked(); Oxbool = m_Controls.checkBoxOx->isChecked(); if (DeOxbool || Oxbool == true) { MITK_INFO << "CHOSEN CHROMOPHORES:"; } if (Oxbool == true) { numberofChromophores += 1; MITK_INFO << "- Oxyhemoglobin"; } if (DeOxbool == true) { numberofChromophores += 1; MITK_INFO << "- Deoxygenated hemoglobin"; } if (numberofChromophores == 0) { mitkThrow() << "PRESS 'IGNORE' AND CHOOSE A CHROMOPHORE!"; } - // to do: number of wavelengths has to be larger then checked chromophores ;) - - //TEST STUFF: - auto m_SpectralUnmixingFilter = mitk::pa::SpectralUnmixingFilter::New(); - MITK_INFO << "size"<< m_SpectralUnmixingFilter->size; - - //MITK_INFO << "size" << mitk::pa::SpectralUnmixingFilter::size; - //MITK_INFO << "m_W" << mitk::pa::SpectralUnmixingFilter::m_Wavelengths; - //MITK_INFO << ".size" << mitk::pa::SpectralUnmixingFilter::m_Wavelengths.size; + // Checking if number of wavelengths >= number of chromophores + if (numberofChromophores > size) + { + mitkThrow() << "PRESS 'IGNORE' AND ADD MORE WAVELENGTHS!"; + } + } } } diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.spectralunmixing/src/internal/SpectralUnmixing.h b/Plugins/org.mitk.gui.qt.photoacoustics.spectralunmixing/src/internal/SpectralUnmixing.h index 9bd923b52c..a4d805ab56 100644 --- a/Plugins/org.mitk.gui.qt.photoacoustics.spectralunmixing/src/internal/SpectralUnmixing.h +++ b/Plugins/org.mitk.gui.qt.photoacoustics.spectralunmixing/src/internal/SpectralUnmixing.h @@ -1,71 +1,75 @@ /*=================================================================== 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 SpectralUnmixing_h #define SpectralUnmixing_h #include #include #include "ui_SpectralUnmixingControls.h" // Perform Spectral Unmixing //include "mitkPASpectralUnmixingFilter.h" //--> include does not work //solution fprr cpp file 'Just right-click on the project -> Configuration Properties -> C/C++ -> General -> Additional Include Directories.' //https://stackoverflow.com/questions/12561048/visual-studio-cannot-include-header-file /** \brief SpectralUnmixing \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class SpectralUnmixing : 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; + // Add Wavelengths with button: + int size; + std::vector m_Wavelengths; + bool DeOxbool; bool Oxbool; 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; /// \brief Called when the user clicks the GUI button void DoImageProcessing(); virtual void Wavelength(); unsigned int wavelength; unsigned int numberofChromophores; Ui::SpectralUnmixingControls m_Controls; }; #endif // SpectralUnmixing_h