Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
agricolab committed Mar 20, 2022
1 parent 9fbb4fa commit e8f92fd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 53 deletions.
29 changes: 29 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-20.04
tools:
python: "3.9"
# You can also specify other tool versions:
# nodejs: "16"
# rust: "1.55"
# golang: "1.17"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: doc/conf.py

# If using Sphinx, optionally build your docs in additional formats such as PDF
# formats:
# - pdf

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: doc/requirements.txt
56 changes: 3 additions & 53 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,10 @@ Its development is supported by the [BMBF: FKZ 13GW0119](https://www.medizintech
#### Weighted Comb Filter
Artifacts can be _non-stationary_ and _non-sinusoidal_, but are required to be _periodic_. Comb filters natively support only frequencies which are integer divisibles of the sampling frequency. This can be circumvented by resampling the signal, and has been implemented.

##### Creation
#### Documentation

The following example creates a kernel for a _classical_ causal comb filte for
an artifcat with a period of 10Hz and sampled at 1000Hz:
```{python}
kernel = create_kernel(
freq=10, fs=1000, width=1, left_mode="uniform", right_mode="none"
)
```

or the superposition of moving averages (SMA) filter as discussed e.g. by [1],
here for 5 periods at 10 Hz and at 1000Hz sampling rate:
See

```{python}
kernel = create_kernel(freq=10, fs:1000, width:5,
left_mode:str='uniform',
right_mode:str='uniform')
```


[1]: Kohli, S., Casson, A.J., 2015. Removal of Transcranial a.c. Current Stimulation
artifact from simultaneous EEG recordings by superposition of moving averages.
Conf Proc IEEE Eng Med Biol Soc 2015, 3436–3439.
https://doi.org/10.1109/EMBC.2015.7319131

##### Application

The kernels, once created can be applied to the signal as follows:

```{python}
filtered_data = filter_2d(artifacted_data, freq=20, fs=1000, kernel:ndarray)
```

The kernel application is implemented for 2-dimensional data, which calls the
1-dimensional implementation in a for-loop. Consider that you have to specify
the artifact frequency and sampling rate again. This is because the kernel only
makes sense if the period is an integer divisible of the sampling rate.
If it is not, the signal is automaticall up-sampled, processed, and down-sampled.
This allows to remove the artifact, but is far from perfect. Additionally,
the function estimates the period of the kernel, and throws an exception if
it does not match the specified frequency. This ensures that the correct kernel
is used.

### Periodic Component Removal

An alternative is the creation and removal of periodic templates, until the
artifact power is sufficiently suppressed. This can be achieved using

```{python}
from artacs import StepwiseRemover
remover = StepwiseRemover(freq=20, s=1000)
filtered_data = remover.process(artifacted_data)
```
#### Matlab

See also [![DOI](https://zenodo.org/badge/87182503.svg)](https://zenodo.org/badge/latestdoi/87182503) for a similar implementation in Matlab.


0 comments on commit e8f92fd

Please sign in to comment.