Skip to content

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
agricolab committed Sep 25, 2018
1 parent 3ff58d7 commit 1ccd1b9
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 341 deletions.
2 changes: 0 additions & 2 deletions artacs/helper/__init__.py

This file was deleted.

72 changes: 0 additions & 72 deletions artacs/helper/api.py

This file was deleted.

166 changes: 0 additions & 166 deletions artacs/helper/peaks.py

This file was deleted.

17 changes: 15 additions & 2 deletions artacs/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
Object-oriented implementation
------------------------------
There exists also an object-oriented implementation.
There exists also an object-oriented implementation as follows::
kernel =
"""
Expand Down Expand Up @@ -280,7 +282,15 @@ def apply_kernel(indata:ndarray, fs:int, freq:int, kernel:ndarray):

#%%
class CombKernel():
'''Object-oriented comb kernel filter
Example to create and apply classical comb kernel::
kernel = CombKernel(freq=20, fs=1000, width=1,
left_mode='uniform', right_mode ='none')
kernel.apply(artifacted_signal)
'''
def __init__(self, freq:int, fs:int, width:int,
left_mode:str='uniform',
right_mode:str='uniform') -> None:
Expand All @@ -298,9 +308,12 @@ def _update_kernel(self):
self._left_mode,
self._right_mode)

def __call__(self, indata:np.array) -> ndarray:
def apply(self, indata:ndarray):
return apply_kernel(indata=indata, freq=self._freq, fs=self._fs,
kernel=self._kernel)

def __call__(self, indata:ndarray) -> ndarray:
return self.apply(indata)

def __repr__(self):
return (f'KernelFilter({self._freq}, {self._fs}, {self._width}, ' +
Expand Down
13 changes: 7 additions & 6 deletions artacs/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@author: rgugg
"""
from numpy import ndarray
import numpy as np
import artacs.tools as tools
import logging
Expand Down Expand Up @@ -64,11 +65,11 @@ def prepare_data(self, indata):
data, period, fs = self.inbound_resample(valid_data)
seeds = self.calc_seeds(period)
return data, period, fs, seeds

def __call__(self, indata):
def __call__(self, indata:ndarray) -> ndarray:
return self.process(indata)

def process(self, indata):
def process(self, indata:ndarray):
'process all channels of a dataset'
if self.true_period is None:
print('Invalid period length, skipping artifact removal')
Expand All @@ -93,7 +94,7 @@ def process(self, indata):
print(']',end='\n')
return np.squeeze(outdata)

def process_channel(self, indata):
def process_channel(self, indata:ndarray) -> ndarray:
'process a single channels of data'
if self.true_period is None:
print('Invalid period length, skipping artifact removal')
Expand All @@ -117,7 +118,7 @@ def process_channel(self, indata):

return outdata

def _process(self, data, period, fs, seed):
def _process(self, data:ndarray, period:int, fs:int, seed:int):
converged = False
iteration = 0
fdata = data.copy()
Expand All @@ -133,4 +134,4 @@ def _process(self, data, period, fs, seed):
converged = True
else:
fdata[put_where] -= template
return put_where, fdata[put_where]
return put_where, fdata[put_where]
Loading

0 comments on commit 1ccd1b9

Please sign in to comment.