NI Labs Toolkits

Showing results for 
Search instead for 
Did you mean: 

NeuroSky LabVIEW Driver

by Member Andy-K on ‎12-07-2011 03:11 PM

NeuroSky Brain Computer Interface

NeuroSky is a company that develops low cost easy to use ASICs for acquiring electroencephalography (EEG) from users through a wireless headset.  NeuroSky has several headsets for sale featuring their ThinkGear chip acquiring EEG through a dry sensor electrode.  The major advantage of the dry sensor is the time it takes to set up. Traditional gel bases EEGs can take up to 30 minutes to start acquiring data while the NeuroSky headsets are ready to go in seconds.  The disadvantage to the dry sensor electrodes is an increase in the impedance contact the sensor has with the scalp.  This can cause low amplitude signals to not be fully represented in the acquired data.

http://www.neurosky.com/

LabVIEW - NeuroSky Driver

A LabVIEW - NeuroSky Driver has been developed that allows users to easily acquire data and access the full functionality of the system level driver provided by NeuroSky. NeuroSky provides a dynamic linked library (DLL) with a set of functions written in C that access the virtual com port that runs with the headset.  Instead of accessing the specific DLL functions, LabVIEW users can now use the LabVIEW - NeuroSky Driver to easily access data from the NeuroSky driver in minutes.  The LabVIEW - NeuroSky Driver also includes examples for basic acquisition as well as some advanced functionality of the driver.

Software required:

  • LabVIEW 2010 or above
  • VI Package Manager by JKI
    http://jki.net/vipm/download
  • LabVIEW - NeuroSky Driver for LabVIEW (attached to this document)
  • NeuroSky driver included with the headset

Supported Hardware

  • The MindWave headset is the only headset that has been tested with the driver.

Installation instructions:
  1. Follow the directions for installing the NeuroSky driver (included with the headset)
  2. Install VI package manager if not already installed
  3. Install the LabVIEW - NeuroSky Driver linked to this document

You should now have access to the NeuroSky functions pallet on the block diagram as well as several examples available through the example finder.  (Help » Find Examples, click the Directory Structure radial button and reference the NeuroSky folder)

The attached VI demonstrates the basic functionality capable with the NeuroSky driver.

NeuroSky Demo.png

Comments
Member Sundar...
Member

HI,

Kindly request to post the VI's for LabVIEW 2010 as well.

Thanks,

Sundar.

Member Andy-K
Member

The demo VI should now work with LV 2010.

Member Portland_Matt
Member

Hi Andy,

I'm running Labview 2011 (64 bit).

I tried to use the driver, but "_TG Read Packets" wont work.

When I tried to link the Call Library Functino Node to the thinkgear.dll filepath on my computer, I got a message about the thinkgear.dll being 32 bit and my Labview being 64 bit.

Do you know how I can solve this?

Thanks.

-Matt

Member Andy-K
Member

Hi Matt,

Unfortunately you cannot access a 32 bit DLL in a 64 bit version of LabVIEW.  The ThinkGear.DLL would have to be recompiled on a 64 bit operating system or you would have to install a 32 bit version of LabVIEW.  This KnowledgeBase expands on this a bit. 

Member Portland_Matt
Member

Andy,

Thanks for the information.

It sounds like I have 2 options:

1. Create a new dll in a 64 bit environment

2. Run 32 bit Labview

Is it possible to install 32 bit Labview on my 64 bit system?

Who created the dll, NI or Neurosky?

Thanks.

-Matt

Member Andy-K
Member

Hi Matt,

You can install 32 bit LabVIEW on a 64 bit OS.   That is actually what I am running right now.  For LabVIEW 2011 32 bit try here.  The evaluation is actually the full version of LabVIEW but without activation.  If you download the evaluation and then activate LabVIEW you will have the full access for unlimited duration.

As far as the DLL, it is part of the driver developed by NeuroSky.  The LabVIEW driver is a wrapper to the NeuroSky driver that brings everything into LabVIEW.

I hope this is helpful!

Member Portland_Matt
Member

Alex,

Can I run both Labview-64 and Labview-32 on the same computer?

Or do I need to uninstall my Labview-64?

