Пример #1
0
def test():
    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
    # Transitions
    cfg2 = {
        "start": TC_B,
        "end": TC_E,
        "dir": "CNNF_0_200____",
        "shift": 300
    }
    # F**k enabled
    cfg3 = {
        "start": 140,
        "end": 300,
        "dir": "CNNF_0_200____",
        "shift": 160
    }
    # 0 - 200
    cfg3 = {
        "start": 0,
        "end": 200,
        "dir": "CNNF_0_200____",
        "shift": 160
    }
    cfg = cfg3
    clf = EMG_CNN.load(cfg["dir"], params=cfg)
    handler = EMGWindowSlicer(clf, start=cfg["start"], end=cfg["end"], shift=cfg["shift"])
    EMGConnector(data_handler=handler.handle_record, communicator=None)
Пример #2
0
    def data_send_loop(self, add_data_callback_func):
        self.communicator.data_signal.connect(add_data_callback_func)
        if self.mock:
            file_name = "EEGMOCK" if self.device == Device.EEG else "EMGMOCK"
            reader = ReadSample(path_fix + file_name)
            sample = reader.read_sample()

            while sample is not None:
                time.sleep(1. / 50.)
                value = sample.channel_data
                value.append(sample.timestamp)
                self.communicator.data_signal.emit(value)
                sample = reader.read_sample()
        else:
            if self.device == Device.EEG:
                board = OBCIConnector()
                board.attach_handlers(self.data_handler)
            elif self.device == Device.EMG:
                self.exp_params.name_prefix = "EMG"
                EMGConnector(self.communicator)
Пример #3
0
    def set_overlap(self, overlap):
        overlap = min(1., max(0., overlap))
        self.w_overlap = int(overlap * self.w_length)
        self.stack.clear()

    def set_length(self, length):
        length = min(200, max(20, length))
        self.w_length = length
        self.w_overlap = int(self.w_overlap * self.w_length)
        self.stack = deque(maxlen=self.w_length)

    def handle_emg(self, emg):
        if self.lag_counter > 0:
            self.lag_counter -= 1
            return
        self.stack.append(emg[:8])
        if len(self.stack) == self.w_length:
            return self.predict()
        return None

    def reset(self):
        self.stack.clear()
        self.lag_counter = self.lag_after_reset
        self.predicted = None


if __name__ == '__main__':
    online_predictor = EasyPredictor(_set=BUZZ_SET, debug=True)
    EMGConnector(data_handler=online_predictor.handle_emg)
Пример #4
0
 def data_send_loop(self, add_data_callback_func):
     self.communicator.data_signal.connect(add_data_callback_func)
     EMGConnector(self.communicator)
Пример #5
0
 def start(self):
     self.logger = KeyboardLogger(handler=self.key_handler)
     self.logger.start()
     EMGConnector(data_handler=self.emg_handler, communicator=None)
Пример #6
0
 def data_send_loop(self, emg_callback, imu_callback):
     self.communicator.data_signal.connect(emg_callback)
     self.imu_communicator.data_signal.connect(imu_callback)
     EMGConnector(communicator=self.communicator,
                  imu_communicator=self.imu_communicator)