Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
72922b2
testing branch
amborsa10 Mar 3, 2021
5d2a612
RTXI user manual code added
amborsa10 Mar 3, 2021
e0474c6
RTXI-specific makefile added
amborsa10 Mar 3, 2021
37a3a0b
consolidate directories
amborsa10 Mar 3, 2021
d2ee23a
edited makefile
amborsa10 Mar 3, 2021
ad7bce9
edited makefile
amborsa10 Mar 3, 2021
afc09ad
fixed missing declarations
amborsa10 Mar 3, 2021
ffbdf27
changing parameters
amborsa10 Mar 3, 2021
674c971
updated to work with updated lfp-cpp-library
amborsa10 Mar 18, 2021
1b5b8d5
fixed typo in MakeFile
amborsa10 Mar 18, 2021
60e7d8c
fixed typo in Makefile
amborsa10 Mar 18, 2021
b2e16fd
debugging
amborsa10 Mar 18, 2021
213a522
renaming to rtxi-lfpRatiometer object
amborsa10 Mar 19, 2021
50692c9
small bug fixes
amborsa10 Mar 19, 2021
d6ec49c
added lfpRatiometer to LIBS Makefile
amborsa10 Mar 19, 2021
3587d93
modified Makefile to be aligned with rtxi-gldsController Makefile
amborsa10 Mar 19, 2021
ce021dd
added Makefile.plugin_compile
amborsa10 Mar 19, 2021
00463a6
including lfpRatiometer library now
amborsa10 Mar 19, 2021
a567f76
missing semicolon
amborsa10 Mar 19, 2021
15682e2
changed name of RTXI plugin
amborsa10 Mar 19, 2021
f7bc497
added cleanrtxi feature to Makefile
amborsa10 Mar 19, 2021
90dd7a3
debugging
amborsa10 Mar 20, 2021
ac1bb35
added FFTW3 pkg-config to Makefile
amborsa10 Mar 22, 2021
7da115d
Makefile changes
amborsa10 Mar 22, 2021
11217d6
Makefile miscellaneous changes
amborsa10 Mar 23, 2021
dd76f2e
minor changes to .cpp file
amborsa10 Mar 23, 2021
af58da8
commenting out lfpRatiometer
amborsa10 Mar 23, 2021
f8b50e3
misc
amborsa10 Mar 23, 2021
4e61e0b
misc
amborsa10 Mar 23, 2021
6987636
Makefile edits
amborsa10 Mar 23, 2021
8ad5445
cleaning
amborsa10 Mar 23, 2021
cfee09b
added comments
amborsa10 Mar 23, 2021
027c3e0
changed variable type
amborsa10 Mar 26, 2021
acf67f7
trying something
amborsa10 Mar 26, 2021
b352e31
changed output of destructor
amborsa10 Mar 26, 2021
9bb1aad
changed output of destructor
amborsa10 Mar 26, 2021
ae23f5c
changed output of destructor
amborsa10 Mar 26, 2021
59a624c
reverted Makefile to plugin-template
amborsa10 Mar 26, 2021
5dcec5d
reverted Makefile to plugin-template
amborsa10 Mar 26, 2021
96649f8
reverting Makefile to Michael's version with pkgconfig
amborsa10 Mar 26, 2021
ca835bc
alternatives commented in Makefile
amborsa10 Mar 26, 2021
db4086f
changes to Makefile that allow RTXI plugin to finally work
amborsa10 Mar 29, 2021
6cc175e
changing constructor initialization
amborsa10 Mar 30, 2021
c8028d3
changing GUI to have all relevant parameters
amborsa10 Mar 30, 2021
780b4ee
addressing two errors for GUI modification
amborsa10 Mar 30, 2021
c8f0434
fixing typo bugs
amborsa10 Mar 30, 2021
5d5a4aa
minor tinkering
amborsa10 Mar 31, 2021
206d899
minor tinkering
amborsa10 Mar 31, 2021
c044b67
more minor tinkering
amborsa10 Mar 31, 2021
27cf77e
setState used for sampling rate
amborsa10 Mar 31, 2021
092616d
minor change
amborsa10 Mar 31, 2021
cd26eef
minor changes
amborsa10 Mar 31, 2021
5b26ca5
more minor changes
amborsa10 Mar 31, 2021
9022ce0
minor changes
amborsa10 Mar 31, 2021
63a9fc7
more tweaking
amborsa10 Mar 31, 2021
e9e5375
small change
amborsa10 Mar 31, 2021
bf11194
minor
amborsa10 Mar 31, 2021
7aedf9e
minor ptII
amborsa10 Mar 31, 2021
7803d94
frequency bounds now taken from lfpratiometer object
amborsa10 Mar 31, 2021
10eda76
stuff
amborsa10 Mar 31, 2021
9987b3f
minor change
amborsa10 Mar 31, 2021
cd82114
adding MODIFY instructions
amborsa10 Mar 31, 2021
9c30c34
minor changes
amborsa10 Mar 31, 2021
891e618
using lfpRatiometer's new changeFFTPlan method
amborsa10 Mar 31, 2021
dc4daed
debugging tracker
amborsa10 Mar 31, 2021
41cad51
some debugging trackers
amborsa10 Mar 31, 2021
d98e8d3
debuggin
amborsa10 Mar 31, 2021
985cccb
more debuggin
amborsa10 Mar 31, 2021
2071bc7
more debugging
amborsa10 Mar 31, 2021
aa7672d
debugging
amborsa10 Mar 31, 2021
efcc8c6
debugging
amborsa10 Mar 31, 2021
f6f6aeb
debugging
amborsa10 Mar 31, 2021
d420303
final changes 3.30.2021
amborsa10 Mar 31, 2021
0c66572
final changes 3.30.2021
amborsa10 Mar 31, 2021
6402b54
final changes 3.30.2021
amborsa10 Mar 31, 2021
10a3c6a
added outputs to track LF & HF power, separately
amborsa10 May 4, 2021
f0bb31e
Merge pull request #1 from amborsa10/rtxi-plugin
amborsa10 May 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
CXX=g++
CXX_FLAGS=-std=c++11 -Iinclude
PLUGIN_NAME = rtxilfpRatiometer

LD_FLAGS=-lfftw3 -lm
HEADERS = rtxi-lfpRatiometer.h

all: build/lfpRatiometer.o
$(CXX) $(CXX_FLAGS) -o build/test src/main.cpp build/lfpRatiometer.o $(LD_FLAGS)
SOURCES = rtxi-lfpRatiometer.cpp \
moc_rtxi-lfpRatiometer.cpp

build/lfpRatiometer.o:
$(CXX) $(CXX_FLAGS) -o build/lfpRatiometer.o -c src/lfpRatiometer.cpp
LIBS =

OS := $(shell uname)
CXX = g++

# FFTW3 (not sure if necessary)
#CXXFLAGS := $(CXXFLAGS) $(shell pkg-config --cflags fftw3)
#LDFLAGS := $(LDFLAGS) $(shell pkg-config --libs fftw3)

# lfpRatiometer
#CXXFLAGS := $(CXXFLAGS) $(shell pkg-config --cflags lfpRatiometer)
#LDFLAGS := $(LDFLAGS) $(shell pkg-config --libs lfpRatiometer)
CXXFLAGS := $(CXXFLAGS) -I/home/amborsa10/.local/include
#LDFLAGS := $(LDFLAGS) -L/usr/lib/x86_64-linux-gnu -lfftw3 -L/home/amborsa10/.local/lib -llfpRatiometer

LDFLAGS := $(LDFLAGS) -Wl,-rpath -Wl,/home/amborsa10/.local/lib -L/home/amborsa10/.local/lib -llfpRatiometer

# CXXFLAGS := $(CXXFLAGS) -rpath /home/amborsa10/.local/lib

# RTXI plug-in stuff
include Makefile.plugin_compile

print-% : ; @echo $* = $($*)

cleanrtxi :
sudo rm -rf /usr/local/lib/rtxi/$(PLUGIN_NAME).*
43 changes: 43 additions & 0 deletions Makefile.plugin_compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
exec_modeldir = /usr/local/lib/rtxi

LIBTOOL = /usr/local/share/rtxi/libtool
CXX = g++
CXXLD = g++
CXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD)
MOC = /usr/bin/moc

CXXFLAGS := $(CXXFLAGS) -I. -I/usr/local/include/rtxi -I/usr/local/include/rtxi/plugins -I/usr/local/include/rtxi/libs -pipe -I/usr/local/include -I/usr/include/x86_64-linux-gnu/qt5/QtOpenGL -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtPrintSupport -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtXml -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtSvg -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/X11R6/include -I/usr/include/hdf5/serial -I/usr/include/qwt -I/usr/local/include/qwt -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_SVG_LIB -DQT_SHARED -w -O3 -std=c++11 -fPIC

