sccn / lsl_archived

Multi-modal time-synched data transmission over local network
242 stars 134 forks source link

Java-API #291

Closed Abdulghany closed 6 years ago

Abdulghany commented 6 years ago

Hi! Does anyone has a working java-api would like to share or can help to setting the example provide into real streams from the device? The examples provided, if i understood, sends random numbers. But how to push the real streams?

mgrivich commented 6 years ago

What device are you talking about? Is there an API available for it? Is this API in Java or some other language?

On 4/25/2018 2:50 PM, Abdulghany wrote:

Hi! Does anyone has a working java-api would like to share or can help to setting the example provide into real streams from the device? The examples provided, if i understood, sends random numbers. But how to push the real streams?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sccn/labstreaminglayer/issues/291, or mute the thread https://github.com/notifications/unsubscribe-auth/AFC33bsgRWOCniIN4iDqgAqFntNAI7uiks5tsO-RgaJpZM4TkNg-.

Abdulghany commented 6 years ago

OpenBCI headset for EEG, it's API in Java. I have used the example codes, but how can i replace the random generated samples in (Sending example) to real EEG from headset?

mgrivich commented 6 years ago

I'm not that familiar with OpenBCI. But it appears that they have implemented LSL support (using python): http://docs.openbci.com/3rd%20Party%20Software/04-LSL

If you just want the data and are not too concerned with implementation details, I would try that first, and post to the OpenBCI forums if it doesn't work out.

If anyone is more aware of using OpenBCI with LSL, feel free to respond.

On 4/25/2018 4:26 PM, Abdulghany wrote:

OpenBCI headset for EEG, it's API in Java. I have used the example codes, but how can i replace the random generated samples in (Sending example) to real EEG from headset?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sccn/labstreaminglayer/issues/291#issuecomment-384464910, or mute the thread https://github.com/notifications/unsubscribe-auth/AFC33c3zU2KlYeQF1vpDaKmzoHvrATE-ks5tsQZBgaJpZM4TkNg-.

Abdulghany commented 6 years ago

Yeah i have seen this, but as you have said it's in python. But i'm interested with java, the SendData example appear as seen below. The sample are generated as random numbers instead of real EEG data, how can i replace these random generations with real EEG signals?

    System.out.println("Creating an outlet...");
    LSL.StreamOutlet outlet = new LSL.StreamOutlet(info);

    System.out.println("Sending data...");
    float[] sample = new float[8];
    for (int t=0;t<100000;t++) {
        for (int k=0;k<8;k++)
            sample[k] = (float)Math.random()*100;
        outlet.push_sample(sample);
        Thread.sleep(10);
    }

    outlet.close();
    info.destroy();
mgrivich commented 6 years ago

If you wish to redo the work in the python tool in Java, I won't stop you, but it will involve significantly more work on your part.

Rough Steps:

1) Get the Java LSL examples functional on your computer, following the examples at https://github.com/sccn/labstreaminglayer/tree/master/LSL/liblsl-Java

2) Learn how to access the data, using Java and the OpenBCI API

3) Build a Java project that accesses both the OpenBCI Java API and LSL library.

4) Pull the data, as instructed by the OpenBCI Java API, and push it to LSL as instructed by the LSL documentation.

On 4/25/2018 5:06 PM, Abdulghany wrote:

Yeah i have seen this, but as you have said it's in python. But i'm interested with java, the SendData example appear as seen below. The sample are generated as random numbers instead as a real EEG data, how can i replace these random generations with real EEG signals?

|System.out.println("Creating an outlet..."); LSL.StreamOutlet outlet = new LSL.StreamOutlet(info); System.out.println("Sending data..."); float[] sample = new float[8]; for (int t=0;t<100000;t++) { for (int k=0;k<8;k++) sample[k] = (float)Math.random()*100; outlet.push_sample(sample); Thread.sleep(10); } outlet.close(); info.destroy(); |

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sccn/labstreaminglayer/issues/291#issuecomment-384471200, or mute the thread https://github.com/notifications/unsubscribe-auth/AFC33YCbA4L6ix-aEuryMMiU3GA2qIAFks5tsQ9-gaJpZM4TkNg-.

cboulay commented 6 years ago

@Abdulghany , I'm pretty sure you're Ghoney on Slack, right?

We can't really write an OpenBCI app for you in Java. There's already a Python app. If you want to do it in Java (school project?), then you're on your own.

You should look here for how the data are fetched from the device. For each block data sample it then calls a callback which streams data over LSL. Here is the callback.