From da08a87d332286480216f0288aa6ea9017849534 Mon Sep 17 00:00:00 2001 From: Gabriel B Motta Date: Wed, 5 Apr 2023 12:09:28 -0400 Subject: [PATCH 1/7] Add skeleton of playback plugin --- .../mne_scan/plugins/CMakeLists.txt | 1 + .../mne_scan/plugins/playback/CMakeLists.txt | 80 +++++++++ .../playback/FormFiles/playbacksetup.ui | 150 ++++++++++++++++ .../FormFiles/playbacksetupwidget.cpp | 69 ++++++++ .../playback/FormFiles/playbacksetupwidget.h | 100 +++++++++++ .../mne_scan/plugins/playback/playback.cpp | 167 ++++++++++++++++++ .../mne_scan/plugins/playback/playback.h | 140 +++++++++++++++ .../mne_scan/plugins/playback/playback.json | 0 .../plugins/playback/playback_global.cpp | 54 ++++++ .../plugins/playback/playback_global.h | 81 +++++++++ 10 files changed, 842 insertions(+) create mode 100644 src/applications/mne_scan/plugins/playback/CMakeLists.txt create mode 100644 src/applications/mne_scan/plugins/playback/FormFiles/playbacksetup.ui create mode 100644 src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.cpp create mode 100644 src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.h create mode 100644 src/applications/mne_scan/plugins/playback/playback.cpp create mode 100644 src/applications/mne_scan/plugins/playback/playback.h create mode 100644 src/applications/mne_scan/plugins/playback/playback.json create mode 100644 src/applications/mne_scan/plugins/playback/playback_global.cpp create mode 100644 src/applications/mne_scan/plugins/playback/playback_global.h 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..809b74ff084 --- /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..9d4856d5129 --- /dev/null +++ b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetup.ui @@ -0,0 +1,150 @@ + + + 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="-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> +<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;">How to setup this plugin?</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;"><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 control this plugin during the measurement?</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;"><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..fa47355c39a --- /dev/null +++ b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.cpp @@ -0,0 +1,69 @@ +//============================================================================================================= +/** + * @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); +} + +//============================================================================================================= + +PlaybackSetupWidget::~PlaybackSetupWidget() +{ +} + 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..db86d265072 --- /dev/null +++ b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.h @@ -0,0 +1,100 @@ +//============================================================================================================= +/** + * @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(); + +private: + + Playback* m_pPlayback; /**< Holds a pointer to corresponding Playback.*/ + + Ui::PlaybackSetupWidgetClass ui; /**< Holds the user interface for the PlaybackSetupWidget.*/ +}; +} // 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..6788cae0892 --- /dev/null +++ b/src/applications/mne_scan/plugins/playback/playback.cpp @@ -0,0 +1,167 @@ +//============================================================================================================= +/** + * @file playback.cpp + * @author Lorenz Esch , + * Gabriel B Motta + * @since 0.1.0 + * @date February, 2020 + * + * @section LICENSE + * + * Copyright (C) 2020, Lorenz Esch, 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 + +//============================================================================================================= +// QT INCLUDES +//============================================================================================================= + +//============================================================================================================= +// EIGEN INCLUDES +//============================================================================================================= + +//============================================================================================================= +// USED NAMESPACES +//============================================================================================================= + +using PLAYBACKPLUGIN::Playback; +using PLAYBACKPLUGIN::PlaybackSetupWidget; +using UTILSLIB::File; +using SCSHAREDLIB::AbstractSensor; +using SCSHAREDLIB::AbstractPlugin; +using Eigen::MatrixXd; + +//============================================================================================================= +// DEFINE MEMBER METHODS +//============================================================================================================= + +Playback::Playback() +{ +} + +//============================================================================================================= + +Playback::~Playback() +{ + if(this->isRunning()) { + stop(); + } +} + +//============================================================================================================= + +QSharedPointer Playback::clone() const +{ + QSharedPointer pPlaybackClone(new Playback); + return pPlaybackClone; +} + +//============================================================================================================= + +void Playback::init() +{ + +} + +//============================================================================================================= + +void Playback::unload() +{ +} + +//============================================================================================================= + +bool Playback::start() +{ + 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* setupWidget = new PlaybackSetupWidget(this);//widget is later distroyed by CentralWidget - so it has to be created everytime new + return setupWidget; +} + +//============================================================================================================= + +void Playback::run() +{ + MatrixXd matData; + qint32 size = 0; + + while(!isInterruptionRequested()) { + if(m_pCircularBuffer) { + + } + } +} + +//============================================================================================================= + +QString Playback::getBuildInfo() +{ + return QString(buildDateTime()) + QString(" - ") + QString(buildHash()); +} 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..ff41777440f --- /dev/null +++ b/src/applications/mne_scan/plugins/playback/playback.h @@ -0,0 +1,140 @@ +//============================================================================================================= +/** + * @file playback.h + * @author Lorenz Esch , + * Gabriel B Motta + * @since 0.1.0 + * @date February, 2020 + * + * @section LICENSE + * + * Copyright (C) 2020, Lorenz Esch, 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 + +//============================================================================================================= +// 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::AbstractAlgorithm) + +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(); + + QSharedPointer m_pCircularBuffer; /**< Holds incoming raw data. */ + +}; +} // 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 From 5b1ee2018329e440f7de5a899a96d39aa6a928f0 Mon Sep 17 00:00:00 2001 From: Gabriel B Motta Date: Wed, 5 Apr 2023 13:26:55 -0400 Subject: [PATCH 2/7] Pick source file --- .../playback/FormFiles/playbacksetup.ui | 4 ++-- .../FormFiles/playbacksetupwidget.cpp | 24 +++++++++++++++++++ .../playback/FormFiles/playbacksetupwidget.h | 9 ++++++- .../mne_scan/plugins/playback/playback.cpp | 19 +++++++++++++-- .../mne_scan/plugins/playback/playback.h | 5 +++- 5 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetup.ui b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetup.ui index 9d4856d5129..dcc40e07be6 100644 --- a/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetup.ui +++ b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetup.ui @@ -115,10 +115,10 @@ p, li { white-space: pre-wrap; } - + - + Browse Files diff --git a/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.cpp b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.cpp index fa47355c39a..5317f20efc7 100644 --- a/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.cpp +++ b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.cpp @@ -59,6 +59,10 @@ PlaybackSetupWidget::PlaybackSetupWidget(Playback* toolbox, 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); } //============================================================================================================= @@ -67,3 +71,23 @@ 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 index db86d265072..33ef9241fbe 100644 --- a/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.h +++ b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetupwidget.h @@ -89,11 +89,18 @@ class PlaybackSetupWidget : public QWidget */ ~PlaybackSetupWidget(); + void setSourceFile(QString filePath); + private: + void browseFiles(); Playback* m_pPlayback; /**< Holds a pointer to corresponding Playback.*/ - Ui::PlaybackSetupWidgetClass ui; /**< Holds the user interface for the PlaybackSetupWidget.*/ + Ui::PlaybackSetupUi ui; /**< Holds the user interface for the PlaybackSetupWidget.*/ + +public: +signals: + void newSourceFileSet(QString filePath); }; } // NAMESPACE diff --git a/src/applications/mne_scan/plugins/playback/playback.cpp b/src/applications/mne_scan/plugins/playback/playback.cpp index 6788cae0892..2cdaa386a44 100644 --- a/src/applications/mne_scan/plugins/playback/playback.cpp +++ b/src/applications/mne_scan/plugins/playback/playback.cpp @@ -49,6 +49,8 @@ // QT INCLUDES //============================================================================================================= +#include + //============================================================================================================= // EIGEN INCLUDES //============================================================================================================= @@ -141,8 +143,12 @@ QString Playback::getName() const QWidget* Playback::setupWidget() { - PlaybackSetupWidget* setupWidget = new PlaybackSetupWidget(this);//widget is later distroyed by CentralWidget - so it has to be created everytime new - return setupWidget; + PlaybackSetupWidget* widget = new PlaybackSetupWidget(this);//widget is later distroyed by CentralWidget - so it has to be created everytime new + + connect(widget, &PlaybackSetupWidget::newSourceFileSet, + this, &Playback::setSourceFile, Qt::UniqueConnection); + + return widget; } //============================================================================================================= @@ -165,3 +171,12 @@ QString Playback::getBuildInfo() { return QString(buildDateTime()) + QString(" - ") + QString(buildHash()); } + +//============================================================================================================= + +void Playback::setSourceFile(QString filePath) +{ + sourceFilePath = filePath; + qDebug() << "SET:" << sourceFilePath; +} + diff --git a/src/applications/mne_scan/plugins/playback/playback.h b/src/applications/mne_scan/plugins/playback/playback.h index ff41777440f..dca71379159 100644 --- a/src/applications/mne_scan/plugins/playback/playback.h +++ b/src/applications/mne_scan/plugins/playback/playback.h @@ -96,7 +96,7 @@ 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::AbstractAlgorithm) + Q_INTERFACES(SCSHAREDLIB::AbstractSensor) public: //========================================================================================================= @@ -133,7 +133,10 @@ class PLAYBACKSHARED_EXPORT Playback : public SCSHAREDLIB::AbstractSensor virtual void run(); QSharedPointer m_pCircularBuffer; /**< Holds incoming raw data. */ + QString sourceFilePath; +public slots: + void setSourceFile(QString filePath); }; } // NAMESPACE From 8b8d0f500a510f1c48e941b29909f5166242f5c5 Mon Sep 17 00:00:00 2001 From: Gabriel B Motta Date: Wed, 5 Apr 2023 14:14:51 -0400 Subject: [PATCH 3/7] Load data from file --- .../mne_scan/plugins/playback/playback.cpp | 57 ++++++++++++++++--- .../mne_scan/plugins/playback/playback.h | 17 ++++-- 2 files changed, 61 insertions(+), 13 deletions(-) diff --git a/src/applications/mne_scan/plugins/playback/playback.cpp b/src/applications/mne_scan/plugins/playback/playback.cpp index 2cdaa386a44..2094df698d0 100644 --- a/src/applications/mne_scan/plugins/playback/playback.cpp +++ b/src/applications/mne_scan/plugins/playback/playback.cpp @@ -1,14 +1,13 @@ //============================================================================================================= /** * @file playback.cpp - * @author Lorenz Esch , - * Gabriel B Motta - * @since 0.1.0 - * @date February, 2020 + * @author Gabriel B Motta + * @since 0.1.9 + * @date April, 2023 * * @section LICENSE * - * Copyright (C) 2020, Lorenz Esch, Gabriel B Motta. All rights reserved. + * 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: @@ -62,8 +61,11 @@ using PLAYBACKPLUGIN::Playback; using PLAYBACKPLUGIN::PlaybackSetupWidget; using UTILSLIB::File; +using FIFFLIB::FiffStream; using SCSHAREDLIB::AbstractSensor; using SCSHAREDLIB::AbstractPlugin; +using SCSHAREDLIB::PluginOutputData; +using SCMEASLIB::RealTimeMultiSampleArray; using Eigen::MatrixXd; //============================================================================================================= @@ -95,7 +97,9 @@ QSharedPointer Playback::clone() const 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); } //============================================================================================================= @@ -108,6 +112,28 @@ 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 (!sourceFile->open(QIODevice::ReadOnly)){ + qWarning() << "[Playback::start] Unable to open:" << sourceFilePath; + return false; + } + + if (!loadFiffRawData()){ + qWarning() << "[Playback::start] Not able to read raw info or data from:" << sourceFilePath; + return false; + } + QThread::start(); return true; @@ -155,8 +181,11 @@ QWidget* Playback::setupWidget() void Playback::run() { - MatrixXd matData; - qint32 size = 0; + int first = rawData.first_samp; + int last = rawData.last_samp; + int bufferSize = rawData.info.sfreq; + MatrixXd data; + MatrixXd times; while(!isInterruptionRequested()) { if(m_pCircularBuffer) { @@ -180,3 +209,15 @@ void Playback::setSourceFile(QString filePath) qDebug() << "SET:" << sourceFilePath; } +//============================================================================================================= + +bool Playback::loadFiffRawData() +{ + if(!FiffStream::setup_read_raw(*sourceFile, rawData)) + { + rawData.clear(); + return false; + } + return true; +} + diff --git a/src/applications/mne_scan/plugins/playback/playback.h b/src/applications/mne_scan/plugins/playback/playback.h index dca71379159..87c4bbe1cb9 100644 --- a/src/applications/mne_scan/plugins/playback/playback.h +++ b/src/applications/mne_scan/plugins/playback/playback.h @@ -1,14 +1,13 @@ //============================================================================================================= /** * @file playback.h - * @author Lorenz Esch , - * Gabriel B Motta - * @since 0.1.0 - * @date February, 2020 + * @author Gabriel B Motta + * @since 0.1.9 + * @date April, 2023 * * @section LICENSE * - * Copyright (C) 2020, Lorenz Esch, Gabriel B Motta . All rights reserved. + * 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: @@ -46,6 +45,8 @@ #include #include +#include + //============================================================================================================= // QT INCLUDES //============================================================================================================= @@ -132,8 +133,14 @@ class PLAYBACKSHARED_EXPORT Playback : public SCSHAREDLIB::AbstractSensor */ virtual void run(); + bool loadFiffRawData(); + + 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; public slots: void setSourceFile(QString filePath); From 929829ec6421e3f08e0e8f27d1ef9465a7155f9b Mon Sep 17 00:00:00 2001 From: Gabriel B Motta Date: Wed, 5 Apr 2023 15:17:35 -0400 Subject: [PATCH 4/7] Send data to output --- .../mne_scan/plugins/playback/playback.cpp | 52 ++++++++++++++----- .../mne_scan/plugins/playback/playback.h | 6 +++ 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/applications/mne_scan/plugins/playback/playback.cpp b/src/applications/mne_scan/plugins/playback/playback.cpp index 2094df698d0..22e7c0b45ef 100644 --- a/src/applications/mne_scan/plugins/playback/playback.cpp +++ b/src/applications/mne_scan/plugins/playback/playback.cpp @@ -42,6 +42,8 @@ #include #include +#include +#include #include //============================================================================================================= @@ -66,7 +68,6 @@ using SCSHAREDLIB::AbstractSensor; using SCSHAREDLIB::AbstractPlugin; using SCSHAREDLIB::PluginOutputData; using SCMEASLIB::RealTimeMultiSampleArray; -using Eigen::MatrixXd; //============================================================================================================= // DEFINE MEMBER METHODS @@ -124,11 +125,6 @@ bool Playback::start() return false; } - if (!sourceFile->open(QIODevice::ReadOnly)){ - qWarning() << "[Playback::start] Unable to open:" << sourceFilePath; - return false; - } - if (!loadFiffRawData()){ qWarning() << "[Playback::start] Not able to read raw info or data from:" << sourceFilePath; return false; @@ -181,16 +177,33 @@ QWidget* Playback::setupWidget() void Playback::run() { - int first = rawData.first_samp; - int last = rawData.last_samp; + initConnector(); + + int absolute_first = rawData.first_samp; + int absolute_last = rawData.last_samp; + int bufferSize = rawData.info.sfreq; - MatrixXd data; - MatrixXd times; - while(!isInterruptionRequested()) { - if(m_pCircularBuffer) { + 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); } } @@ -218,6 +231,21 @@ bool Playback::loadFiffRawData() 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 index 87c4bbe1cb9..75d121e421e 100644 --- a/src/applications/mne_scan/plugins/playback/playback.h +++ b/src/applications/mne_scan/plugins/playback/playback.h @@ -135,6 +135,8 @@ class PLAYBACKSHARED_EXPORT Playback : public SCSHAREDLIB::AbstractSensor 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. */ @@ -142,6 +144,10 @@ class PLAYBACKSHARED_EXPORT Playback : public SCSHAREDLIB::AbstractSensor 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); }; From c9d8f3b3564c1bcba33a2a0f11759c8e2a852876 Mon Sep 17 00:00:00 2001 From: Gabriel B Motta Date: Wed, 5 Apr 2023 15:19:45 -0400 Subject: [PATCH 5/7] Add description to startup ui --- .../mne_scan/plugins/playback/FormFiles/playbacksetup.ui | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetup.ui b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetup.ui index dcc40e07be6..5f0ec14e7f1 100644 --- a/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetup.ui +++ b/src/applications/mne_scan/plugins/playback/FormFiles/playbacksetup.ui @@ -80,12 +80,11 @@ 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="-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> -<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-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="-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> -<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 control this plugin during the measurement?</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;"><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-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> From 45bc7e06549fa81f982f2405d02a72ec698bfd0d Mon Sep 17 00:00:00 2001 From: Gabriel B Motta Date: Tue, 11 Apr 2023 09:46:22 -0400 Subject: [PATCH 6/7] Fix export macro definitions for windows --- src/applications/mne_scan/plugins/playback/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/applications/mne_scan/plugins/playback/CMakeLists.txt b/src/applications/mne_scan/plugins/playback/CMakeLists.txt index 809b74ff084..bb003608389 100644 --- a/src/applications/mne_scan/plugins/playback/CMakeLists.txt +++ b/src/applications/mne_scan/plugins/playback/CMakeLists.txt @@ -73,7 +73,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE 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}") +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) From 0f4f0facc2d67e37fb55ea431f5ed388b6838066 Mon Sep 17 00:00:00 2001 From: Gabriel B Motta Date: Wed, 26 Apr 2023 14:03:35 -0400 Subject: [PATCH 7/7] Keep source file path and display on setupwidget --- src/applications/mne_scan/plugins/playback/playback.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/applications/mne_scan/plugins/playback/playback.cpp b/src/applications/mne_scan/plugins/playback/playback.cpp index 22e7c0b45ef..93c9e90a4c5 100644 --- a/src/applications/mne_scan/plugins/playback/playback.cpp +++ b/src/applications/mne_scan/plugins/playback/playback.cpp @@ -167,6 +167,8 @@ 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);