davidhaslacher / sass

Stimulation Artifact Source Separation
6 stars 0 forks source link

Correct usage of SASS #1

Open mglassen opened 2 years ago

mglassen commented 2 years ago

Hi David,

I tried implementing SASS on my tdcs/EEG dataset this week and I had some questions on correct usage. Following your paper(Stimulation artifact source separation (SASS) for assessing electric brain oscillations during transcranial alternating current stimulation (tACS)), : 1.) I split the recordings into 1 minute of resting EEG data with no stimulation, and 1 minute of resting EEG with 4Hz stimulation. 2.) I then applied a bandpass filter(3-5Hz) to each dataset. 3.) Used numpy.cov to get the covariance matrix for both datasets 4.) Used your script to apply SASS to the stimulation dataset

It is at step 4 that I'm a little confused. The function takes the stimulation dataset(band-pass filtered) and the 2 covariance matrices, and outputs cleaned data. My question is does the stimulation data thats fed into the function have to be band-pass filtered to the narrow stimulation frequency(in this case 4Hz) or can it be a wider band(5-50Hz). Is the narrow bandpass filter only used to get the covariance matrices for the 2 datasets, and then you can use a wider filter on the data that is input to the SASS function?

Sorry if I didn't word this clearly, I appreciate any help you can provide!

Best, Michael Glassen

EDIT:

I also realize that because I'm stimming at 4Hz, I have to apply SASS at 8Hz, 12Hz, 16Hz etc. Because I'm interested up to the beta band(30Hz), I will have to use SASS at each harmonic like you do in the paper. Does my implementation below seem correct?

1.)Narrow band pass raw data for 4Hz. 2.)Get no stim and stim covariance matrices from this narrow band filtered data 3.)Apply SASS to wider band pass filtered data(5-50Hz) 4.)Go back to raw data, apply narrow band pass for 8Hz 5.)Get both covariance matrices 6.)Apply SASS with these covariance matrices to the data output from step 3 7-End) Repeat this process for each harmonic

Thank you again!

davidhaslacher commented 2 years ago

Dear Michael,

The procedure you have suggested is the one I would follow! Unfortunately, the harmonics tend to have a slightly different spatial pattern than the base frequency, which requires repeated application of SASS. Let me know if you have success. Otherwise, you can send over your data and analysis pipeline, and I can see what I can do on my end!

Best,

David

mglassen commented 2 years ago

SASSdata.zip

Thank you so much for the quick reply! I think I have everything working, but would you mind taking a look over my script? I attached a powerpoint with few comparison figures. Since I'm stimming at 4Hz, I band pass filtered the resting and stim data separately at each harmonic up to 50Hz and applied SASS to the 5-50Hz filtered data at each frequency. When you say repeated application of SASS at the harmonics, do you just mean once at each harmonic or you have to run SASS multiple times at each one? I am definitely happy with the results, power was greatly reduced at each harmonic and the time series data looks much cleaner.

Thank you again for the help!

Best, Mike

Script used is runSASS.py

Naming convention for data: (stimCondition_FrequencyFiltered) withStim_Filt and noStim_Filt are the datasets with the wide band pass filter(5-50Hz)

cleanData.csv is the output, with SASS run once at each harmonic up to 50Hz

davidhaslacher commented 2 years ago

Dear Mike,

Thanks for sending over the sample data. What you've done so far looks fine. A few comments:

Do let me know how else I can help you!

[1] https://www.biorxiv.org/content/10.1101/2022.02.28.482226v1

mglassen commented 2 years ago

Hey David,

Thanks again for helping! I just wanted to clarify on your first point, I think I'm already doing what you suggest but I just want to make sure. I first apply a broad band-pass(1-50Hz) to the stim data and set this aside. Then I take the unfiltered stim data and non stim data, and apply a narrow band pass at each harmonic up to 50Hz, saving each dataset seperately(these are the files saved in the format stim_8, noStim_12, etc..). Then for each harmonic starting at 4Hz, I take the the narrow-band files at that frequency, get the covariance matrices and input them to your SASS function along with the broadband data. This outputs the broadband data cleaned with SASS at 4Hz for instance, then I take that output and use it as the input along with the narrowband covariance matrices for 8Hz, which should now output data cleaned at both 4Hz and 8Hz, and I repeat this all the way up to 50.

And thank you for the tip about using am-tacs instead of basic tacs, I'll bring this up to my PI and see if we can change the protocol around.

Best, Mike

davidhaslacher commented 2 years ago

Dear Mike,

yes, this would be correct. I have typically only analyzed data at the target frequency with AM-tACS, however. Let me know if it works, and if I can be of any help otherwise! Good luck.

Best,

David