Skip to content
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

restore support for pieeg #729

Merged
merged 4 commits into from
Jul 14, 2024
Merged

restore support for pieeg #729

merged 4 commits into from
Jul 14, 2024

Conversation

Andrey1994
Copy link
Member

Recreate #723 from a local branch

Hi @nickgamb! Great work on this, I wanted to push some minor changes in code style fixes and also wanted to remove some extra stuff which remained from Android part. And to dont affect your master branch(also think I have no permissions for pushing there) recreated your PR frrom a local branch with some extra changes made by me

Signed-off-by: Andrey Parfenov <[email protected]>

Author:    Nick Gamb <[email protected]>
Date:      Sun Jun 30 02:40:04 2024 +0200
@Andrey1994
Copy link
Member Author

We need a final testing round on it, cannot be merged wo confirmation from somebody with device and I dont have one

@nickgamb
Copy link

nickgamb commented Jul 13, 2024

eeg_data_brainflow_3.csv

Hi @Andrey1994 I have the board and can try but I notice the amplitude on the data when using ConsciousLabs ThinkPulse electrodes is low. I typically need change the gain when using these to 8 or more.

    uint8_t reg_address = 0x04 + channel;
    uint8_t reg_value = 0x04 | gain;

Other than that things seem to be working. I compiled this branch on a pi4 with a pieeg hat connected and used brainflow to acquire the data. I did not apply any filtering. When I have time this weekend I will increase the gain and recompile to see if that can improve the result with my setup.

Hope that helps some - if not perfect.

@Andrey1994
Copy link
Member Author

can you store all the data as in brainflow? without filtering for eeg channels. One of tests to run is to run it for 10 seconds and see how many rows there are in the file

@Andrey1994
Copy link
Member Author

I am not sure about gain, as far as I understand somehow its used here

            for (size_t i = 0; i < eeg_channels.size (); i++)
            {
                int offset = 3 * i + 3;
                uint32_t voltage = (buf[offset] << 8) | buf[offset + 1];
                voltage = (voltage << 8) | buf[offset + 2];
                uint32_t voltage_test = voltage | data_test;
                if (voltage_test == data_check)
                {
                    voltage = 16777214 - voltage;
                }

                package[eeg_channels[i]] = 0.27 * voltage;
            }

And assuming that everything is correct, if you change the gain you need to update these equations. In the end resulting voltage will be the same I think

@Andrey1994
Copy link
Member Author

Andrey1994 commented Jul 14, 2024

Maybe @Ildaron knows how to update equations for a new gain, to be honest I stll dont get why this conversion is not the same as for openbci devices

@nickgamb
Copy link

nickgamb commented Jul 14, 2024 via email

@Andrey1994
Copy link
Member Author

we can add support for setting gain via config_board method, it may look like this:

board.config_board("{"channel_number": 1, "gain": 8}")

Other formats for it are also ok.
But equations to calculate resulting voltage should be updated. BrainFlow returns lets call it "body" voltage and apparently this value should not be increased by multiple times when you change the gain. As I understand it gain is more like sensitivity setting

@Andrey1994
Copy link
Member Author

and config_board stuff can be done in a separated PR

@nickgamb
Copy link

nickgamb commented Jul 14, 2024 via email

@nickgamb
Copy link

nickgamb commented Jul 14, 2024

pieeg_brainflow_data.csv

Figure_1

Hi @Andrey1994 . This data was taken using brainflow_get_data.py using my headset sitting in a forest far away from most interference.

I think it is looking promising.

@Andrey1994 Andrey1994 merged commit ebe6c25 into master Jul 14, 2024
34 checks passed
@Andrey1994
Copy link
Member Author

thanks! looks awesome, I will create new release with pieeg support

@Andrey1994 Andrey1994 deleted the pieeg branch August 20, 2024 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants