EDFlib for Java

Post Reply
Teuniz
Posts: 37
Joined: Wed Feb 06, 2008 9:42 am
Location: Neverland

EDFlib for Java

Post by Teuniz »

Dear all,

I have ported EDFlib to Java. It also supports BDF.

You can find it here:

https://www.teuniz.net/edflib_java/

Kind Regards,

Teunis van Beelen

grahambriggs
Posts: 3
Joined: Sat Mar 13, 2021 12:04 am

Re: EDFlib for Java

Post by grahambriggs »

Teunis

Thank you for your work on the EDFlib code.

I recently used your code to implement BDF file recording in my application. The library worked perfectly and I had no problems.

I do have one question, maybe you can help me out with.

What is the recommended way to deal with missing samples? I am creating a system to use with the OpenBCI boards. They have a sample index counter so you know when you are missing samples in the time sequence.

With BDF, there are a fixed number of records per page, so if you are missing samples, and if you don't fill in something for those records in the page, then your time tags will start to drift the more samples you miss.

I was thinking of dealing with this condition in one of two ways:

1) Fill in the gaps with samples with 0.0 for data, or maybe the 'missing value' for data.
2) Fill in the gaps with samples interpolated from the previous and next samples you have in the sequence.

Can you comment on what would be the recommended way to handle missing samples?

I thank you in advance for your time and attention.

GB

Teuniz
Posts: 37
Joined: Wed Feb 06, 2008 9:42 am
Location: Neverland

Re: EDFlib for Java

Post by Teuniz »

Hello Graham,

I'm glad to hear you like it.

If your goal is just hobby/fun, then go with solution #2.

If, on the other hand, you want to create a more serious application that also can be used for research,
then my advice is to investigate why the hardware "looses" samples and try to fix that instead.

I had a brief look at the OpenBCI project and I noticed that their hardware uses Bluetooth for communication.
Imho, for a reliable communication without loosing samples, a Bluetooth module must be used with the following specs:

- Class 2 (indicates the max. TX power and will usually work fine up to 10 mtrs. without walls)

- Version 2.1+EDR

- SPP (Serial Port Profile)

Then, the device must use a microcontroller with lots of SRAM in order to be able to buffer enough samples
to overcome temporary packet loss caused by other transmitters operating in the 2.4GHz band.
(Remember, the 2.4GHz band is a "free for all" band that is used by Wi-Fi, garage-door openers, video transmitters, etc.)

If, on the other hand, you are not using the radiocomm but you are using the SD-card for data-exchange,
then I don't understand why the system is loosing samples.

Kind Regards,

Teunis van Beelen

grahambriggs
Posts: 3
Joined: Sat Mar 13, 2021 12:04 am

Re: EDFlib for Java

Post by grahambriggs »

Teunis

Thank you for the prompt reply. Your comments have shed more light on my beginner's understanding.

I implemented a function to use the sample index property of the Cyton data stream to detect missing samples and then fill in with interpolated values. Unfortunately, early on in testing it I discovered the sample index property is not that reliable when there are dropped packets. Therefore, my idea was not a viable solution.


I also discovered that the actual sampling rate was not consistently 250Hz, it ranges from 248 to 252, trending on the high side of 251 for long term average. Therefore my goal of keeping the time accurate by the number of samples is not going to work unless i also 'trim' samples when there are more than 250 per second. Upon further reflection this all seems like the wrong idea. I am learning that absolute time is not so important as relative time between signal and marker for example.


More experimentation with the Cyton and dongle have confirmed that it is much more reliable when you have the dongle within a few feet of the board. I will have to make sure this physical condition is met when the system is to be recording mode.

FWIW: My system includes C++ program for the Raspberry Pi, and C# code used in cross platform programs for Windows, Android (Xamarin), and Raspberry Pi (Mono). I had to write a thin wrapper library around your EDFlib in order to have convenient C# wrapper for those platforms. You may see the code here if you are interested: https://github.com/GrahamBriggs/bcibegi ... Wrapper.cs

Thank you

GB

Teuniz
Posts: 37
Joined: Wed Feb 06, 2008 9:42 am
Location: Neverland

Re: EDFlib for Java

Post by Teuniz »

Hi Graham,

One little request, this forum is for support & questions about Biosemi hard- and software.
If you have any other questions related to EDFlib for Java, could you create an issue here please:

https://gitlab.com/Teuniz/EDFlib-Java

Thanks,
Teunis

grahambriggs
Posts: 3
Joined: Sat Mar 13, 2021 12:04 am

Re: EDFlib for Java

Post by grahambriggs »

Teunis

Got it. I will direct any further questions about EDFlib through the issue tracker.

Thank you for your help.

GB

Teuniz
Posts: 37
Joined: Wed Feb 06, 2008 9:42 am
Location: Neverland

Re: EDFlib for Java

Post by Teuniz »

You'r welcome.

Post Reply