If I do that, will my preferences file still exist for my options?

Thanks.

-Matt

Trusted Enthusiast
Trusted Enthusiast

LabVIEW 32-bit and 64-bit can peacefully coexist on the same computer.  They are installed in different directories and use different registry hives, so configuration remains mostly separate.  They are approximately as separate as two different versions (e.g. 2009 and 2010) would be.  I have LabVIEW 8.2 - LabVIEW 2011 with both 32-bit and 64-bit versions installed for 2009 and above on my development machine and have no difficulties (yes, I do have eight versions of LabVIEW installed on my machine).

Member Portland_Matt
Member

Alex,

I have installed Labview 32 and I have loaded the neurosky driver with the .vip installer (whatever that is), and I have begun to play with it.

I can talk to the headset from LV, but I can't read from it.

For example, I can run "Create Task" and "Get new Connection ID" with out error, and the headset will return a connection ID and task number.

When I run these vis the light on the headset changes from red to blue.

But when I try to read from the headset, using "TG Get Value", I always get a 0 returned, no matter what data type I specify.

My Call Library Function Node is pointing to: "thinkgear.dll" and never returns an error.

Can you suggest how I might trouble shoot this situation, to get things working?

Thanks.

-Matt

Member Andy-K
Member

The .vip installer is the file format used by VI Package manager which is a great tool for installing tools such as the LabVIEW NeuroSky driver.

As far as the programming goes, if you want to work at the DLL level you should keep in mind that depending on what data you are reading from the driver, the TG Get Value function may not return data because there is currently no new data from the driver for that data value.  You can use the TG Get Value status to see the state of the data you are looking at reading.

You should not need to operate on the DLL level with this driver though.  I encourage you to look at the examples found by going to Help » Find Examples, click the Directory Structure radial button and reference the NeuroSky folder.  You can then dive into the VIs to see how the driver is structured and how to read data.

I hope this is helpful!

Member Portland_Matt
Member

Thanks Andy.

Unfortunately, when I try using any of top level VIs in the driver, they

all time out when they are trying to read from the device.


Which is what led me to dig deeper into the sub-vis.  I discovered that the

reason they are timing out is because they all just get a 0 value every

time they read.  Even "TG Get Value Status" returns a zero.  But the lights

on the hedset and dongle turn from red to blue, and I can get a device

number back.  Also, the headset works susccessfully with the Neurosky apps

that ship withteh product.


Do you know how I can track down what is not working right?  Maybe

somethign in the communications setup?


Thanks.


-Matt

Member Andy-K
Member

Hi Matt,

Sometimes it can take quite a while for the first sample to come in on the driver but then all the samples after that come in right no time.  If possible, can you try running the Cont Read EEG Raw.vi example included with the driver and increase the timeout on the read?  If you look at the block diagram the read VI has an input for timeout.  If it is unwired the default is 20 seconds.  Try putting a higher number such as 30 seconds ore a minute and see if samples start to stream in before it has a chance to time out.

Member Portland_Matt
Member

Andy,

Thanks for the advice.

I increased the timeout and now things are working.

-Matt

Member eeeoaaa
Member

Hi Andy,

Thanks for everything,

I already have another type of headset that I think also use ThinkGear chip , but there is no worless connection , Mindflex, I use Arduino board to connect it with PC , like the project on :http://frontiernerds.com/brain-hack

I tryed to use the same vi , on my set , but no new usb port are detected , I think it should work , may beacuse that I'm new with LabView!

BR,

EOA

Member Andy-K
Member

Since the driver for LabVIEW is a wrapper for the .DLL based driver that NeuroSky put together, it will only work for setups that use the thinkgear driver.  It is based on having a serial stream of data through a com connection which you do not have with the Arduino setup.  With the Arduino setup you are intercepting the hardware at a much lower level.

Member Portland_Matt
Member

Hi Andy,

I've had some time over the holidays to play with the Neurosky driver.

Sometimes it takes a while for the conection to get started, but on the whole, it works pretty reliably.

Can you help me out with a little more information:

1. When I use the "alpha1" - "theta" versions of "Thinkgear Read", it takes about a second to get the data back.  If I request several of these filtered signals, even in parallel, this delay adds together causing  a large delay in my execution.  Is there a way to request that all of these filtered points be sent at the same time?

