Skip to content

Commit

Permalink
Add downsampling pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
m2-farzan committed Feb 9, 2021
1 parent 62d0387 commit cfba5ec
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions moabb/pipelines/resample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from scipy.signal import resample
from sklearn.base import BaseEstimator, TransformerMixin


"""
Implements Sakhavi 2018
(https://ieeexplore.ieee.org/document/8310961)
section III, sub-section B, item 4.
"""
class Resample(TransformerMixin, BaseEstimator):
def __init__(self, old_fs=250, new_fs=10):
self.old_fs = old_fs
self.new_fs = new_fs

def fit(self, X, y):
return self

def transform(self, X):
n_samples_new = round( X.shape[2] * self.new_fs / self.old_fs )
return resample(X, n_samples_new, axis=2)

0 comments on commit cfba5ec

Please sign in to comment.