1
0
Selaa lähdekoodia

Fix: 若干bug

DESKTOP-4GKCI80\Neuracle 1 vuosi sitten
vanhempi
commit
fa08dff314

+ 4 - 4
backend/device/data_client.py

@@ -12,6 +12,7 @@ class NeuracleDataClient:
     def __init__(self, n_channel=9, samplerate=1000, host='localhost', port=8712, buffer_len=1):
         self.n_channel = n_channel
         self.__sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
+        self.chunk_size = int(self.UPDATE_INTERVAL * samplerate * self.BYTES_PER_NUM * n_channel)
         self.buffer = []
         self.max_buffer_length = int(buffer_len * samplerate)
         self._host = host
@@ -47,7 +48,7 @@ class NeuracleDataClient:
                 continue
 
             # unpack data
-            data = self._unpack_data()
+            data = self._unpack_data(data)
 
             # do highpass (exclude stim channel)
             data[:, :-1] = self.filter.filter_incoming(data[:, :-1])
@@ -62,8 +63,7 @@ class NeuracleDataClient:
             self.lock.release()
     
     def _unpack_data(self, bytes_data):
-        total_data = b''.join(bytes_data)
-        byte_data = bytearray(total_data)
+        byte_data = bytearray(bytes_data)
         if len(byte_data) % 4 != 0:
             raise ValueError
         data = np.frombuffer(byte_data, dtype='<f')
@@ -98,7 +98,7 @@ class NeuracleDataClient:
 
 class OnlineHPFilter:
     def __init__(self, freq=1, fs=1000):
-        self.sos = signal.butter(4, freq, btype='hp', fs=fs, output='sos')
+        self.sos = signal.butter(2, freq, btype='hp', fs=fs, output='sos')
         self._z = None
 
     def filter_incoming(self, data):

+ 1 - 1
backend/device/fubo_pneumatic_finger.py

@@ -46,7 +46,7 @@ class FuboPneumaticFingerClient:
         if init_params:
             self.port = init_params["port"]
         
-        self.init()
+        self.connect()
 
     def __del__(self):
         self.ser.close()

+ 1 - 1
backend/tests/test_neo.py

@@ -43,7 +43,7 @@ class TestNeo(unittest.TestCase):
             time.sleep(0.1)
         fs, event, data = self.receiver.get_trial_data(clear=True)
         print(event.shape)
-        self.assertTrue(event.shape[0] == 5)
+        self.assertEqual(event.shape[0], 5)
         self.assertTrue(np.allclose(event[:, 2], np.arange(1, 6)))
         self.assertTrue(data.shape[1] == settings.CONFIG_INFO['sample_rate'] * self.buffer_len)
 

+ 1 - 1
backend/tests/test_peripheral_hand.py

@@ -31,7 +31,7 @@ class TestPeripheralHand(unittest.TestCase):
 
     def test_start_extend_success(self):
         client = FuboPneumaticFingerClient(init_params)
-        client.client.extend()
+        client.extend()
         time.sleep(3)
         client.close()