Skip to content

Commit 4a0bdb8

Browse files
committed
Documentation, Refactoring and new data savinf functions
1 parent 9739380 commit 4a0bdb8

3 files changed

Lines changed: 282 additions & 155 deletions

File tree

sciopy/EIT_16_32_64_128.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
}
3030

3131
from .sciopy_dataclasses import EitMeasurementSetup
32-
from sciopydev.sciopy.usb_message_parser import MessageParser, make_eitframes_hex, get_data_as_matrix
32+
from sciopydev.sciopy.usb_message_parser import (MessageParser, make_eitframes_hex, get_data_as_matrix,
33+
make_results_folder)
3334

3435

3536
class EIT_16_32_64_128:
@@ -581,7 +582,7 @@ def StartStopMeasurementFast(self, return_as="pot_mat"):
581582
elif return_as == "pot_mat":
582583
return self.get_data_as_matrix()
583584

584-
#todo check
585+
585586
def StartStopMeasurementNew(self, timeout:int=0, return_as="pot_mat", bSaveData:bool=False, bDeleteData:bool=False,
586587
sSavepath:str="C/", bResultsFolder=True):
587588
"""
@@ -599,8 +600,8 @@ def StartStopMeasurementNew(self, timeout:int=0, return_as="pot_mat", bSaveData:
599600
- "pot_mat": Returns the processed data as a matrix using `get_data_as_matrix()`.
600601
Default is "pot_mat".
601602
- else: data is only stored
602-
bSaveData (bool): Specifies if a the measured data is saved in NPZ format
603-
bDeleteData (bool): Specifies if a the measured data is deleted out of memory after each EITframe, with
603+
bSaveData (bool): Specifies if the measured data is saved in NPZ format
604+
bDeleteData (bool): Specifies if the measured data is deleted out of memory after each EITframe, with
604605
bSaveData=True, measured data is saved and then removed from RAM
605606
sSavepath (str): Specifies the sPath where the measured data is saved.
606607
@@ -610,14 +611,13 @@ def StartStopMeasurementNew(self, timeout:int=0, return_as="pot_mat", bSaveData:
610611

611612
# Start measurement
612613
self.cMessageParser.clear_out_data()
613-
if bResultsFolder:
614-
self.cMessageParser.make_results_folder(bResultsFolder, bSaveData, sSavepath)
614+
sCurrentPath= make_results_folder(bResultsFolder, bSaveData, sSavepath) # No new path is created if bResultsFolder=False
615615

616616
self.send_message(bytearray([0xB4, 0x01, 0x01, 0xB4]))
617617
self.cMessageParser.bPrintMessages = False
618618
if timeout != 0:
619619
self.cMessageParser.read_usb_for_seconds(timeout, bSaveData=bSaveData, bDeleteDataFrame=bDeleteData,
620-
sSavePath=sSavepath,bResultsFolder=False )
620+
sSavePath=sCurrentPath,bResultsFolder=False )
621621
else:
622622
if self.setup.burst_count ==0:
623623
print("Burst count for this setup needs to be >=1")
@@ -628,7 +628,7 @@ def StartStopMeasurementNew(self, timeout:int=0, return_as="pot_mat", bSaveData:
628628
self.send_message(bytearray([0xB4, 0x01, 0x00, 0xB4]))
629629
# All data is returned if wanted
630630
data = self.cMessageParser.read_usb_till_timeout(bSaveData=bSaveData, bDeleteDataFrame=bDeleteData,
631-
sSavePath=sSavepath, bResultsFolder=False)
631+
sSavePath=sCurrentPath, bResultsFolder=False)
632632

633633
if bDeleteData:
634634
return
@@ -639,6 +639,8 @@ def StartStopMeasurementNew(self, timeout:int=0, return_as="pot_mat", bSaveData:
639639
elif return_as == "eitframe":
640640
return data
641641

642+
643+
642644
def get_data_as_matrix(self):
643645
"""
644646
Converts the raw EIT data into a 3D matrix of potentials.

sciopy/sciopy_dataclasses.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from dataclasses import dataclass
44
from typing import List, Tuple, Union
5-
5+
import numpy.typing as npt
66

77
@dataclass
88
class EitMeasurementSetup:
@@ -211,3 +211,33 @@ class PreperationConfig:
211211
lpath: str
212212
spath: str
213213
n_samples: int
214+
215+
216+
217+
# -------------------------------------------------------------------------------------------------------------------- #
218+
@dataclass
219+
class EITFrame:
220+
"""
221+
This class is for parsing the whole EIT excitation stages (and frequency stages).
222+
Defined by Sciospec:"EIT -16,32,64,128", Chapter 5.4.1
223+
224+
Parameters
225+
----------
226+
n_el = Number of used electrodes
227+
excitation_stgs : np.array [[int1, int2]] , Features the [ESout, ESin] injection electrodes
228+
frequency_stgs : List[str] # todo
229+
timestamp1 : int Timestamp of the very first measured channel group in this frame, milli seconds?
230+
timestamp2 : int Timestamp of the very last measured channel group in this frame, milli seconds?
231+
ppcData : np.array [[Complex measured data]]
232+
for e in used excitations stages,
233+
for f in used frequency stages:
234+
for c in all used channels: -> insert complex value
235+
"""
236+
n_el: int # Number of used electrodes
237+
excitation_stgs: npt.NDArray[int] # Num Excitation Settings X 2
238+
frequency_stgs: npt.NDArray[int] # List of Frequency-Sweep Settings,
239+
timestamp1: int # [ms]
240+
timestamp2: int
241+
ppcData: npt.NDArray[complex] # Channels 1-(64) all channel groups combined
242+
243+

0 commit comments

Comments
 (0)