Input Logging & Java Animation

Forum for software developers to discuss BCI2000 software development
Post Reply
chrishunt
Posts: 5
Joined: 30 Jun 2015, 14:40

Input Logging & Java Animation

Post by chrishunt » 30 Jun 2015, 15:03

Hello there,

I'm new to this forum and I have a question on the capabilities of BCI2000. I've been working with the framework for about a month now, attempting to use it as the data acquisition workhorse in the background of a bigger framework. I've been using the tutorials on the wiki as examples for writing my own code but I have a few questions that the wiki hasn't really addressed.

1. How can I use the custom input loggers that I've built in BCI2000? I've written two input loggers, following the example in the wiki. However, I'm not exactly sure how to actually use them in a signal source module. I know that as environment extensions, any source module can access the system states stored in the loggers (or so I thought) but I'm not sure how to actually integrate them with a source module. Any help on that front would be greatly appreciated.

2. In the overall framework I've been helping to develop, graphical output is handled with Java. As such, a Java object needs to be able to access data being collected in BCI2000 in real-time. From what I've read, a similar thing can be done with Matlab using a filter (?), although I'm not exactly too sure how to go about doing that. Is there a similar filter already available that will allow me to do the same thing with Java? I just want to be able to drive a Java animation using real-time data from BCI2000. Again, any help would be appreciated.

Thank you!

Christopher Hunt

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: Input Logging & Java Animation

Post by boulay » 30 Jun 2015, 21:19

Hi Christopher,

If you're only after controlling the graphical output with the end result of the signal processing (i.e., the control signal normally used to control a cursor or a robot) then you can try using AppConnector [1]. However, if you want the graphical output to access the data at any earlier stage then you'll need to create a new signal processing module and in its filter chain insert a custom filter to serve data (e.g., send to a server, act as a server itself, write to shared memory) and your Java application will pull data from that server/memory.

The MatlabFilter is an example of a filter that writes to shared memory. I'm not sure if there are any examples for creating a filter that acts as a UDP or TCP server, but it shouldn't be too difficult to take a simple filter and add a network server to it with code samples found elsewhere on the web.

I'll think Peter should answer about input loggers as I've never worked with those.

-Chad

[1] http://www.bci2000.org/wiki/index.php/T ... _Connector

pbrunner
Posts: 344
Joined: 17 Sep 2010, 12:43

Re: Input Logging & Java Animation

Post by pbrunner » 01 Jul 2015, 21:32

Christopher,

can you post a few more details about your loggers? If they are general purpose enough we can perhaps add them to the BCI2000 source code contributions. I can walk you through once I know more about your loggers and the steps that you have already performed.

Regards, Peter

chrishunt
Posts: 5
Joined: 30 Jun 2015, 14:40

Re: Input Logging & Java Animation

Post by chrishunt » 02 Jul 2015, 10:54

Hi Chad,

Thanks for the information. Since I'm not actually doing any signal processing with BCI2000, I feel like the AppConnector should be fine. If I'm not mistaken, it seems to just act as a UDP server at some port. It's easy enough to write UDP client in Java to read from that port. If not, I'll look into developing a custom filter. Thanks again!

Hi Peter,

Unfortunately, I do not think my loggers are general purpose enough to be added to the contributions section. One logger was used to interface with some custom hardware developed with Arduino and the other was a stripped down logger to interface with the CyberGlove (eliminating the bloat associated with the graphical output). For both, I've written the following files as instructed by the wiki:

