diff --git a/src/applications/mne_scan/plugins/CMakeLists.txt b/src/applications/mne_scan/plugins/CMakeLists.txt index 775c74dbf69..467ba4be41f 100644 --- a/src/applications/mne_scan/plugins/CMakeLists.txt +++ b/src/applications/mne_scan/plugins/CMakeLists.txt @@ -27,6 +27,7 @@ add_subdirectory(neuronalconnectivity) add_subdirectory(writetofile) add_subdirectory(hpi) add_subdirectory(rtfwd) +add_subdirectory(playback) option(WITH_BRAINFLOW "Build brainflow plugin" OFF) option(WITH_LSL "Build LSL plugin" OFF) diff --git a/src/applications/mne_scan/plugins/playback/CMakeLists.txt b/src/applications/mne_scan/plugins/playback/CMakeLists.txt new file mode 100644 index 00000000000..bb003608389 --- /dev/null +++ b/src/applications/mne_scan/plugins/playback/CMakeLists.txt @@ -0,0 +1,80 @@ +cmake_minimum_required(VERSION 3.14) +project(scan_playback LANGUAGES CXX) + +#Handle qt uic, moc, rrc automatically +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(QT_REQUIRED_COMPONENTS Core Widgets Svg) +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS ${QT_REQUIRED_COMPONENTS}) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS ${QT_REQUIRED_COMPONENTS}) + +set(SOURCES + playback.cpp + FormFiles/playbacksetupwidget.cpp + playback_global.cpp +) + +set(HEADERS + playback_global.h + playback.h + FormFiles/playbacksetupwidget.h +) + +set(UI + FormFiles/playbacksetup.ui +) + +set(FILE_TO_UPDATE playback_global.cpp) + +set(SOURCE_PATHS ${SOURCES}) +list(TRANSFORM SOURCE_PATHS PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/") +set_source_files_properties(${FILE_TO_UPDATE} PROPERTIES OBJECT_DEPENDS "${SOURCE_PATHS}") + +add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS} ${UI}) + +set(FFTW_LIBS "") + +if(USE_FFTW) + if (WIN32) + set(FFTW_LIBS + ${FFTW_DIR_LIBS}/libfftw3-3.dll + ${FFTW_DIR_LIBS}/libfftw3f-3.dll + ${FFTW_DIR_LIBS}/libfftwf3l-3.dll + ) + target_include_directories(${PROJECT_NAME} PRIVATE ${FFTW_DIR_INCLUDE}) + elseif(UNIX AND NOT APPLE) + set(FFTW_LIBS ${FFTW_DIR_LIBS}/lib/libfftw3.so) + target_include_directories(${PROJECT_NAME} PRIVATE ${FFTW_DIR_INCLUDE}/api) + endif() +endif() + +target_include_directories(${PROJECT_NAME} PUBLIC ../) + +set(QT_REQUIRED_COMPONENT_LIBS ${QT_REQUIRED_COMPONENTS}) +list(TRANSFORM QT_REQUIRED_COMPONENT_LIBS PREPEND "Qt${QT_VERSION_MAJOR}::") + +target_link_libraries(${PROJECT_NAME} PRIVATE + ${QT_REQUIRED_COMPONENT_LIBS} + eigen + mne_disp + mne_utils + mne_fiff + mne_fs + mne_mne + mne_fwd + mne_inverse + mne_rtprocessing + mne_connectivity + mne_events + scDisp + scShared + scMeas + ${FFTW_LIBS}) + +target_compile_definitions(${PROJECT_NAME} PRIVATE SCAN_PLAYBACK_PLUGIN MNE_GIT_HASH_SHORT="${MNE_GIT_HASH_SHORT}" MNE_GIT_HASH_LONG="${MNE_GIT_HASH_LONG}") + +if(NOT BUILD_SHARED_LIBS) + target_compile_definitions(${PROJECT_NAME} PRIVATE STATICBUILD QT_STATICPLUGIN) +endif() diff --git a/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetup.ui b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetup.ui new file mode 100644 index 00000000000..5f0ec14e7f1 --- /dev/null +++ b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetup.ui @@ -0,0 +1,149 @@ + + + PlaybackSetupUi + + + + 0 + 0 + 600 + 450 + + + + DummySetupWidget + + + + + + + 75 + true + + + + Playback Configuration + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + + + + 0 + 0 + + + + + 0 + 100 + + + + File Source + + + false + + + + + + Information + + + + + + <!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:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:600;">Description:</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Stream raw data from a fiff file.</span></p> +<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; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:600;">How to setup this plugin?</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Either use the browse button to select a file, or type in a file path. Then, start MNE Scan.</span></p> +<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; font-size:8pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:600;">Input data type:</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt;">None</span></p> +<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; font-family:'MS Shell Dlg 2'; font-size:8.25pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:600;">Output data type:</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt;">This plugin streams raw data blocks to subsequent connected plugins.</span></p> +<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; font-family:'MS Shell Dlg 2'; font-size:8.25pt;"><br /></p></body></html> + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 500 + 5 + + + + + + + + + + + Browse Files + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + diff --git a/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.cpp b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.cpp new file mode 100644 index 00000000000..5317f20efc7 --- /dev/null +++ b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.cpp @@ -0,0 +1,93 @@ +//============================================================================================================= +/** + * @file playbacksetupwidget.cpp + * @author Lorenz Esch + * @since 0.1.0 + * @date February, 2020 + * + * @section LICENSE + * + * Copyright (C) 2020, Lorenz Esch. 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 Definition of the PlaybackSetupWidget class. + * + */ + +//============================================================================================================= +// INCLUDES +//============================================================================================================= + +#include "playbacksetupwidget.h" + +//============================================================================================================= +// QT INCLUDES +//============================================================================================================= + +#include + +//============================================================================================================= +// USED NAMESPACES +//============================================================================================================= + +using namespace PLAYBACKPLUGIN; + +//============================================================================================================= +// DEFINE MEMBER METHODS +//============================================================================================================= + +PlaybackSetupWidget::PlaybackSetupWidget(Playback* toolbox, QWidget *parent) +: QWidget(parent) +, m_pPlayback(toolbox) +{ + ui.setupUi(this); + connect(ui.m_qPushButton_Browse, &QPushButton::pressed, + this, &PlaybackSetupWidget::browseFiles, Qt::UniqueConnection); + connect(ui.m_lineEditSourceFile, &QLineEdit::textChanged, + this, &PlaybackSetupWidget::newSourceFileSet, Qt::UniqueConnection); +} + +//============================================================================================================= + +PlaybackSetupWidget::~PlaybackSetupWidget() +{ +} + +//============================================================================================================= + +void PlaybackSetupWidget::setSourceFile(QString filePath) +{ + ui.m_lineEditSourceFile->setText(filePath); +} + +//============================================================================================================= + +void PlaybackSetupWidget::browseFiles() +{ + QString sFilePath = QFileDialog::getOpenFileName(Q_NULLPTR, + tr("Open File"), + QString(), + tr("Fiff file (*.fif *.fiff);;Event file (*.eve)")); + + if(!sFilePath.isEmpty()){ + ui.m_lineEditSourceFile->setText(sFilePath); + } +} diff --git a/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.h b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.h new file mode 100644 index 00000000000..33ef9241fbe --- /dev/null +++ b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.h @@ -0,0 +1,107 @@ +//============================================================================================================= +/** + * @file playbacksetupwidget.h + * @author Lorenz Esch + * @since 0.1.0 + * @date February, 2020 + * + * @section LICENSE + * + * Copyright (C) 2020, Lorenz Esch. 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 Contains the declaration of the PlaybackSetupWidget class. + * + */ + +#ifndef PLAYBACKSETUPWIDGET_H +#define PLAYBACKSETUPWIDGET_H + +//============================================================================================================= +// INCLUDES +//============================================================================================================= + +#include "ui_playbacksetup.h" +#include "../playback.h" + +//============================================================================================================= +// QT INCLUDES +//============================================================================================================= + +#include + +//============================================================================================================= +// DEFINE NAMESPACE PLAYBACKPLUGIN +//============================================================================================================= + +namespace PLAYBACKPLUGIN +{ + +//============================================================================================================= +// FORWARD DECLARATIONS +//============================================================================================================= + +class Playback; + +//============================================================================================================= +/** + * DECLARE CLASS PlaybackSetupWidget + * + * @brief The PlaybackSetupWidget class provides the Playback configuration window. + */ +class PlaybackSetupWidget : public QWidget +{ + Q_OBJECT + +public: + + //========================================================================================================= + /** + * Constructs a PlaybackSetupWidget which is a child of parent. + * + * @param[in] toolbox a pointer to the corresponding Playback. + * @param[in] parent pointer to parent widget; If parent is 0, the new PlaybackSetupWidget becomes a window. If parent is another widget, PlaybackSetupWidget becomes a child window inside parent. PlaybackSetupWidget is deleted when its parent is deleted. + */ + PlaybackSetupWidget(Playback* toolbox, QWidget *parent = 0); + + //========================================================================================================= + /** + * Destroys the PlaybackSetupWidget. + * All PlaybackSetupWidget's children are deleted first. The application exits if PlaybackSetupWidget is the main widget. + */ + ~PlaybackSetupWidget(); + + void setSourceFile(QString filePath); + +private: + void browseFiles(); + + Playback* m_pPlayback; /**< Holds a pointer to corresponding Playback.*/ + + Ui::PlaybackSetupUi ui; /**< Holds the user interface for the PlaybackSetupWidget.*/ + +public: +signals: + void newSourceFileSet(QString filePath); +}; +} // NAMESPACE + +#endif // PLAYBACKSETUPWIDGET_H diff --git a/src/applications/mne_scan/plugins/playback/playback.cpp b/src/applications/mne_scan/plugins/playback/playback.cpp new file mode 100644 index 00000000000..93c9e90a4c5 --- /dev/null +++ b/src/applications/mne_scan/plugins/playback/playback.cpp @@ -0,0 +1,253 @@ +//============================================================================================================= +/** + * @file playback.cpp + * @author Gabriel B Motta + * @since 0.1.9 + * @date April, 2023 + * + * @section LICENSE + * + * Copyright (C) 2023, Gabriel B Motta. 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 Definition of the Playback class. + * + */ + +//============================================================================================================= +// INCLUDES +//============================================================================================================= + +#include "playback.h" + +#include "FormFiles/playbacksetupwidget.h" + +#include +#include +#include +#include +#include + +//============================================================================================================= +// QT INCLUDES +//============================================================================================================= + +#include + +//============================================================================================================= +// EIGEN INCLUDES +//============================================================================================================= + +//============================================================================================================= +// USED NAMESPACES +//============================================================================================================= + +using PLAYBACKPLUGIN::Playback; +using PLAYBACKPLUGIN::PlaybackSetupWidget; +using UTILSLIB::File; +using FIFFLIB::FiffStream; +using SCSHAREDLIB::AbstractSensor; +using SCSHAREDLIB::AbstractPlugin; +using SCSHAREDLIB::PluginOutputData; +using SCMEASLIB::RealTimeMultiSampleArray; + +//============================================================================================================= +// DEFINE MEMBER METHODS +//============================================================================================================= + +Playback::Playback() +{ +} + +//============================================================================================================= + +Playback::~Playback() +{ + if(this->isRunning()) { + stop(); + } +} + +//============================================================================================================= + +QSharedPointer Playback::clone() const +{ + QSharedPointer pPlaybackClone(new Playback); + return pPlaybackClone; +} + +//============================================================================================================= + +void Playback::init() +{ + m_pRTMSA_Playback = PluginOutputData::create(this, "Playback", "Playback Output"); + m_pRTMSA_Playback->measurementData()->setName(this->getName());//Provide name to auto store widget settings + m_outputConnectors.append(m_pRTMSA_Playback); +} + +//============================================================================================================= + +void Playback::unload() +{ +} + +//============================================================================================================= + +bool Playback::start() +{ + if(sourceFilePath.isEmpty()){ + qWarning() << "[Playback::start] Source path empty"; + return false; + } + + sourceFile = std::make_unique(sourceFilePath); + + if(!sourceFile->exists()){ + qWarning() << "[Playback::start] Could not find:" << sourceFilePath; + return false; + } + + if (!loadFiffRawData()){ + qWarning() << "[Playback::start] Not able to read raw info or data from:" << sourceFilePath; + return false; + } + + QThread::start(); + + return true; +} + +//============================================================================================================= + +bool Playback::stop() +{ + requestInterruption(); + wait(); + + m_bPluginControlWidgetsInit = false; + + return true; +} + +//============================================================================================================= + +AbstractPlugin::PluginType Playback::getType() const +{ + return _ISensor; +} + +//============================================================================================================= + +QString Playback::getName() const +{ + return "Playback"; +} + +//============================================================================================================= + +QWidget* Playback::setupWidget() +{ + PlaybackSetupWidget* widget = new PlaybackSetupWidget(this);//widget is later distroyed by CentralWidget - so it has to be created everytime new + + widget->setSourceFile(sourceFilePath); + + connect(widget, &PlaybackSetupWidget::newSourceFileSet, + this, &Playback::setSourceFile, Qt::UniqueConnection); + + return widget; +} + +//============================================================================================================= + +void Playback::run() +{ + initConnector(); + + int absolute_first = rawData.first_samp; + int absolute_last = rawData.last_samp; + + int bufferSize = rawData.info.sfreq; + + int first = absolute_first; + int last = absolute_first; + + Eigen::MatrixXd data; + Eigen::MatrixXd times; + + QElapsedTimer timer; + + while(!isInterruptionRequested()) { + timer.start(); + last = first + bufferSize - 1; + if(last < absolute_last){ + if(rawData.read_raw_segment(data,times,first,last)){ + m_pRTMSA_Playback->measurementData()->setValue(data); + } + } else { + break; + } + first += bufferSize; + sleep(1); + } +} + +//============================================================================================================= + +QString Playback::getBuildInfo() +{ + return QString(buildDateTime()) + QString(" - ") + QString(buildHash()); +} + +//============================================================================================================= + +void Playback::setSourceFile(QString filePath) +{ + sourceFilePath = filePath; + qDebug() << "SET:" << sourceFilePath; +} + +//============================================================================================================= + +bool Playback::loadFiffRawData() +{ + if(!FiffStream::setup_read_raw(*sourceFile, rawData)) + { + rawData.clear(); + return false; + } + + m_pFiffInfo = QSharedPointer(new FIFFLIB::FiffInfo(rawData.info)); + m_pFiffDigData = QSharedPointer(new FIFFLIB::FiffDigitizerData()); + rawData.file->read_digitizer_data(rawData.file->dirtree(), *m_pFiffDigData); + + return true; +} + +//============================================================================================================= + +void Playback::initConnector() +{ + m_pRTMSA_Playback->measurementData()->initFromFiffInfo(m_pFiffInfo); + m_pRTMSA_Playback->measurementData()->setDigitizerData(m_pFiffDigData); + m_pRTMSA_Playback->measurementData()->setMultiArraySize(1); + m_pRTMSA_Playback->measurementData()->setVisibility(true); + m_pRTMSA_Playback->measurementData()->setXMLLayoutFile(QCoreApplication::applicationDirPath() + "/../resources/mne_scan/plugins/FiffSimulator/VectorViewSimLayout.xml"); +} diff --git a/src/applications/mne_scan/plugins/playback/playback.h b/src/applications/mne_scan/plugins/playback/playback.h new file mode 100644 index 00000000000..75d121e421e --- /dev/null +++ b/src/applications/mne_scan/plugins/playback/playback.h @@ -0,0 +1,156 @@ +//============================================================================================================= +/** + * @file playback.h + * @author Gabriel B Motta + * @since 0.1.9 + * @date April, 2023 + * + * @section LICENSE + * + * Copyright (C) 2023, Gabriel B Motta. 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 Contains the declaration of the Playback class. + * + */ + +#ifndef PLAYBACK_H +#define PLAYBACK_H + +//============================================================================================================= +// INCLUDES +//============================================================================================================= + +#include "playback_global.h" + +#include +#include +#include + +#include + +//============================================================================================================= +// QT INCLUDES +//============================================================================================================= + +#include +#include +#include +#include + +//============================================================================================================= +// EIGEN INCLUDES +//============================================================================================================= + +#include + +//============================================================================================================= +// FORWARD DECLARATIONS +//============================================================================================================= + +namespace FIFFLIB{ + class FiffInfo; + class FiffStream; +} + +namespace SCMEASLIB{ + class RealTimeMultiSampleArray; +} + +//============================================================================================================= +// DEFINE NAMESPACE PLAYBACKPLUGIN +//============================================================================================================= + +namespace PLAYBACKPLUGIN +{ + +//============================================================================================================= +// PLAYBACKPLUGIN FORWARD DECLARATIONS +//============================================================================================================= + +//============================================================================================================= +/** + * DECLARE CLASS Playback + * + * @brief The Playback class provides a tools to reduce noise of an incoming data stream. It then forwards the processed data to subsequent plugins. + */ +class PLAYBACKSHARED_EXPORT Playback : public SCSHAREDLIB::AbstractSensor +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "scsharedlib/1.0" FILE "playback.json") //New Qt5 Plugin system replaces Q_EXPORT_PLUGIN2 macro + // Use the Q_INTERFACES() macro to tell Qt's meta-object system about the interfaces + Q_INTERFACES(SCSHAREDLIB::AbstractSensor) + +public: + //========================================================================================================= + /** + * Constructs a Playback. + */ + Playback(); + + //========================================================================================================= + /** + * Destroys the Playback. + */ + ~Playback(); + + //========================================================================================================= + /** + * AbstractSensorfunctions + */ + virtual QSharedPointer clone() const override; + virtual void init() override; + virtual void unload() override; + virtual bool start() override; + virtual bool stop() override; + virtual AbstractPlugin::PluginType getType() const override; + virtual QString getName() const override; + virtual QWidget* setupWidget() override; + virtual QString getBuildInfo() override; + +private: + //========================================================================================================= + /** + * AbstractAlgorithm function + */ + virtual void run(); + + bool loadFiffRawData(); + + void initConnector(); + + SCSHAREDLIB::PluginOutputData::SPtr m_pRTMSA_Playback; /**< The RealTimeMultiSampleArray to provide the rt_server Channels.*/ + + QSharedPointer m_pCircularBuffer; /**< Holds incoming raw data. */ + QString sourceFilePath; + std::unique_ptr sourceFile; + FIFFLIB::FiffRawData rawData; + + QSharedPointer m_pFiffInfo; /**< Fiff measurement info.*/ + QSharedPointer m_pFiffDigData; /**< Fiff Digitizer Data. */ + + +public slots: + void setSourceFile(QString filePath); +}; +} // NAMESPACE + +#endif // PLAYBACK_H diff --git a/src/applications/mne_scan/plugins/playback/playback.json b/src/applications/mne_scan/plugins/playback/playback.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/applications/mne_scan/plugins/playback/playback_global.cpp b/src/applications/mne_scan/plugins/playback/playback_global.cpp new file mode 100644 index 00000000000..c6b9f6a538f --- /dev/null +++ b/src/applications/mne_scan/plugins/playback/playback_global.cpp @@ -0,0 +1,54 @@ +//============================================================================================================= +/** + * @file playback_global.cpp + * @author Juan G Prieto ; + * Gabriel B Motta ; + * @since 0.1.9 + * @date September, 2021 + * + * @section LICENSE + * + * Copyright (C) 2021, Juan G Prieto, Gabriel B Motta. 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 playback plugin global definitions. + * + */ + +//============================================================================================================= +// INCLUDES +//============================================================================================================= + +#include "playback_global.h" + +//============================================================================================================= +// DEFINE METHODS +//============================================================================================================= + +const char* PLAYBACKPLUGIN::buildDateTime(){ return UTILSLIB::dateTimeNow();} + +//============================================================================================================= + +const char* PLAYBACKPLUGIN::buildHash(){ return UTILSLIB::gitHash();} + +//============================================================================================================= + +const char* PLAYBACKPLUGIN::buildHashLong(){ return UTILSLIB::gitHashLong();} diff --git a/src/applications/mne_scan/plugins/playback/playback_global.h b/src/applications/mne_scan/plugins/playback/playback_global.h new file mode 100644 index 00000000000..1cba9d3cb0d --- /dev/null +++ b/src/applications/mne_scan/plugins/playback/playback_global.h @@ -0,0 +1,81 @@ +//============================================================================================================= +/** + * @file playback_global.h + * @author Lorenz Esch + * @since 0.1.0 + * @date February, 2020 + * + * @section LICENSE + * + * Copyright (C) 2020, Lorenz Esch. 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 Contains the Playback library export/import macros. + * + */ + +#ifndef PLAYBACK_GLOBAL_H +#define PLAYBACK_GLOBAL_H + +//============================================================================================================= +// INCLUDES +//============================================================================================================= + +#include + +//============================================================================================================= +// QT INCLUDES +//============================================================================================================= + +#include + +//============================================================================================================= +// PREPROCESSOR DEFINES +//============================================================================================================= + +#if defined(SCAN_PLAYBACK_PLUGIN) +# define PLAYBACKSHARED_EXPORT Q_DECL_EXPORT /**< Q_DECL_EXPORT must be added to the declarations of symbols used when compiling a shared library. */ +#else +# define PLAYBACKSHARED_EXPORT Q_DECL_IMPORT /**< Q_DECL_IMPORT must be added to the declarations of symbols used when compiling a client that uses the shared library. */ +#endif + +namespace PLAYBACKPLUGIN{ + +//============================================================================================================= +/** + * Returns build date and time. + */ +PLAYBACKSHARED_EXPORT const char* buildDateTime(); + +//============================================================================================================= +/** + * Returns abbreviated build git hash. + */ +PLAYBACKSHARED_EXPORT const char* buildHash(); + +//============================================================================================================= +/** + * Returns full build git hash. + */ +PLAYBACKSHARED_EXPORT const char* buildHashLong(); +} + +#endif // PLAYBACK_GLOBAL_H