Browse Source

重构HMM初始化过程

dk 1 year ago
parent
commit
6609e3e33c
1 changed files with 2 additions and 7 deletions
  1. 2 7
      backend/bci_core/online.py

+ 2 - 7
backend/bci_core/online.py

@@ -101,8 +101,7 @@ class Controller:
 class HMMModel:
     def __init__(self, transmat=None, n_classes=2, state_trans_prob=0.6, state_change_threshold=0.5):
         self.n_classes = n_classes
-        self._probability = np.zeros(n_classes)
-        self.reset_state()
+        self.set_current_state(0)
 
         self.state_change_threshold = state_change_threshold
 
@@ -122,15 +121,11 @@ class HMMModel:
         # emission probability moving average, (5 steps)
         self._filter_b = np.ones(5) / 5
         self._z = np.zeros((len(self._filter_b) - 1, n_classes))
-
-    def reset_state(self):
-        self._probability[0] = 1.
-        self._last_state = 0
     
     def set_current_state(self, current_state):
         self._last_state = current_state
         self._probability = np.zeros(self.n_classes)
-        self._probability[current_state] = 1
+        self._probability[current_state] = 1.
     
     def step_probability(self, fs, data):
         # do preprocessing here