2. Do you know the frequency limits for each of these filtered signals?

3. Is there any advantage to using the filtered channels, or can I just as effectively acquire the raw data and do my own FFTs?

Thanks.

- Matt

Member Andy-K
Member

1. When I use the "alpha1" - "theta" versions of "Thinkgear Read", it takes about a second to get the data back.  If I request several of these filtered signals, even in parallel, this delay adds together causing  a large delay in my execution.  Is there a way to request that all of these filtered points be sent at the same time?

This may be a limitation of the Neurosky Driver itself but I will take a look to see if there is a way to get all of the filtered data at once.  I had not intended for multiple reads to be run in parallel for the same connection task.

2. Do you know the frequency limits for each of these filtered signals?

I am not sure, that is coming directly from the low level NeuroSky driver.  They may have more information on their site about it.

3. Is there any advantage to using the filtered channels, or can I just as effectively acquire the raw data and do my own FFTs?

That would depend on what actual processing they are doing to get those values.  I do know the filtered data is sent in regular interval packets, 1 second I think.  What is actually being done on the data is a good question.  If I get some time I will take a look at their documentation.  You can certainly filter the data yourself in LabVIEW to get the different frequency bands though.

Member Portland_Matt
Member

Hi Andy,

I've been very happy with your Neurosky driver.

However, it only offers the ability to read one of the processed signals at a time.

For example, I can read the "Attention" channel once per second, but if I want to read the "Meditation" channel also, I need to wait another second.

I would like to try to rewrite the Code Interface Node so that it grabs all the signals from the .dll once per second.

Could you post the source files for your CINs?

Thanks.

-Matt

Member Andy-K
Member

Hey guys,

I finally had some time to sit down and add some of the features you guys requested.  The new version, 1.1, has the ability to read multiple types of data at a time from the 1 second packet from the NeuroSky driver.

The other main addition is some execution timing that should drastically reduce the amount of CPU resources the driver will take while running.

I have not had a chance to test the additions too much so please let me know if there are any issues.

Thanks for all of your feedback and I hope you guys are enjoying the driver!

Andy K

Member drval
Member

Does the Neurosky interface only allow for 1 second of data being received at a time?  And, if so, is that a limitation in the device, the dll, the wrappers or all three?

Member Andy-K
Member

Everything but the raw EEG data comes in at one second intervals from the underlying NeuroSky Think Gear driver.  Essintially the answer is all three.

Member drval
Member

ok.  What about the raw EEG? To be clear> I'm not interested in anything but raw EEG?  So the rest is irrelevant to me.

Member Andy-K
Member

The raw EEG is sampled at 512 Hz for the headset I have been using and I think all of the chipsets have the same rates so far.  If you take a look at the bottom of the specifications sections of this page it shows that the EEG data is sampled at 512 Hz and the "eSense" is calculated at 1 Hz.

Member drval
Member

Yes I had seen that but wasn't sure if that meant that the "raw EEG" was already subjected to the "eSense" algorithm or some other gating such that there wasn't actually a throughput rate of 512 sps.  Do you know if the "3-100Hz hadware filtering" means that there are hardware based low and high pass filters that can not be bypassed?  Is this level of detail further specified in documentation available from Neurosky?

Member Hiba.ini
Member

Do you  have any idea what the excel sheet data generated by the VI means?
Its a bunch of random numbers without a title.

Member Andy-K
Member

Hi drval,

As far as I understand the 3-100 Hz filter involves some hardware filtering.  The ThinkGear driver that is wrapped into LabVIEW here is not capable of adjusting filtering.

Andy K

Member Andy-K
Member

Hi Hiba,

The streaming to file is implemented in the underlying driver and as far as I understand it is simply for low level debugging.  I wanted to include all of the functionality of the ThinkGear driver including the logging capabilities but there use in LabVIEW is limited.

Documentation from the header file for stream log:

As a ThinkGear Connection reads bytes from its serial stream, it may

automatically log those bytes into a log file.  This is useful primarily

for debugging purposes.  Calling this function with a valid @c filename

will turn this feature on.  Calling this function with an invalid

@c filename, or with @c filename set to NULL, will turn this feature

off.  This function may be called at any time for either purpose on a

ThinkGear Connection.

Documentation from the header file for data log:

As a ThinkGear Connection reads and parses Packets of data from its

serial stream, it may log the parsed data into a log file.  This is

useful primarily for debugging purposes.  Calling this function with

a valid @c filename will turn this feature on.  Calling this function

with an invalid @c filename, or with @c filename set to NULL, will turn

this feature off.  This function may be called at any time for either

purpose on a ThinkGear Connection.

Andy K

Member drval
Member

Hi Andy,

What's the best way to gain direct access to that documentation and any other documentation supplied by NeuroSky?

val

Member Beutlich
Member

There is a Wiki talking about the different driver APIs, and you can download them directly there, as well as get more detailed documentation for each.

App Notes and Tutorials (by ThinkGear API)

http://developer.neurosky.com/docs/doku.php?id=app_notes_and_tutorials

Member drval
Member

Yes I saw those unfortunately none of that gives me the level of detail that I'm looking for.  And BTW it isn't a "driver" that has been in LV.  It's a set of wrapper VIs around Neurosky's Windows DLL.  That's just a small technical detail but I do think it's important to point out.

Member Chee_Teck
Member

May I know if the driver works with MindWave Mobile or MindBand? Please advise. Thank you.

Member Andy-K
Member

Hi CheeTeck,

I have not tested the wrapper on anything other than the MindWave; however, any of the Neurosky devices that use the TGAM1 module should work with the LabVIEW wrapper.  The MindWave Mobile does use the TGAM1 according to the product page here.  The MindBand has the option of the TGAM1 or the TGAP1 according to the product page here.  While these have not been tested with the LabVIEW wrapper so they cannot be garunteed to work, they should work due to the consistency between them with the TGAM1 module.

I hope this is helpful!

Andy K

Member geetarguy85
Member

Hi CheeTeck,

I've just tested it with the MindWave mobile and it definitely works.

Ern

Member killer2538
Member

Sorry to bother you but is it the mindwave mobile or just the mindwave?

I look forward to work with this sensor.

Member geetarguy85
Member

Hi,

It's the Mindwave Mobile. In theory, all of Neurosky's current headsets should work with this driver as they use the same ASIC and output the same data, so the protocol for parsing the data is the same. The only differences in their current lineup are the form factor of each headset, and a difference in communication method (Mindwave uses RF, all others use Bluetooth). But I believe that this driver is  getting the data from the ThinkGear Connector so no matter which headset and communication method is used, the same data should be delivered to LabVIEW in the same manner.

Ern

Member Blueberibun
Member

Hello,

I'm using labview 2011 & when i try to open your program demo. It's appears that there are alot of missing SubVIs. How can i solve this probem?

Thank you.

Active Participant zyl7
Active Participant

Hi !

I'm a complete newbie with this kind of hardaware.

I'd like to use the headset to recognize some 'words' tought by the user (like left, right, up, down). Is it possible to do this using this LV driver ?

Thanks !

Member Andy-K
Member

Bleuberibun,

Make sure you run through these steps in this order:

Installation instructions:

  1. Follow the directions for installing the NeuroSky driver (included with the headset)
  2. Install VI package manager if not already installed
  3. Install the LabVIEW - NeuroSky Driver linked to this document

It sounds like you do not have the driver wrapper installed which includes the VIs in the demo program.

Andy

Member Andy-K
Member

zyl7,

It is going to be hard to get that level of control with the single sensor EEG of the NeuroSky.  You do have access to the raw EEG data from the sensor that you can use in different algorithms that can be implemented using LabVIEW.  Any algorithm you can implement in a text based language you should be able to implement in LabVIEW it is just a graphical approach.

Andy

Member Archiet
Member

HI

I have used this VI and have collected some data by using the file log in the example. Yet, I am not quite sure what do they represent.

The data I got is similar to "1351872241.983:[80]   115, 0073, -2.149560"

Could you give me some ideas?

Member Andy-K
Member

Hi Archiet,

