Open danielfonsecab opened 11 months ago
Hi Daniel,
Sorry for the delay in getting back to you, I was doing a lot of traveling yesterday!
Regarding the code, there are a couple of things that come to mind!
What data is stored within the EDF file? When we were processing our data, we were only exporting EEG voltage data and date/time data in the file. If there is more data being exported, there is the possibility that the code is reading some other data from the EDF file instead of EEG voltage.
What units of voltage is your EEG data recorded in? I believe our system default was to record EEG data in volts, so I added a line of code (line 49 in the Auto Detector V2 Code) that converted to millivolts. This could be affecting the detection of epileptic activity if the system is already recording in millivolts.
We used a set of parameters for peak detection in (line 85 in the Auto Detector V2 Code) that worked well for our animals. These may need to be adjusted depending on the EEG signal output for your own EEG recordings. This link provides some additional insight into the function of these different parameters ( https://www.mathworks.com/help/signal/ug/find-peaks-in-data.html).
Lastly, have you tried running your EEG data in EDF file format through the manual detector? By default, the manual detector allows you to see a short run of the EEG data, set a lower threshold for spike detection manually, and then review the data on screen after it is done processing. This might allow you to see what is going on in the background with the code!
Let me know if this helps or what additional questions you have. I am happy to keep troubleshooting this and would also be happy to take a look at your EDF file as well, if we don't find a resolution and you feel comfortable with that!
All the best, Kyle
On Tue, Nov 21, 2023 at 12:32 PM danielfonsecab @.***> wrote:
Hi Kyle,
I've been trying to use the code you publish with our own recordings. However, the same error pops up with all the files. The variable EEG it's missing. I assumed it was the label used to mark the volts in the recording but when I switched to the Data.Nameofthevariable it ran but did not detect any spike. I'm probably doing something wrong but I can't figure out what.
Thanks in advance,
-Daniel F
— Reply to this email directly, view it on GitHub https://github.com/Jackson-Kyle-CCOM/Automated-EEG-Algorithm/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2OORX3Q6ISN2ZODBZOMFTDYFTXSTAVCNFSM6AAAAAA7VBARXKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAYDIOJQHA3TEOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hi Kyle,
Thanks for the help. I managed to get the analysis after adjusting the units of amplitude as you suggested. However, I still have some issues regarding the correct identification and export of spikes (both the excel and graph show the same issue). I'm trying to figure the problem but I'm really new to MATLAB and I would appreciate if you could take a look. I uploaded the folder with the manual and automatic detection (with slight modifications) and a 12h EDF recording.
https://www.dropbox.com/scl/fo/i8leee96j5dxiluvd4xto/h?rlkey=r8qcjqufrn1149smfjayxbz9r&dl=0
Pd: My PI reached your PI for the same issue yesterday. I'm sorry for the double message.
-Daniel F
Hi Daniel,
No worries regarding the double communication and sorry for the delay in getting back to you!
Here are the changes I made in response to some small differences:
In your EDF file, the data is stored as "EEGEEG_1_SA_B" instead of "EEG" as it was in our files. I made this update in line 46 of the code. After making this change, the Auto version of the code started running for me.
What units of voltage are you recording in by default? I can import the data but am not sure if the data is recorded in volts, millivolts, etc.
All the best, Kyle
On Wed, Nov 22, 2023 at 4:02 PM danielfonsecab @.***> wrote:
Hi Kyle,
Thanks for the help. I managed to get the analysis after adjusting the units of amplitude as you suggested. However, I still have some issues regarding the correct identification and export of spikes (both the excel and graph show the same issue). I'm trying to figure the problem but I'm really new to MATLAB and I would appreciate if you could take a look. I uploaded the folder with the manual and automatic detection (with slight modifications) and a 12h EDF recording.
https://www.dropbox.com/scl/fo/i8leee96j5dxiluvd4xto/h?rlkey=r8qcjqufrn1149smfjayxbz9r&dl=0
Pd: My PI reached your PI for the same issue yesterday. I'm sorry for the double message.
-Daniel F
— Reply to this email directly, view it on GitHub https://github.com/Jackson-Kyle-CCOM/Automated-EEG-Algorithm/issues/1#issuecomment-1823563715, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2OORX67J3YJCE7TVASBXJDYFZY5RAVCNFSM6AAAAAA7VBARXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRTGU3DGNZRGU . You are receiving this because you commented.Message ID: @.***>
Hi Daniel,
I made some additional headway but here is a summary of everything I have updated so far.
In your EDF file, the data is stored as "EEGEEG_1_SA_B" instead of "EEG" as it was in our files. I made this update in line 46 of the code. After making this change, the Auto version of the code started running for me and detected a lower threshold value of 130 uV.
Our system for recording EEG data was set at a collection frequency of 500 data points per second, whereas your system is recording data at a frequency of 2,000 points per second. This changes the way the data is processed a little bit since your system has 4X as much data being produced. To fix this, I added a line of code (line 49: Time_seg_2 = seconds(Time_seg);) and updated line 112 to reflect this new variable.
I believe your EDF file is outputting EEG data as microvolts, so I changed line 50 to convert from microvolts into millivolts by dividing by
(Voltage_mV = Voltage_V/1000;)
I changed some of the baseline detection parameters as well, but this was a minor change.
I have got the code running and working for both manual and automatic versions. I can do some more work with optimizing detection parameters for your data later! I have included a rough image of the spike detection.
All the best, Kyle EEG Collab.zip https://drive.google.com/file/d/17bBiuQD0jNxCRPkLA7VUdy8qxnDUL0mZ/view?usp=drive_web
On Mon, Nov 27, 2023 at 5:27 PM Kyle Jackson @.***> wrote:
Hi Daniel,
No worries regarding the double communication and sorry for the delay in getting back to you!
Here are the changes I made in response to some small differences:
In your EDF file, the data is stored as "EEGEEG_1_SA_B" instead of "EEG" as it was in our files. I made this update in line 46 of the code. After making this change, the Auto version of the code started running for me.
What units of voltage are you recording in by default? I can import the data but am not sure if the data is recorded in volts, millivolts, etc.
All the best, Kyle
On Wed, Nov 22, 2023 at 4:02 PM danielfonsecab @.***> wrote:
Hi Kyle,
Thanks for the help. I managed to get the analysis after adjusting the units of amplitude as you suggested. However, I still have some issues regarding the correct identification and export of spikes (both the excel and graph show the same issue). I'm trying to figure the problem but I'm really new to MATLAB and I would appreciate if you could take a look. I uploaded the folder with the manual and automatic detection (with slight modifications) and a 12h EDF recording.
https://www.dropbox.com/scl/fo/i8leee96j5dxiluvd4xto/h?rlkey=r8qcjqufrn1149smfjayxbz9r&dl=0
Pd: My PI reached your PI for the same issue yesterday. I'm sorry for the double message.
-Daniel F
— Reply to this email directly, view it on GitHub https://github.com/Jackson-Kyle-CCOM/Automated-EEG-Algorithm/issues/1#issuecomment-1823563715, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2OORX67J3YJCE7TVASBXJDYFZY5RAVCNFSM6AAAAAA7VBARXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRTGU3DGNZRGU . You are receiving this because you commented.Message ID: @.*** com>
Hi Kyle,
Thanks for the help. Last week wasn't my best and I really messed up trying to figure out the scale of amplitude. Yesterday I started from scratch and it worked perfectly (I made the changes you suggested and started tuning the detection parameters for our model). I requested access to the drive folder you attached with my personal email. Also, it would be very helpful If you could share one of the EEG traces you worked with as I had trouble with some noisy recordings. Were you able to use noisy EEGs or do they needed to be super clean? Thanks.
Hi Daniel,
Glad to hear things are working on your end! Let me know if you encounter any other challenges or issues!
I don't have access to the files on my current computer but can send them from my laptop later this evening. Regarding noisy data, we had a couple of animals with noisy EEGs and the automatic algorithm was able to adjust for this noise when determining the baseline activity value and lower threshold. Additionally, animal movement, grooming activity, etc. often generated large amplitude spikes (>1500 uV) which the algorithm excludes automatically.
The upper threshold of 1500 uV can be adjusted in the early part of the code, as well as some of the parameters for baseline activity determination.
Hope this helps! Kyle
On Tue, Nov 28, 2023 at 12:03 PM danielfonsecab @.***> wrote:
Hi Kyle,
Thanks for the help. Last week wasn't my best and I really messed up trying to figure out the scale of amplitude. Yesterday I started from scratch and it worked perfectly (I made the changes you suggested and started tuning the detection parameters for our model). I requested access to the drive folder you attached with my personal email. Also, it would be very helpful If you could share one of the EEG traces you worked with as I had trouble with some noisy recordings. Were you able to use noisy EEGs or do they needed to be super clean? Thanks.
— Reply to this email directly, view it on GitHub https://github.com/Jackson-Kyle-CCOM/Automated-EEG-Algorithm/issues/1#issuecomment-1830402827, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2OORX6YR7SABTFSLAUHLQLYGYRN5AVCNFSM6AAAAAA7VBARXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZQGQYDEOBSG4 . You are receiving this because you commented.Message ID: @.***>
Hi Daniel,
Here is a sample of one of our EEG tracings. I can work on finding more later if needed!
I have also included a copy of both the automatic and manual code to use since these were originally optimized for this data, and there are some small differences between our systems.
All the best, Kyle
Test Folder.zip https://drive.google.com/file/d/1ouZ-EGO6wDjDalDoTwez4fmkUVBJNjM1/view?usp=drive_web
On Tue, Nov 28, 2023 at 12:03 PM danielfonsecab @.***> wrote:
Hi Kyle,
Thanks for the help. Last week wasn't my best and I really messed up trying to figure out the scale of amplitude. Yesterday I started from scratch and it worked perfectly (I made the changes you suggested and started tuning the detection parameters for our model). I requested access to the drive folder you attached with my personal email. Also, it would be very helpful If you could share one of the EEG traces you worked with as I had trouble with some noisy recordings. Were you able to use noisy EEGs or do they needed to be super clean? Thanks.
— Reply to this email directly, view it on GitHub https://github.com/Jackson-Kyle-CCOM/Automated-EEG-Algorithm/issues/1#issuecomment-1830402827, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2OORX6YR7SABTFSLAUHLQLYGYRN5AVCNFSM6AAAAAA7VBARXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZQGQYDEOBSG4 . You are receiving this because you commented.Message ID: @.***>
Hi Kyle,
I've been trying to use the code you publish with our own recordings. However, the same error pops up with all the files. The variable EEG it's missing. I assumed it was the label used to mark the volts in the recording but when I switched to the Data.Nameofthevariable it ran but did not detect any spike. I'm probably doing something wrong but I can't figure out what.
Thanks in advance,
-Daniel F