Skip to content

Commit bc6d967

Browse files
authored
Dev (#23)
* new example * v=0.4.3 * inserted n_el 16 and 32 save dicts * updated example scripts * new example for converting measurement directorys to csv * first implementation of npz to csv * corrected plot angle * fixed position error of measurement * 0.4.4 * added logo * deleted section * new release of 0.4.2 * added 0.5.0 * linting * appended ScioSpecMeasurementConfig * update examples * linting * flake * Update README.md * updated docstring and resolved import error * linting * deleted old docs * added excitation frequency * Inserted exc_freq to dependent files. * v==0.5.2 * prep for pytest publish * pctr * updated picture * v==0.6.0 * changed logo * Update README.md * v==0.6.1 * Update README.md * angle correction * inserted daytime and temperature * docstring and data format * temperature visualization * linting * new visualization and black linting==23.1.0 * updated black==23.1.0 * pypitest==0.6.1.4 * pypi test == 0.6.1.5 * pypi test == 0.6.1.5 * v==0.6.2 * implemented visualization, not added to init * linting * linting#2 * linting #3 * meshing * inserted citation cff * added citation cff * zenodo doi * inserted absolute valued potential data * Implemented mesh generation * gitignore .vscode * inserted raw string for fixing error. * changed function names and inserted v computation * linting * docstring and function descriptions. * linting * skipping first measured value * changed absolute label at potential matrix * init. mesh for import * first try to use pyvista * pyvisa changes * changed prepare for ml routine * merge dev to 3d * updated function * added file in ignore * modified configurations and added an example for 32 electrodes measurement * modified burst count * deleted prototyping functions. * ignored .vsc settings * updated reqs * fixed npz to csv conversion error * changed names of example measurements * deleted unspecified measurement example. * Adjusting the configurations * Ready for test measurements using 32 electrodes. * Inserted Issue marker in npz_to_csv.npz * working example measurement scripts * updated setup_m * linting and ignore * linting and updates * new example script * pypi test release * new release v==0.6.4 * updated readme * Updated Readme TDB * preperations for Ethernet connection * new pytest version and typos * linting * updated and undo some changes from pytest 0.6.4.7 * release==0.6.4.8 * channel group repeated bug resolved. * Added further information, optimized the .gitignore. * fixed current computation configuration bug. * v0.6.5 * fixed data type error * enables multiple pattern measurements * added package function to readme * typo documentation * linting * SoftwareReset usb-hs * docstring update * fixed variable name error * updated example
1 parent 495446a commit bc6d967

7 files changed

Lines changed: 72 additions & 191 deletions

File tree

examples/custom_measurement.py

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,47 @@
22

33
from sciopy import (
44
SystemMessageCallback,
5-
set_measurement_config,
6-
connect_COM_port,
7-
StartStopMeasurement,
8-
reshape_full_message_in_bursts,
9-
del_hex_in_list,
10-
split_bursts_in_frames,
5+
sciospec_measurement,
6+
connect_COM_port_usb_hs,
7+
set_measurement_config_usb_hs,
8+
SystemMessageCallback_usb_hs,
119
)
1210

1311
from sciopy.sciopy_dataclasses import ScioSpecMeasurementSetup
1412

1513
s_path = ""
16-
files_offset = 0
1714

18-
sciospec_measurement_setup = ScioSpecMeasurementSetup(
15+
Sciospec = connect_COM_port_usb_hs()
16+
17+
ssms = ScioSpecMeasurementSetup(
1918
burst_count=1, # The number of measurements to be performed.
20-
total_meas_num=10, # Repetitions of burst count
21-
n_el=64, # Set 16, 32, 48 or 64 and do not forget to change the channel_group.
19+
total_meas_num=1, # Repetitions of burst count
20+
n_el=32, # Set 16, 32, 48 or 64 and do not forget to change the channel_group.
2221
channel_group=[
2322
1,
2423
2,
25-
3,
26-
4,
2724
], # Use [1] for n_el=16, [1,2] for n_el=32, [1,2,3] for n_el=48, and [1,2,3,4] for n_el=64
28-
exc_freq=10_000, # 10,000Hz = 10kHz
29-
framerate=5, # Measurements per second
25+
exc_freq=125_000, # 10,000Hz = 10kHz
26+
framerate=10, # Measurements per second
3027
amplitude=0.01, # 0.01A = 10mA (maximum)
31-
inj_skip=0, # injection electrode skip
28+
inj_skip=16, # injection electrode skip
3229
gain=1,
3330
adc_range=1, # +/- 1V
34-
notes="None", # add measurement information
35-
configured=False,
31+
notes="test measurement", # add measurement information
32+
configured=True,
3633
)
3734

38-
# Connect ScioSpec device
39-
COM_ScioSpec = connect_COM_port(port="/dev/ttyACM0")
40-
41-
# Send configuration
42-
set_measurement_config(serial=COM_ScioSpec, ssms=sciospec_measurement_setup)
43-
44-
# Read out system callback
45-
SystemMessageCallback(COM_ScioSpec, prnt_msg=True)
46-
47-
# Start and stop single measurement
48-
measurement_data_hex = StartStopMeasurement(COM_ScioSpec)
49-
# Delete hex in mesured buffer
50-
measurement_data = del_hex_in_list(measurement_data_hex)
51-
# Reshape the full mesaurement buffer. Depending on number of electrodes
52-
split_measurement_data = reshape_full_message_in_bursts(
53-
measurement_data, sciospec_measurement_setup
54-
)
55-
measurement_data = split_bursts_in_frames(
56-
split_measurement_data, sciospec_measurement_setup
57-
)
35+
set_measurement_config_usb_hs(Sciospec, ssms)
36+
SystemMessageCallback_usb_hs(Sciospec, prnt_msg=True)
5837

59-
# Set to "True" to save single measurement
60-
save = True
38+
sciospec_data = sciospec_measurement(Sciospec, ssms)
6139

62-
if save:
63-
for bursts in measurement_data:
64-
np.savez(
65-
s_path + "sample_{0:06d}.npz".format(files_offset),
66-
config=sciospec_measurement_setup,
67-
data=bursts,
68-
)
69-
files_offset += 1
70-
SystemMessageCallback(COM_ScioSpec, prnt_msg=False)
40+
file_idx = 0
41+
for bursts in sciospec_data:
42+
np.savez(
43+
s_path + "sample_{0:06d}.npz".format(file_idx),
44+
config=ssms,
45+
data=bursts,
46+
)
47+
file_idx += 1
48+
SystemMessageCallback(COM_ScioSpec, prnt_msg=False)

examples/measurement_n_el_16.py

Lines changed: 0 additions & 71 deletions
This file was deleted.

examples/measurement_n_el_32.py

Lines changed: 0 additions & 71 deletions
This file was deleted.

sciopy/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
convert_fulldir_doteit_to_npz,
99
)
1010

11+
1112
from .com_handling import (
1213
available_serial_ports,
1314
connect_COM_port,
@@ -20,6 +21,7 @@
2021
set_measurement_config_usb_hs,
2122
SystemMessageCallback_usb_hs,
2223
StartStopMeasurement_usb_hs,
24+
SoftwareReset_usb_hs,
2325
)
2426

2527
from .print_command_info import (
@@ -102,6 +104,8 @@
102104
mesh_sample,
103105
)
104106

107+
from .sciospec_hs import sciospec_measurement
108+
105109
# TBD from .configurations import configuration_01
106110

107111
__all__ = [
@@ -123,6 +127,7 @@
123127
"set_measurement_config_usb_hs",
124128
"SystemMessageCallback_usb_hs",
125129
"StartStopMeasurement_usb_hs",
130+
"SoftwareReset_usb_hs",
126131
# .print_command_info
127132
"print_syntax",
128133
"print_general_system_messages",
@@ -190,4 +195,6 @@
190195
"add_circle_anomaly",
191196
"plot_mesh",
192197
"mesh_sample",
198+
# .sciospec_hs
199+
"sciospec_measurement",
193200
]

sciopy/sciospec_hs.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
try:
2+
import serial
3+
except ImportError:
4+
print("Could not import module: serial")
5+
6+
from sciopy import (
7+
StartStopMeasurement_usb_hs,
8+
del_hex_in_list,
9+
reshape_full_message_in_bursts,
10+
split_bursts_in_frames,
11+
)
12+
13+
from sciopy.sciopy_dataclasses import ScioSpecMeasurementSetup
14+
15+
16+
def sciospec_measurement(COM_Sciospec, ssms: ScioSpecMeasurementSetup) -> None:
17+
measurement_data_hex = StartStopMeasurement_usb_hs(COM_Sciospec)
18+
measurement_data = del_hex_in_list(measurement_data_hex)
19+
split_measurement_data = reshape_full_message_in_bursts(measurement_data, ssms)
20+
measurement_data = split_bursts_in_frames(split_measurement_data, ssms)
21+
return measurement_data

sciopy/usb_hs_handling.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from pyftdi.ftdi import Ftdi
22
import struct
3+
import time
34
from typing import Union
45
from sciopy.sciopy_dataclasses import (
56
ScioSpecMeasurementSetup,
@@ -266,3 +267,19 @@ def StartStopMeasurement_usb_hs(serial: Ftdi, print_msg: bool = False) -> list:
266267
serial.write_data(bytearray([0xB4, 0x01, 0x00, 0xB4]))
267268
SystemMessageCallback_usb_hs(serial, prnt_msg=False, ret_hex_int="int")
268269
return measurement_data_hex
270+
271+
272+
def SoftwareReset_usb_hs(serial: Ftdi, print_msg: bool = True) -> None:
273+
"""
274+
Reset the ScioSpec device.
275+
276+
Parameters
277+
----------
278+
serial : Ftdi
279+
USB-HS serial connection
280+
print_msg : bool, optional
281+
print the callback message, by default True
282+
"""
283+
serial.write_data(bytearray([0xA1, 0x00, 0xA1]))
284+
time.sleep(5)
285+
SystemMessageCallback_usb_hs(serial, print_msg)

setup.py

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

33
setuptools.setup(
44
name="sciopy",
5-
version="0.7.1",
5+
version="0.7.1.3",
66
author="Jacob Peter Thönes",
77
author_email="jacob.thoenes@uni-rostock.de",
88
description="Python based interface module for communication with the Sciospec Electrical Impedance Tomography (EIT) device.",

0 commit comments

Comments
 (0)