LDFLAGS := $(LDFLAGS) -L/usr/local/lib/rtxi/libs -L/usr/local/lib -lQt5OpenGL -lQt5PrintSupport -lQt5Xml -lQt5Svg -lQt5Widgets -lQt5Gui -lQt5Network -lQt5Core -lgit2 -lqwt-qt5 -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lhdf5 -lhdf5_hl -lGL -lpthread -lgsl -lgslcblas -lm -ldl -Wl,--no-as-needed -Wl,@/usr/xenomai/lib/modechk.wrappers -lalchemy -lcopperplate /usr/xenomai/lib/xenomai/bootstrap-pic.o -L/usr/xenomai/lib -lcobalt -lmodechk -lpthread -lrt -module -avoid-version

ifdef DEBUG
CXXFLAGS += -DDEBUG
endif

# 2018-01-17 : MFB edited to prepend julia stuff to existing OBJECTS variable.
OBJECTS += $(shell echo $(SOURCES) | sed "s/\.cpp[ \t\n]*/\.lo /g")
MOOBJECTS = $(shell echo $(HEADERS) | sed "s/\.h[ \t\n]*/\.lo /g")

all: $(PLUGIN_NAME).la

%.lo: %.cpp
$(CXXCOMPILE) $(CXXFLAGS) -c $< -o $@

$(PLUGIN_NAME).la: $(OBJECTS) $(SOURCES) $(HEADERS)
$(CXXLINK) $(CXXFLAGS) $(LIBS) $(LDFLAGS) -rpath `readlink -f $(exec_modeldir)` -o $(PLUGIN_NAME).la $(OBJECTS)

install: $(PLUGIN_NAME).la
$(LIBTOOL) --mode=install cp $(PLUGIN_NAME).la `readlink -f $(exec_modeldir)`

clean:
rm -f $(OBJECTS)
rm -f $(MOOBJECTS)
rm -f moc_*
rm -f *.o
rm -f $(PLUGIN_NAME).la
rm -f $(PLUGIN_NAME).o
rm -rf .libs

moc_%.cpp: %.h
$(MOC) -o $@ $<
79 changes: 0 additions & 79 deletions include/lfpRatiometer.h

This file was deleted.

159 changes: 159 additions & 0 deletions rtxi-lfpRatiometer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#include <rtxi-lfpRatiometer.h>

using namespace std;

extern "C" Plugin::Object *createRTXIPlugin(void){
return new rtxilfpRatiometer();
}

static DefaultGUIModel::variable_t vars[] = {
{
"Time Window (s)", "Time Window (s)",
DefaultGUIModel::PARAMETER | DefaultGUIModel::DOUBLE
},
{
"Sampling Rate (Hz)", "Sampling Rate (Hz)",
DefaultGUIModel::STATE | DefaultGUIModel::DOUBLE,
},
{
"LF Lower Bound", "LF Lower Bound",
DefaultGUIModel::PARAMETER | DefaultGUIModel::DOUBLE,
},
{
"LF Upper Bound", "LF Upper Bound",
DefaultGUIModel::PARAMETER | DefaultGUIModel::DOUBLE,
},
{
"HF Lower Bound", "HF Lower Bound",
DefaultGUIModel::PARAMETER | DefaultGUIModel::DOUBLE,
},
{
"HF Upper Bound", "HF Upper Bound",
DefaultGUIModel::PARAMETER | DefaultGUIModel::DOUBLE,
},
{
"input_LFP", "Input LFP",
DefaultGUIModel::INPUT | DefaultGUIModel::DOUBLE,
},
{
"ratio", "Output LFP Power Ratio",
DefaultGUIModel::OUTPUT | DefaultGUIModel::DOUBLE,
},
{
"LF Power", "Power in LF Band",
DefaultGUIModel::OUTPUT | DefaultGUIModel::DOUBLE,
},
{
"HF Power", "Power in HF Band",
DefaultGUIModel::OUTPUT | DefaultGUIModel::DOUBLE,
}
};

static size_t num_vars = sizeof(vars) / sizeof(DefaultGUIModel::variable_t);