The logging functionaility is what is built into the wrapped up DLL driver.  It is meant for debugging purposes.  If you just want to log data I would recommend reading the data into LabVIEW and using LabVIEW to log the data to a file.  There are examples for file IO in Help » Find Examples.

Andy

Member Archiet
Member

Hi Andy,

Thank you very much and I can export the raw data, attention/mediation data, blink strength data and the signal strength.

Yet, when i am using the demo  and select to display the graph of individual wave like alpha, I find that the wave is updated point by point even though i have choose 30 samples to be read, is that something wrong?Also, what is the sampling rate of the demo ? What is more is when running the program, there is always a warning come out which is related  to the runtime of blinkstrength

Archie

Active Participant JaredRo
Active Participant

Hi Archie,

I just downloaded and ran the demo myself.  Rather than updating point-by-point, my waveform chart would update in groups of data points equal to the Samples to Read input I selected.  Which tab do you have selected on your front panel?  The example is written such that the Samples to Read input only affects the Raw EEG graph.  The Attention and Meditation tab will update one point at a time regardless of your Samples to Read selection.  

I also did a bit of benchmarking to determine the sampling rate.  I found that on my machine the VI's read in about one data point per second. 

I didn't receive a warning when I ran the code.  Can you provide the exact text of the warning you're receiving?

Member Archiet
Member

Hi JaredRo,

  The error I recieved is" Error-10 occured at ThinkGear Blink Strength  Possible reson(s): Read time out"

This warning come out every time when I select the sample to read as 30, but when i choose less samples,says 10, the demo run normally

  For the update rate problem, I have chosen the Raw tab and seleced to display the theta,alpha or other single type brain wave. From the single type brain wave graph, it has shown that the update rate is not related to the number of samples to be read, the rate is irregular, same time is 1Hz for a point some sometimes more than 1 HZ or even stop to be updated unless I have stopped to run the Vi and restart again. Also the magnitude of the single wave is strange , degree of variation is large.

Archie

Active Participant JaredRo
Active Participant

Hi Archie,

I believe that the default timeout value for the Thinkgear Read VI is 20 seconds.  There is a timeout terminal on this VI.  Wiring a constant to this terminal that is greater than the number of samples you would like to read may prevent the timeout error from occuring. 

I tried again to recreate the update rate issues you described.  My waveform chart is always updated with groups of data points equal to my Samples to Read setting.  Have you amended the NeuroSkyDemo.vi code at all?

There is nothing in the code that would cause the sampling rate to vary drastically from iteration to iteration.  The code is just making calls to the Neurosky DLL's over and over again to get the data out.  There may be something going on within the DLL that is causing the nonuniformity in the sampling rate that you're experiencing. 

Member Archiet
Member

Hi JaredRo,

Do you mean in the Raw tab, If alpha or theta or other individual wave has been selected to be displayed, the number of updated group points is the same as the number of samples to be read?

I can obtain the same result only when I select the raw EGG, but not the selection of individaul brain wave

Thank you!

Archie

Active Participant JaredRo
Active Participant

Archie,

I am seeing the same behavior regardless of whether I choose to read in the raw EEG or an individual signal.  Regardless of my selection, the chart is updated in groups of points equal to my selection for Samples to Read.  When I read in the raw EEG, however, the chart updates much faster than when I read in any of the individual signals.

Member Archiet
Member

Hi JaredRo,

I have got the expected result as yours, the mistake must be from my modification of the code.

Seems that the sampling frequency of the raw EGG is fixed at 512Hz, and the remainig data,including individual signal, are all fixed at 1Hz,

the samples to be read is just the diaplay udate rate, not the data sampling rate, am I right?

Archie 

Active Participant JaredRo
Active Participant

Archiet,

You are correct regarding the Samples to Read terminal.  If you look within the subVI's of the driver, you will see that the Samples to Read input is wired to the count terminal of a For Loop that is directly making calls to the Neurosky DLL.  The sampling rate is determined by the DLL; the update rate is determined by the Samples to Read input.

Member audiomachine
Member

Hello Andy, I would like to implement your driver with my application in Labview, but Im having some troubles. Can you please provide me some feedback and help? Contact: sfaxonluverz@gmail.com   Thank you.