brainflow icon indicating copy to clipboard operation
brainflow copied to clipboard

Added support for PiEEG

Open nickgamb opened this issue 1 year ago • 1 comments

Added initial support for PiEEG board. Updated supported board docs. Added pieeg_emulator.py. Added pieeg_server.py and pieeg_client.py examples.

nickgamb avatar May 30 '24 20:05 nickgamb

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!

nickgamb avatar May 30 '24 20:05 nickgamb

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

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:

  • Reverted unrelated code style changes in CMakeLists.txt.
  • Removed emulator code that does not handle GPIO correctly.
  • Removed version setting from init.py for consistency with CI scripts.
  • Removed pieeg_client.py and pieeg_server.py as they are outside the scope of minimalistic examples.
  • Moved c_periphery to third_party folder.
  • Updated build.cmake to only include necessary libraries and restore proper Android linking.
  • Removed unnecessary socket includes and custom data sending in pieeg_board.h and pieeg_board.cpp.

Let me know what you think!

nickgamb avatar May 31 '24 17:05 nickgamb

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. Both versions handle GPIO and SPI initialization similarly, but the new version ensures better consistency. The core data reading and streaming logic remain the same, with similar approaches to handling SPI transfers and GPIO events.

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?

nickgamb avatar Jun 01 '24 03:06 nickgamb

@Ildaron do you remember what was the problem? I think it was smth about lower sampling rate and lost packages

Andrey1994 avatar Jun 01 '24 07:06 Andrey1994

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 Now Pi4 and Pi5)

Ildaron avatar Jun 01 '24 23:06 Ildaron

Which registers are changed? Can you check the code here in terms of register writes and suggest changes?

Andrey1994 avatar Jun 02 '24 16:06 Andrey1994

Hi @Andrey1994 yes of course, only I didn't find here script with the settings for registers, Hi @nickgamb can you clarify where I need check these parts

write_byte (config1, 0x96) write_byte (config2, 0xD4) write_byte (config3, 0xFF)

Ildaron avatar Jun 03 '24 15:06 Ildaron

Hi @Andrey1994 yes of course, only I didn't find here script with the settings for registers, Hi @nickgamb can you clarify where I need check these parts

write_byte (config1, 0x96) write_byte (config2, 0xD4) write_byte (config3, 0xFF)

I think you are looking for this code @Ildaron ?

https://github.com/brainflow-dev/brainflow/blob/587c0e573384d4ea5e57baf2571c72d78a186f48/src/board_controller/pieeg/pieeg_board.cpp#L71

nickgamb avatar Jun 04 '24 03:06 nickgamb

Hi @Andrey1994 yes of course, only I didn't find here script with the settings for registers, Hi @nickgamb can you clarify where I need check these parts write_byte (config1, 0x96) write_byte (config2, 0xD4) write_byte (config3, 0xFF)

I think you are looking for this code @Ildaron ?

https://github.com/brainflow-dev/brainflow/blob/587c0e573384d4ea5e57baf2571c72d78a186f48/src/board_controller/pieeg/pieeg_board.cpp#L71

Hi @nickgamb need replace only this one from spi_res = write_reg(0x03, 0xE0); to spi_res = write_reg(0x03, 0xFF); // reg3

Ildaron avatar Jun 04 '24 09:06 Ildaron

Hi @Andrey1994 yes of course, only I didn't find here script with the settings for registers, Hi @nickgamb can you clarify where I need check these parts write_byte (config1, 0x96) write_byte (config2, 0xD4) write_byte (config3, 0xFF)

I think you are looking for this code @Ildaron ? https://github.com/brainflow-dev/brainflow/blob/587c0e573384d4ea5e57baf2571c72d78a186f48/src/board_controller/pieeg/pieeg_board.cpp#L71

Hi @nickgamb need replace only this one from spi_res = write_reg(0x03, 0xE0); to spi_res = write_reg(0x03, 0xFF); // reg3

Fantastic! Thank you so much @Ildaron. I have made update.

nickgamb avatar Jun 04 '24 20:06 nickgamb

Good, could you share 10 seconds of recordings?

Andrey1994 avatar Jun 04 '24 20:06 Andrey1994

any updates? can any of you run the basic brainflow get data script and store data in a file?

Andrey1994 avatar Jun 09 '24 21:06 Andrey1994

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.

nickgamb avatar Jun 10 '24 15:06 nickgamb

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.

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. eeg_data.zip

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.

nickgamb avatar Jun 13 '24 19:06 nickgamb

Thanks, I will review everything tomorrow!

Andrey1994 avatar Jun 13 '24 20:06 Andrey1994

Moved that to #729

Andrey1994 avatar Jun 30 '24 00:06 Andrey1994