Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neurofeedbackplugin #885

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
539 changes: 539 additions & 0 deletions applications/mne_scan/libs/scDisp/realtimeneurofeedbackwidget.cpp

Large diffs are not rendered by default.

228 changes: 228 additions & 0 deletions applications/mne_scan/libs/scDisp/realtimeneurofeedbackwidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
//=============================================================================================================
/**
* @file realtimeneurofeedbackwidget.h
* @author Simon Marxgut <[email protected]>
* @since 0.1.0
* @date November, 2021
*
* @section LICENSE
*
* Copyright (C) 2021, Simon Marxgut. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that
* the following conditions are met:
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * Neither the name of MNE-CPP authors nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*
* @brief Declaration of the RealTimeNeurofeedbackWidget Class.
*
*/

#ifndef REALTIMENEUROFEEDBACKWIDGET_H
#define REALTIMENEUROFEEDBACKWIDGET_H

//=============================================================================================================
// INCLUDES
//=============================================================================================================

#include "scdisp_global.h"
#include "measurementwidget.h"


//=============================================================================================================
// EIGEN INCLUDES
//=============================================================================================================

#include <Eigen/Core>

//=============================================================================================================
// QT INCLUDES
//=============================================================================================================

#include <QSharedPointer>
#include <QVector>
#include <QPointer>
#include <QMap>
#include <QSlider>
#include <QLabel>
#include <QGridLayout>

//=============================================================================================================
// FORWARD DECLARATIONS
//=============================================================================================================

namespace DISPLIB {
class ChannelSelectionView;
class ChannelInfoModel;
class RtFiffRawView;
class ChannelDataViewNew;
}

namespace FIFFLIB {
class FiffInfo;
}

namespace SCMEASLIB{
class RealTimeNeurofeedbackResult;
class RealTimeSampleArrayChInfo;
}


//=============================================================================================================
// DEFINE NAMESPACE SCDISPLIB
//=============================================================================================================

namespace SCDISPLIB
{

//=============================================================================================================
// SCDISPLIB FORWARD DECLARATIONS
//=============================================================================================================

//=============================================================================================================
/**
* DECLARE CLASS RealTimeMultiSampleArrayWidget
*
* @brief The RealTimeMultiSampleArrayWidget class provides a real-time curve display.
*/
class SCDISPSHARED_EXPORT RealTimeNeurofeedbackWidget : public MeasurementWidget
{
Q_OBJECT

public:
//=========================================================================================================
/**
* Constructs a RealTimeMultiSampleArrayWidget which is a child of parent.
*
* @param [in] pTime pointer to application time.
* @param [in] parent pointer to parent widget; If parent is 0, the new NumericWidget becomes a window. If parent is another widget, NumericWidget becomes a child window inside parent. NumericWidget is deleted when its parent is deleted.
*/
RealTimeNeurofeedbackWidget(QSharedPointer<QTime> &pTime,
QWidget* parent = 0);

//=========================================================================================================
/**
* Destroys the RealTimeNeurofeedbackWidget.
*/
~RealTimeNeurofeedbackWidget();

//=========================================================================================================
/**
* Initialise the MeasurementWidget.
*/
virtual void init(){}

//=========================================================================================================
/**
* Is called when new data are available.
*
* @param [in] pMeasurement pointer to measurement -> not used because its direct attached to the measurement.
*/
virtual void update(SCMEASLIB::Measurement::SPtr pMeasurement);

//=========================================================================================================
/**
* Update the OpenGL viewport. This, e.g., necessary if this widget was set to a QDockWidget which changes
* its floating state.
*/
void updateOpenGLViewport();


private:
//=========================================================================================================
/**
* Initialise the display control widgets to be shown in the QuickControlView.
*/
void initDisplayControllWidgets();

//=========================================================================================================
/**
* Shows sensor selection widget
*/
void showSensorSelectionWidget();

//=========================================================================================================
/**
* Call this slot whenever you want to make a screenshot current view.
*
* @param[in] imageType The current iamge type: png, svg.
*/
void onMakeScreenshot(const QString& imageType);

//=========================================================================================================
/**
* Toggle bad channel visibility
*/
void onHideBadChannels();

//=========================================================================================================
/**
* Update Label - Textoutput (Classification Output).
*/
void updateLabel(QString text, QString Color);

//=========================================================================================================
/**
* Update Slider (Frequency Output).
*/
void updateSlider(int slider, bool allCh, int numCh);

//=========================================================================================================
/**
* Update Imageoutput (Classification Output).
*/
void updateImage(QPixmap image);

//=========================================================================================================
/**
* Add Slider to Layout (Frequency Output).
*/
void addSlider(int value, int output, int Max, int Min);

//=========================================================================================================
/**
* clear Layout.
*/
void clearLayout(QLayout *layout);

private:
QSharedPointer<SCMEASLIB::RealTimeNeurofeedbackResult> m_pRTNR; /**< The real-time sample array measurement. */

QSharedPointer<DISPLIB::QuickControlView> m_pQuickControlView; /**< quick control widget. */
QSharedPointer<DISPLIB::ChannelInfoModel> m_pChannelInfoModel; /**< channel info model. */
QSharedPointer<DISPLIB::ChannelSelectionView> m_pChannelSelectionView; /**< ChannelSelectionView. */
QPointer<DISPLIB::RtFiffRawView> m_pChannelDataView; /**< the QTableView being part of the model/view framework of Qt. */
QSharedPointer<FIFFLIB::FiffInfo> m_pFiffInfo; /**< FiffInfo, which is used insteadd of ListChInfo*/

QPointer<QAction> m_pActionHideBad; /**< Hide bad channels. */

qint32 m_iMaxFilterTapSize; /**< Maximum number of allowed filter taps. This number depends on the size of the receiving blocks. */

Eigen::MatrixXd m_matNeurofeedbackData;
QGridLayout * m_pLayout;

Eigen::MatrixXd m_iClassification;

QString m_sOutput;




};
} // NAMESPACE SCDISPLIB

#endif // REALTIMENEUROFEEDBACKWIDGET_H
2 changes: 2 additions & 0 deletions applications/mne_scan/libs/scDisp/scDisp.pro
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ SOURCES += \
realtimemultisamplearraywidget.cpp \
realtimeevokedsetwidget.cpp \
realtimecovwidget.cpp \
realtimeneurofeedbackwidget.cpp \
realtimespectrumwidget.cpp \
realtime3dwidget.cpp \

HEADERS += \
realtimeneurofeedbackwidget.h \
scdisp_global.h \
measurementwidget.h \
realtimemultisamplearraywidget.h \
Expand Down
2 changes: 2 additions & 0 deletions applications/mne_scan/libs/scMeas/measurementtypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "realtimesamplearraychinfo.h"
#include "realtimecov.h"
#include "realtimeevokedset.h"
#include "realtimeneurofeedbackresult.h"

//=============================================================================================================
// USED NAMESPACES
Expand Down Expand Up @@ -77,4 +78,5 @@ void MeasurementTypes::registerTypes()
qRegisterMetaType< RealTimeCov::SPtr >("RealTimeCov::SPtr");
qRegisterMetaType< RealTimeEvokedSet::SPtr >("RealTimeEvokedSet::SPtr");
qRegisterMetaType< RealTimeSampleArrayChInfo::SPtr >("RealTimeSampleArrayChInfo::SPtr");
qRegisterMetaType< RealTimeNeurofeedbackResult::SPtr >("RealTimeNeurofeedbackResult::SPtr");
}
Loading