HardwareLogger.h, HardwareLogger.cpp: The environment extension that defines the logger. I use the Extension() macro at the beginning of the source file to instantiate a logger object (I think that's what it does). All of the necessary functions (Preflight(), Publish(), etc.) have been written.

HardwareThread.h: The dedicated thread to read from the hardware. Instantiates the serial object to read from the serial port in its Execute() function.

HardwareSerial.h, HardwareSerial.cpp: The serial object that actually reads from the hardware. Contains an Initialize() and GetData() function.

Each has been written for both loggers, with more specific names of course, by following the examples from the wiki. Now, I'm just confused on how to integrate them into BCI2000 so that any source module can instantiate with the command line Optional Parameter --LogHardware=1. Thanks for the help!

Christopher Hunt

pbrunner
Posts: 344
Joined: 17 Sep 2010, 12:43

Re: Input Logging & Java Animation

Post by pbrunner » 02 Jul 2015, 14:01

Christopher,

@1: you probably just miss a few steps:

(1) Edit the "Extensions.cmake" file in the "\src\contrib\Extensions" folder and add one line for each of your new loggers.

(2) Edit the "GetConfigOpts.bat" file in the "\src\contrib\Extensions" folder and add one line for each of your new loggers.

(3) Delete the "CMakeCache.txt" file in the "\build" folder.

(4) Run the "Make VS2012 Project Files.cmd" file in the "\build" folder and when asked to add your extension select "Y".

(5) Open the "BCI2000.sln" file in the "\build" folder and recompile the entire solution.

(6) Edit the batch file that starts your configuration of BCI2000 in the "\batch" directory and add the "--LogHardware=1" parameter to your source module parameter list.

(7) Run the batch file and check if your parameter and states show up.

Let me know if this solves your issue.

@2: The AppConnector avenue should be the easiest for your application scenario.

Regards, Peter

chrishunt
Posts: 5
Joined: 30 Jun 2015, 14:40

Re: Input Logging & Java Animation

Post by chrishunt » 07 Jul 2015, 11:55

Ah, thank you so much! This seems like it will work for me. I am running into one more slight issue though. I keep getting a LNK2019 error in MSVC2012 when I try and build the projects. I know a LNK2019 error stems from misdefined (or undefined) function calls, however, I'm getting the error in regards to both custom-written functions (not weird) but also constructor (not weird) and destructor (really weird) definitions. I've checked the error-inducing functions and they are indeed defined correctly, being called with the same parameter types that they are defined for. Furthermore, the fact that I'm getting a LNK2019 error with a destructor seems really weird to me. Destructors take no parameters and if not defined explicitly, the compiler provides a general implicit one, right? All this leads me to believe that I have not included the proper files (headers and sources) in the build path for the project. I know that the include path seems to be handled by the IncludeExtensions.cmake file in the directory, however, I am quite unfamiliar with Cmake. I've followed the examples provided by the other contributed input loggers and I think I've correctly added both the HardWareLogger.h and HardWareLogger.cpp files appropriately, however, I am not confident that I correctly added the supporting files (HardWareThread.h, HardWareSerial.h, HardWareSerial.cpp, Serial.h, Serial.cpp). All of the specific supporting files are in the same directory as the logger files while I added Serial.h and Serial.cpp are within the provided shared utilities folder (BCI2000/src/shared/utils). Below is the generalized script I wrote. To be honest, I am not exactly sure what any of the SET blocks are actually setting, I merely imitated from the other input loggers. If I had to wager a guess though, I'd say that they set the libraries path, the libraries directory, the included directories, the extension headers, and the extension source files in that order. Any help would be greatly appreciated.

SET( BCI2000_SIGSRCLIBS
${BCI2000_SIGSRCLIBS}
)

SET( BCI2000_SIGSRCLIBDIRS
${BCI2000_SIGSRCLIBDIRS}
)

SET( BCI2000_SIGSRCINCDIR
${BCI2000_SIGSRCINCDIRS}
${BCI2000_EXTENSION_DIR}
${BCI2000_SRC_DIR}/shared/utils
)

SET( BCI2000_SIGSRCHEADERS_EXTENSIONS
${BCI2000_SIGSRCHEADERS_EXTENSIONS}
${BCI2000_EXTENSION_DIR}/HardWareLogger.h
)

SET( BCI2000_SIGSRCSOURCES_EXTENSIONS
${BCI2000_SIGSRCSOURCES_EXTENSIONS}
${BCI2000_EXTENSION_DIR}/HardWareLogger.cpp
)

Christopher Hunt

pbrunner
Posts: 344
Joined: 17 Sep 2010, 12:43

Re: Input Logging & Java Animation

Post by pbrunner » 07 Jul 2015, 13:31

Christopher,

can you please provide me dropbox link to your project. Is actually easier for me to look at the problem that way.

You can find my email info at www.schalklab.org/people

Regards, Peter

chrishunt
Posts: 5
Joined: 30 Jun 2015, 14:40

Re: Input Logging & Java Animation

Post by chrishunt » 07 Jul 2015, 14:00

Hello Peter,

I've sent you an email with the Dropbox link.

Christopher Hunt

pbrunner
Posts: 344
Joined: 17 Sep 2010, 12:43

Re: Input Logging & Java Animation

Post by pbrunner » 16 Jul 2015, 11:14

This issue was resolved by the user by fixing a user-created cmake file.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest