ChrisVeigl / BrainBay

Open Source Biofeedback Software
http://brainbay.lo-res.org
Other
163 stars 52 forks source link

muse s - connecting with brainflow (python), but not with brainbay #41

Open windwerfer opened 1 year ago

windwerfer commented 1 year ago

system: win11 (all updates), python 3.11 (brainflow 5.8.2), brainbay 2.7

testing if the device will connect to my laptop: starting the default connection example (first one on https://brainflow.readthedocs.io/en/stable/Examples.html ) with (i have a muse s = board id is 39): python brainflow-connection-test.py --board-id 39 the device will be found, connected to, and some data will be recorded.

doing the same in brainbay (choosing the muse s, not the muse s BLED because i do not have the dongle) will return 'failed to prepare session 17' (instandly, no scanning done, just some error).

i tried the same today on win10 (before reformating in installing win 11) and got the same error (it would also connect through pure python-brainflow).

is it possible to use brainbay/muse without the BLED bluetooth dongle? could there be any other problems?

thank you for, writing this program. it seems amazing, i cant wait to try it out :-)

windwerfer commented 1 year ago

it was a bit late yesterday, and i did not spend as much effort preparing the post as i should have.

first i found that the brainbay forum https://brainbay.iphpbb3.com/ is not accessable from thailand (i thought it was down, thats why i did not look there first). so i will search there first now (i use a vpn now to access it).

also i started brainbay with the --debug option:

commandline:--debug initialising Brainflow object ... Brainflow: Board created. Update channels for Device ID -1, device name = Synthetic Board description = {"accel_channels":[17,18,19],"battery_channel":29,"ecg_channels":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],"eda_channels":[23],"eeg_channels":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],"eeg_names":"Fz,C3,Cz,C4,Pz,PO7,Oz,PO8,F5,F7,F3,F1,F2,F4,F6,F8","emg_channels":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],"eog_channels":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],"gyro_channels":[20,21,22],"marker_channel":31,"name":"Synthetic","num_rows":32,"package_num_channel":0,"ppg_channels":[24,25],"resistance_channels":[27,28],"sampling_rate":250,"temperature_channels":[26],"timestamp_channel":30} the package number is at channel 0 the sampling rate is 250 Number of rows:32 available channels are as follows: Now trying to add exg channels: chn1:exg chn2:exg chn3:exg chn4:exg chn5:exg chn6:exg chn7:exg chn8:exg chn9:exg chn10:exg chn11:exg chn12:exg chn13:exg chn14:exg chn15:exg chn16:exg Now trying to add eda channels: chn23:eda Now trying to add res channels: chn27:res chn28:res Now trying to add temp channels: chn26:temp Now trying to add accel channels: chn17:accel chn18:accel chn19:accel Now trying to add gyro channels: chn20:gyro chn21:gyro chn22:gyro Now trying to add ppg channels: chn24:ppg chn25:ppg Now trying to add pcount channels: chn0:pcount Now trying to add batt channels: chn29:batt Now trying to add time channels: chn30:time Now trying to add marker channels: chn31:marker Added total number of 32 data channels! Brainflow: release current Board. Brainflow: delete Board class Brainflow: Board release done. Brainflow: Board created. Update channels for Device ID 39, device name = MuseS Board description = {"eeg_channels":[1,2,3,4],"eeg_names":"TP9,Fp1,Fp2,TP10","marker_channel":7,"name":"MuseS","num_rows":8,"other_channels":[5],"package_num_channel":0,"sampling_rate":256,"timestamp_channel":6} the package number is at channel 0 the sampling rate is 256 Number of rows:8 available channels are as follows: Now trying to add exg channels: chn1:exg chn2:exg chn3:exg chn4:exg Added total number of 4 data channels! EEG Channel 1 has name TP9 EEG Channel 2 has name Fp1 EEG Channel 3 has name Fp2 EEG Channel 4 has name TP10 skipping Channel 0 Using OUT PORT 0 for BF-Channel 1 Using OUT PORT 1 for BF-Channel 2 Using OUT PORT 2 for BF-Channel 3 Using OUT PORT 3 for BF-Channel 4 skipping Channel 5 skipping Channel 6 skipping Channel 7 <- finished loading the brainflow board into my test design Brainflow: start session. <- press F7 Brainflow: Exception handler triggered.

if there are any other ways to help troubleshoot, please let me know. i would really like to fix the problem. my programming skills are not that cracked up to be (especially c++), but i can compile things if it helps.

as i said, i find this project pretty amazing. the node style scripting makes it a breeze to create my own designs without programming.. thats awsome. hope i can get it to work with my device. thanks for all the hard work!

ChrisVeigl commented 1 year ago

