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

M and N parameters #5

Open
robertoguarnieri opened this issue May 11, 2020 · 2 comments
Open

M and N parameters #5

robertoguarnieri opened this issue May 11, 2020 · 2 comments

Comments

@robertoguarnieri
Copy link

The comb filter is an implementation of the SMA method (Kohli 2019) if I am not wrong.
In that paper they have 2 parameters, M (neighboring segments) and N (the total number of segmented epochs).
In your implementation, what are the values of these 2 parameters?
Thanks

@agricolab
Copy link
Owner

agricolab commented May 12, 2020

Thanks for your interest!

In your implementation, what are the values of these 2 parameters?

TLDR

If you want to replicate SMA using convolution with a kernel, the M parameter would be NumberPeriods , while wfun = 'uniform' and symflag = 'symmetric'. N fully depends on the length of the signal you want to filter given the target frequency, and is otherwise not a parameter of the filter itself.

Long explanation

Consider that the SMA method is based on creating a template by averaging and subsequent subtraction. The implementation in ArtACS is using convolution with a (comb) kernel. Therefore mathematics differ slightly, although results would be identical under most circumstances.
If you take a look at e.g. Figure 3 of Kohli 2015:
image

N corresponds to the number of segments, and "the length of each segment matches the period of the tACS stimulation frequency". Consider therefore, that N only depends on the length of the signal you want to filter, and is not influenced by the filter itself, but only be the frequency you would want to filter. Subsequently, you go iteratively through all N segments. M defines how many segments are averaged symmetrically around the central segment, which is indexed with n. This gives you N artifact templates.

If we would use convolution, we would first have to define a kernel that does something similar to this. For this kernel, almost all values of the kernel are zeros. The width of the kernel defines how many periods (i.e. segments) one would "average" relative to the current sample. In that regard, the parameter NumberPeriods resembles M. See also this figure sma-kernel which would be the kernel resembling an M=5 SMA. Only the central entry would be 1, while the entries exactly a multiple of a period apart would be -1/M. Therefore, SMA can be implemented by convolution with a symmetric average comb kernel. But consider that there are many different possible weighing functions. At least in my simulations and test measurements, the symmetric uniform kernel was one of the best performing. Therefore, i didn't explore different weighing functions any deeper.

You can find more details in the pdf accompanying the package: https://github.com/agricolab/ArtACS_preprint/blob/master/docs/main.pdf

As a side note, consider that his package was written in 2017, but Kohli and Casson had published several papers describing their results for SMA on tACS artifacts already, e.g. Kohli 2015.

@robertoguarnieri
Copy link
Author

robertoguarnieri commented May 12, 2020

Dear,
Thank you very much for your kind reply.
What I needed was the documentation (sorry I did not find it before).
I am using N as expressed from the paper.
For M, I would use the same you used in your validation on simulated data (NumberPeriods=10). [If NumberPeriods corresponds to M in SMA]

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

No branches or pull requests

2 participants