Skip to content

Commit

Permalink
Dev (#23)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
JacobTh98 authored Aug 30, 2024
1 parent 495446a commit bc6d967
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 191 deletions.
74 changes: 26 additions & 48 deletions examples/custom_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,47 @@

from sciopy import (
SystemMessageCallback,
set_measurement_config,
connect_COM_port,
StartStopMeasurement,
reshape_full_message_in_bursts,
del_hex_in_list,
split_bursts_in_frames,
sciospec_measurement,
connect_COM_port_usb_hs,
set_measurement_config_usb_hs,
SystemMessageCallback_usb_hs,
)

from sciopy.sciopy_dataclasses import ScioSpecMeasurementSetup

s_path = ""
files_offset = 0

sciospec_measurement_setup = ScioSpecMeasurementSetup(
Sciospec = connect_COM_port_usb_hs()

ssms = ScioSpecMeasurementSetup(
burst_count=1, # The number of measurements to be performed.
total_meas_num=10, # Repetitions of burst count
n_el=64, # Set 16, 32, 48 or 64 and do not forget to change the channel_group.
total_meas_num=1, # Repetitions of burst count
n_el=32, # Set 16, 32, 48 or 64 and do not forget to change the channel_group.
channel_group=[
1,
2,
3,
4,
], # 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
exc_freq=10_000, # 10,000Hz = 10kHz
framerate=5, # Measurements per second
exc_freq=125_000, # 10,000Hz = 10kHz
framerate=10, # Measurements per second
amplitude=0.01, # 0.01A = 10mA (maximum)
inj_skip=0, # injection electrode skip
inj_skip=16, # injection electrode skip
gain=1,
adc_range=1, # +/- 1V
notes="None", # add measurement information
configured=False,
notes="test measurement", # add measurement information
configured=True,
)

# Connect ScioSpec device
COM_ScioSpec = connect_COM_port(port="/dev/ttyACM0")

# Send configuration
set_measurement_config(serial=COM_ScioSpec, ssms=sciospec_measurement_setup)

# Read out system callback
SystemMessageCallback(COM_ScioSpec, prnt_msg=True)

# Start and stop single measurement
measurement_data_hex = StartStopMeasurement(COM_ScioSpec)
# Delete hex in mesured buffer
measurement_data = del_hex_in_list(measurement_data_hex)
# Reshape the full mesaurement buffer. Depending on number of electrodes
split_measurement_data = reshape_full_message_in_bursts(
measurement_data, sciospec_measurement_setup
)
measurement_data = split_bursts_in_frames(
split_measurement_data, sciospec_measurement_setup
)
set_measurement_config_usb_hs(Sciospec, ssms)
SystemMessageCallback_usb_hs(Sciospec, prnt_msg=True)

# Set to "True" to save single measurement
save = True
sciospec_data = sciospec_measurement(Sciospec, ssms)

if save:
for bursts in measurement_data:
np.savez(
s_path + "sample_{0:06d}.npz".format(files_offset),
config=sciospec_measurement_setup,
data=bursts,
)
files_offset += 1
SystemMessageCallback(COM_ScioSpec, prnt_msg=False)
file_idx = 0
for bursts in sciospec_data:
np.savez(
s_path + "sample_{0:06d}.npz".format(file_idx),
config=ssms,
data=bursts,
)
file_idx += 1
SystemMessageCallback(COM_ScioSpec, prnt_msg=False)
71 changes: 0 additions & 71 deletions examples/measurement_n_el_16.py

This file was deleted.

71 changes: 0 additions & 71 deletions examples/measurement_n_el_32.py

This file was deleted.

7 changes: 7 additions & 0 deletions sciopy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
convert_fulldir_doteit_to_npz,
)


from .com_handling import (
available_serial_ports,
connect_COM_port,
Expand All @@ -20,6 +21,7 @@
set_measurement_config_usb_hs,
SystemMessageCallback_usb_hs,
StartStopMeasurement_usb_hs,
SoftwareReset_usb_hs,
)

from .print_command_info import (
Expand Down Expand Up @@ -102,6 +104,8 @@
mesh_sample,
)

from .sciospec_hs import sciospec_measurement

# TBD from .configurations import configuration_01

__all__ = [
Expand All @@ -123,6 +127,7 @@
"set_measurement_config_usb_hs",
"SystemMessageCallback_usb_hs",
"StartStopMeasurement_usb_hs",
"SoftwareReset_usb_hs",
# .print_command_info
"print_syntax",
"print_general_system_messages",
Expand Down Expand Up @@ -190,4 +195,6 @@
"add_circle_anomaly",
"plot_mesh",
"mesh_sample",
# .sciospec_hs
"sciospec_measurement",
]
21 changes: 21 additions & 0 deletions sciopy/sciospec_hs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
try:
import serial
except ImportError:
print("Could not import module: serial")

from sciopy import (
StartStopMeasurement_usb_hs,
del_hex_in_list,
reshape_full_message_in_bursts,
split_bursts_in_frames,
)

from sciopy.sciopy_dataclasses import ScioSpecMeasurementSetup


def sciospec_measurement(COM_Sciospec, ssms: ScioSpecMeasurementSetup) -> None:
measurement_data_hex = StartStopMeasurement_usb_hs(COM_Sciospec)
measurement_data = del_hex_in_list(measurement_data_hex)
split_measurement_data = reshape_full_message_in_bursts(measurement_data, ssms)
measurement_data = split_bursts_in_frames(split_measurement_data, ssms)
return measurement_data
17 changes: 17 additions & 0 deletions sciopy/usb_hs_handling.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pyftdi.ftdi import Ftdi
import struct
import time
from typing import Union
from sciopy.sciopy_dataclasses import (
ScioSpecMeasurementSetup,
Expand Down Expand Up @@ -266,3 +267,19 @@ def StartStopMeasurement_usb_hs(serial: Ftdi, print_msg: bool = False) -> list:
serial.write_data(bytearray([0xB4, 0x01, 0x00, 0xB4]))
SystemMessageCallback_usb_hs(serial, prnt_msg=False, ret_hex_int="int")
return measurement_data_hex


def SoftwareReset_usb_hs(serial: Ftdi, print_msg: bool = True) -> None:
"""
Reset the ScioSpec device.
Parameters
----------
serial : Ftdi
USB-HS serial connection
print_msg : bool, optional
print the callback message, by default True
"""
serial.write_data(bytearray([0xA1, 0x00, 0xA1]))
time.sleep(5)
SystemMessageCallback_usb_hs(serial, print_msg)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setuptools.setup(
name="sciopy",
version="0.7.1",
version="0.7.1.3",
author="Jacob Peter Thönes",
author_email="[email protected]",
description="Python based interface module for communication with the Sciospec Electrical Impedance Tomography (EIT) device.",
Expand Down

0 comments on commit bc6d967

Please sign in to comment.