thank you or the detailled report! unfortunately I don't know why the problem happens, as the "Muse S" device (ID 39) should be supported. It is opened like any other device. I can try to update the Brainflow libraries and rebuild the executable, maybe this will help. I will do this in a few days when I am back at my development machine, and post a note here as soon as the update is done.

windwerfer commented 1 year ago

that would be very much appreciated. thank you, lets try that.

ChrisVeigl commented 12 months ago

i just updated the brainflow libraries and added the timeout parameter - maybe this helps, see https://github.com/ChrisVeigl/BrainBay/releases/tag/v2.8

windwerfer commented 12 months ago

thank you for the update. i tried it and there is still error nr 17 (instantly). i tried setting the timeout to 10, but it didnt change. instant error 17. i found in the brainbay programm folder the file brainflow_error_log.log and it had the following content:

[2023-07-15 17:16:44.091] [board_logger] [info] incoming json: {"file":"","file_anc":"","file_aux":"","ip_address":"192.168.4.1","ip_address_anc":"","ip_address_aux":"","ip_port":4567,"ip_port_anc":0,"ip_port_aux":0,"ip_protocol":0,"mac_address":"","master_board":-100,"other_info":"","serial_number":"","serial_port":"COM4","timeout":10} [2023-07-15 17:16:44.098] [board_logger] [info] Use timeout for discovery: 10 [2023-07-15 17:16:44.098] [board_logger] [error] failed to load lib [2023-07-15 17:16:44.098] [board_logger] [error] Failed to init dll_loader [2023-07-15 17:16:44.098] [board_logger] [error] failed to prepare session17 [2023-07-15 17:16:50.485] [board_logger] [error] failed to stop stream15

when i try to load another brainbay board (i tried the notionosc2) i get:

[2023-07-15 17:54:40.012] [board_logger] [info] incoming json: {"file":"","file_anc":"","file_aux":"","ip_address":"192.168.4.1","ip_address_anc":"","ip_address_aux":"","ip_port":4567,"ip_port_anc":0,"ip_port_aux":0,"ip_protocol":0,"mac_address":"","master_board":-100,"other_info":"","serial_number":"","serial_port":"COM4","timeout":0} [2023-07-15 17:54:45.026] [board_logger] [error] no data received in 5sec, stopping thread [2023-07-15 17:54:45.026] [board_logger] [error] WSAGetLastError is 10060 [2023-07-15 17:54:45.027] [board_logger] [error] failed to start stream7 [2023-07-15 17:54:55.740] [board_logger] [error] failed to stop stream11

it seems to fail to load some libraries. i am pretty sure that it is hard to debug from afar, is there anything i can do to help out troubleshooting? (i installed microsoft visual studio 2019 and compiled brainbay successfully, but since i have no experience in c++, i do not know what do there :-)

so it seems that it is specific to the muse device, not brainflow in general.

ChrisVeigl commented 12 months ago

thanks for these additional insights. AFAIK I copied all brainflow libraries and dlls into the brainbay folder after the new brainflow build. maybe it's a muse-related lib/dll... it's a pity that the error log doe not tell which dll is needed....

3 more things you could try:

) increase the timeout (i think it's milliseconds) to 2000 or 3000 - i remember that somebody reported that a longer time is needed for establishing connection ) copy all muse related .dlls you can find to the briainbay bin folder *) ask andrey / in the brainflow slack channel about possible reasons

windwerfer commented 11 months ago

thank you for the advice. i downloaded the git master branch from brainbay and copied the dll files over. and it worked a bit more. i now get (timeout 100s, i tried with longer values but it just freezes brainbay for longer):

{"file":"","file_anc":"","file_aux":"","ip_address":"192.168.4.1","ip_address_anc":"","ip_address_aux":"","ip_port":4567,"ip_port_anc":0,"ip_port_aux":0,"ip_protocol":0,"mac_address":"","master_board":-100,"other_info":"","serial_number":"","serial_port":"COM4","timeout":100} [2023-07-21 05:18:04.028] [board_logger] [info] Use timeout for discovery: 100 [2023-07-21 05:18:04.041] [board_logger] [info] found 1 BLE adapter(s) [2023-07-21 05:18:04.054] [board_logger] [warning] Probably bluetooth is disabled. [2023-07-21 05:19:44.055] [board_logger] [error] Failed to find Muse Device [2023-07-21 05:19:45.062] [board_logger] [error] failed to prepare session7

(but bluetooth is activated and working - tested with muselsl)

i will ask andrey / in the brainflow slack channel about possible reasons. just wanted to let you know that there is progress. thank you.

ChrisVeigl commented 11 months ago

okay -- thanks for the update! I have no idea why the BT-connection can't be opened successfully by the Brainflow library...

BTW: in case you download from the master branch (or install the current version using the setup exe) you do not need to replace the .dlls - they should be up-to-date.