-
-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for PiEEG #723
Conversation
Fixed multiple bugs.
Updated pieeg_board to handle websocket
Updated docs and emulator for pieeg support. Included pieeg_server.py and pieeg_client.py examples in the python_package\examples folder.
Hi @Andrey1994! This is a draft PR for PiEEG board support. I am new to BrainFlow and it would help me a lot if you could take a peek at this draft when you have a moment. No rush. I want to iterate on this until you feel it is a solid PR. Please let me know what you think! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, good overall, I did initial check. First of all, there are some changes not related to pieeg, they should not be a part of this PR. Also, it should not send any data from brainflow direcrtly using custom implementations, there are methods like add_streamer
and streaming_board
which do it in a uniform manner. I also dont understand how emulator can work
@@ -1,70 +1,96 @@ | |||
cmake_minimum_required (VERSION 3.13) | |||
project (brainflow) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these code style changes are not related to pieeg, and should be reverted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted the code style changes not related to PIEEG as requested.
|
||
if __name__ == "__main__": | ||
logging.basicConfig(level=logging.INFO) | ||
start_emulator("/dev/ttyUSB0") # Adjust the port as necessary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont understand how it can work, since pieeg also uses /dev/gpiochip0 which is not emulated here afaict. Emulator is not a strict requirement, so maybe it can be skipped(remove it if doesnt work, I have no idea how to emulate gpio)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the emulator code as it does not handle GPIO emulation correctly and is not required for this PR.
python_package/brainflow/__init__.py
Outdated
from brainflow.utils import * | ||
|
||
__version__ = "0.0.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version is set in CI scripts, they parse setup.py and override its content. For consistency I would recommend to remove it from here or parse it also in CI and override for publishing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the version setting from init.py to maintain consistency with CI scripts.
@@ -0,0 +1,83 @@ | |||
import logging | |||
import socket |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we maintain only minimalistic examples, its ok to create smth like brainflow_get_data.py for pieeg only, but stuff like sending data, etc is outside from the scope of these examples, so please remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed pieeg_client.py as it is outside the scope of minimalistic examples maintained by the project.
import threading | ||
import time | ||
import logging | ||
from brainflow.board_shim import BoardShim, BrainFlowInputParams, BoardIds, BrainFlowError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove it also, and for streaming data between nodes and processes, we have streaming board
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed pieeg_server.py as data streaming should be handled by high-level APIs like streaming boards or user implementations.
#include "timestamp.h" | ||
|
||
#ifdef __ANDROID__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not related to pieeg, should be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted changes to emotibit.cpp - not related to pieeg.
@@ -0,0 +1,184 @@ | |||
* v2.4.2 - 07/05/2023 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c_periphery should be in third_party folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c_periphery moved to third_party folder and build.cmake updated.
#include "board.h" | ||
#include "board_controller.h" | ||
#include "math.h" | ||
#include "socket_server_tcp.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does it need socket?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the unnecessary socket_server_tcp.h inclusion.
return (int)BrainFlowExitCodes::UNABLE_TO_OPEN_PORT_ERROR; | ||
} | ||
|
||
server_socket = new SocketServerTCP("0.0.0.0", params.ip_port, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the socket server initialization as data streaming should not be handled here.
// Send data over TCP | ||
if (server_socket && server_socket->client_connected) | ||
{ | ||
server_socket->send(package, num_rows * sizeof(double)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should not send anything from here, idea of this code is to read data straight on raspberry pi and if its needed to be sent to PC or somewhere use high level API like streaming boards, or user's own implementations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the custom data sending code as streaming should be done via high-level APIs.
- Removed socket-related code from PIEEGBoard to adhere to high-level API usage for data streaming. - Moved the c_periphery library to the third_party folder. - Updated CMakeLists and build.cmake to conditionally include and link periphery only when needed. - Removed unnecessary 'c' and 'm' libraries from the target_link_libraries. - Removed the emulator script and unnecessary examples from the PR.
Reverting emotibit.cpp changes.
Hi @Andrey1994, Thank you for the review! I have think I have addressed all of the feedback and pushed the necessary changes. The following updates have been made:
Let me know what you think! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the difference between this and implementation which we had? I remember there were issues, did you fix them here or was it in fw/hw? Can you share brainflow_get_data.py data dumped to a file?(use add_streamer("file://data.csv:w")
right after prepare_session
to store data)
After reviewing the implementation that you had previously I found that the approach is very similar. The new version has improved class naming and consistency in logging and error handling. I am not able to be at my desk this weekend but I will upload a dump as soon as possible next week. I stream the data to my Android app over a socket so I can confirm that the board is collecting the data and it appears to be functioning as expected. I have more testing to do for sure. If you can tell me more about the issue you had in the past I can attempt to replicate it? |
@Ildaron do you remember what was the problem? |
Hey @Andrey1994 @nickgamb yes there was definitely a problem with packet loss, I also changed the register values in the latest versions, and now works well , and then I tested Pi3 |
Which registers are changed? Can you check the code here in terms of register writes and suggest changes? |
Hi @Andrey1994 yes of course, write_byte (config1, 0x96) |
I think you are looking for this code @Ildaron ?
|
Hi @nickgamb need replace only this one |
Adjusted reg3 from spi_res = write_reg(0x03, 0xE0); to spi_res = write_reg(0x03, 0xFF);
Fantastic! Thank you so much @Ildaron. I have made update. |
Good, could you share 10 seconds of recordings? |
any updates? can any of you run the basic brainflow get data script and store data in a file? |
Hey @Andrey1994 . I have not forgotten about this and I appreciate your patience. I took a tech break for the weekend to spend time with my family. I also am waiting for a new set of electrodes from OpenBCI. I was using some equipment on loan to get started and needed to buy my own. They shipped last week but tracking is showing delivery to me on Wednesday. If you can hold for a little longer I will plug the new electrodes in as soon as I open the package and run the test. |
Adjusted CMakeLists.txt and board__controller build.cmake to properly build periphery and link when defined.
Hi @Andrey1994. Thank you for your patience. I seem to have not received ear clips so I am stuck using 2 of my signal electrodes for ref and biasout at the moment. That means I only have 6 channels for signal. I am buying what I need but was able to pull this data for you to show the progress. Again this is only 6 channels with 2 flat ThinkPulse electrodes operating as temp ref and biasout. Please let me know if you are seeing anything. This was not taken in a great environment so there is noise but I think it should be functioning as expected considering. |
Thanks, I will review everything tomorrow! |
Moved that to #729 |
Added initial support for PiEEG board.
Updated supported board docs.
Added pieeg_emulator.py.
Added pieeg_server.py and pieeg_client.py examples.