// defining what's in the object's constructor
// sampling set by RT period
rtxilfpRatiometer::rtxilfpRatiometer(void) :
DefaultGUIModel("lfpRatiometer with Custom GUI", ::vars, ::num_vars),
period(((double)RT::System::getInstance()->getPeriod())*1e-9), // grabbing RT period
sampling(1.0/period), // calculating RT sampling rate
lfpratiometer(N, sampling) // constructing lfpRatiometer object
{
setWhatsThis("<p><b>lfpRatiometer:</b><br>Given an input, this module calculates the LF/HF ratio over a specified causal time window.</p>");
DefaultGUIModel::createGUI(vars, num_vars);
customizeGUI();
update(INIT);
refresh();
QTimer::singleShot(0, this, SLOT(resizeMe()));
}

// defining what's in the object's destructor
rtxilfpRatiometer::~rtxilfpRatiometer(void) { }

// real-time RTXI function
void rtxilfpRatiometer::execute(void) {

// push new time series reading to lfpRatiometer
lfpratiometer.pushTimeSample(input(0));

// calculate LF/HF ratio
lfpratiometer.calcRatio();

// put the LF/HF ratio into the output
output(0) = lfpratiometer.getRatio();
output(1) = lfpratiometer.getLFpower();
output(2) = lfpratiometer.getHFpower();

}

// update function (not running in real time)
void rtxilfpRatiometer::update(DefaultGUIModel::update_flags_t flag)
{
switch (flag) {
case INIT:
setParameter("Time Window (s)", sampling/N);
setState("Sampling Rate (Hz)", sampling);
// get bounds from lfpratiometer object
setParameter("LF Lower Bound", lfpratiometer.getFreqBounds()[0]);
setParameter("LF Upper Bound", lfpratiometer.getFreqBounds()[1]);
setParameter("HF Lower Bound", lfpratiometer.getFreqBounds()[2]);
setParameter("HF Upper Bound", lfpratiometer.getFreqBounds()[3]);
break;

case MODIFY:
// defining parameters needed for constructor
period = ((double)RT::System::getInstance()->getPeriod())*1e-9;
sampling = 1.0/period;
setState("Sampling Rate (Hz)", sampling); // updating GUI
N = (int) (getParameter("Time Window (s)").toDouble() * sampling);

// making new FFT plan
lfpratiometer.changeFFTPlan(N, sampling);

// setting frequency bounds based on user input
lfpratiometer.setRatioParams(getParameter("LF Lower Bound").toDouble(),
getParameter("LF Upper Bound").toDouble(),
getParameter("HF Lower Bound").toDouble(),
getParameter("HF Upper Bound").toDouble());

// setting DFT windowing function choice
if (windowShape->currentIndex() == 0) {
lfpratiometer.window_rect();
}
else if (windowShape->currentIndex() == 1) {
lfpratiometer.window_hamming();
}

// clearing time series
lfpratiometer.clrTimeSeries();

break;

case UNPAUSE:
break;

case PAUSE:
lfpratiometer.clrTimeSeries();
break;

case PERIOD:
break;

default:
break;
}
}

// RTXI's customizeGUI function
void rtxilfpRatiometer::customizeGUI(void)
{
QGridLayout* customlayout = DefaultGUIModel::getLayout();

// adding dropdown menu for choosing FFT window shape
windowShape = new QComboBox;
windowShape->insertItem(1, "Rectangular");
windowShape->insertItem(2, "Hamming");

customlayout->addWidget(windowShape, 2, 0);
setLayout(customlayout);
}
47 changes: 47 additions & 0 deletions rtxi-lfpRatiometer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef RTXILFPRATIOMETER_H
#define RTXILFPRATIOMETER_H

#include <default_gui_model.h>
#include <main_window.h>
#include <lfpRatiometer>

class rtxilfpRatiometer : public DefaultGUIModel {

Q_OBJECT

public:
// constructor
rtxilfpRatiometer(void);

// destructor
virtual ~rtxilfpRatiometer(void);

// execute
void execute(void);

// functions to make GUI
void createGUI(DefaultGUIModel::variable_t*, int);
void customizeGUI(void);

protected:

// update function
virtual void update(DefaultGUIModel::update_flags_t);

private:

// needed to initialize lfpratiometer object
int N = 1000; // initialized to 1000 samples (1s for 1kHz sampling)
double period; // set from RT period
double sampling; // set based on RT period

// lfpRatiometer object
lfpRatiometer lfpratiometer;

// variables for GUI
QComboBox* windowShape;

};


#endif
Loading