コード例 #1
0
class SignalProcessor(object):
    def __init__(self, verbose=False):
        config = ConfigProvider().getProcessingConfig()
        self.maxNaNValues = config.get("maxNaNValues")
        self.lowerBound = config.get("lowerBound")
        self.upperBound = config.get("upperBound")
        self.normalize = config.get("normalize")
        self.mean = config.get("mean")
        self.samplingRate = ConfigProvider().getEmotivConfig().get(
            "samplingRate")
        self.windowSeconds = ConfigProvider().getCollectorConfig().get(
            "windowSeconds")
        self.qualUtil = QualityUtil()
        self.sigUtil = SignalUtil()
        self.verbose = verbose

    def process(self, raw, quality):
        # remove outliners
        proc = self.qualUtil.replaceOutliners(raw, NaN)

        # too much outliners?
        if self.qualUtil.isInvalidData(proc, len(raw) / self.windowSeconds):
            return None, True

        # center signal (mean = 0)
        #proc = self.sigUtil.center(proc, self.mean)

        # normalize date between -1 and 1
        #proc = self.sigUtil.normalize(proc)

        # replace Nans with zero (for fft)
        proc = self.qualUtil.replaceNans(proc)
        return proc, False
コード例 #2
0
class SignalProcessor(object):
    def __init__(self, verbose=False):
        config = ConfigProvider().getProcessingConfig()
        self.maxNaNValues = config.get("maxNaNValues")
        self.lowerBound = config.get("lowerBound")
        self.upperBound = config.get("upperBound")
        self.normalize = config.get("normalize")
        self.samplingRate = ConfigProvider().getEmotivConfig().get("samplingRate")
        self.qualUtil = QualityUtil()
        self.sigUtil = SignalUtil()
        self.verbose = verbose

    def process(self, raw, quality):
        proc = self.qualUtil.replaceOutliners(raw, 0)
        proc = self.sigUtil.normalize(proc, self.normalize)

        invalid = self.qualUtil.isInvalidData(proc)
        return proc, invalid