Skip to content
28 changes: 1 addition & 27 deletions cuvis/AcquisitionContext.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from ._cuvis_il import cuvis_il
from .Async import Async, AsyncMesu
from .Calibration import Calibration
from .General import ComponentInfo
from .Measurement import Measurement
from .SessionFile import SessionFile
from .cuvis_aux import SDKException, SessionData
from .cuvis_aux import SDKException, SessionData, ComponentInfo
from .cuvis_types import HardwareState, OperationMode

from typing import Coroutine, Callable, Awaitable, Union, Iterable, Optional
Expand Down Expand Up @@ -463,31 +462,6 @@ def set_auto_exp_comp_async(self, val: float) -> Async:
raise SDKException()
return Async(cuvis_il.p_int_value(_pasync))

@property
@copydoc(cuvis_il.cuvis_acq_cont_binning_get)
def binning(self) -> bool:
_ptr = cuvis_il.new_p_int()
if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_binning_get(
self._handle, _ptr):
raise SDKException()
return bool(cuvis_il.p_int_value(_ptr))

@binning.setter
@copydoc(cuvis_il.cuvis_acq_cont_binning_set)
def binning(self, val: bool) -> None:
if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_binning_set(
self._handle, val):
raise SDKException()
return

@copydoc(cuvis_il.cuvis_acq_cont_binning_set_async)
def set_binning_async(self, val: bool) -> Async:
_pasync = cuvis_il.new_p_int()
if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_binning_set_async(
self._handle, _pasync, int(val)):
raise SDKException()
return Async(cuvis_il.p_int_value(_pasync))

def register_ready_callback(self, callback: Callable[None, Awaitable[None]]) -> None:
self.reset_ready_callback()

Expand Down
8 changes: 1 addition & 7 deletions cuvis/Calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@ def info(self) -> CalibrationInfo:
if cuvis_il.status_ok != cuvis_il.cuvis_calib_get_info(
self._handle, ret):
raise SDKException()
return CalibrationInfo(
ret.model_name,
ret.serial_no,
ret.calibration_date,
ret.annotation_name,
ret.unique_id,
ret.file_path)
return CalibrationInfo._from_internal(ret)

@property
def id(self) -> str:
Expand Down
28 changes: 20 additions & 8 deletions cuvis/FileWriteSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _get_internal(self):
return ge

@classmethod
def _from_internal(cls, ge):
def _from_internal(cls, ge: cuvis_il.cuvis_export_general_settings_t):
return cls(export_dir=ge.export_dir,
channel_selection=ge.channel_selection,
spectra_multiplier=ge.spectra_multiplier,
Expand All @@ -64,7 +64,8 @@ def _get_internal(self):
return ge, es

@classmethod
def _from_internal(cls, ge, es):
def _from_internal(cls,
ge: cuvis_il.cuvis_export_general_settings_t, es):
ge = super()._from_internal(ge)
return cls(**ge.__dict__)

Expand All @@ -83,7 +84,9 @@ def _get_internal(self):
return ge, ts

@classmethod
def _from_internal(cls, ge, ts):
def _from_internal(cls,
ge: cuvis_il.cuvis_export_general_settings_t,
ts: cuvis_il.cuvis_export_tiff_settings_t):
ge = super()._from_internal(ge)
return cls(**ge.__dict__,
compression_mode=internal.__TiffCompressionMode__[
Expand All @@ -94,6 +97,7 @@ def _from_internal(cls, ge, ts):
@dataclass(repr=False)
class ViewExportSettings(GeneralExportSettings):
userplugin: InitVar[str] = None
pan_failback: bool = True

def __post_init__(self, userplugin: str):
if userplugin is not None:
Expand Down Expand Up @@ -130,13 +134,16 @@ def _get_internal(self):
ge = super()._get_internal()
vs = cuvis_il.cuvis_export_view_settings_t()
vs.userplugin = self.userplugin
vs.pan_failback = int(self.pan_failback)
return ge, vs

@classmethod
def _from_internal(cls, ge, vs):
def _from_internal(cls,
ge: cuvis_il.cuvis_export_general_settings_t,
vs: cuvis_il.cuvis_viewer_settings_t):
ge = super()._from_internal(ge)
return cls(**ge.__dict__,
userplugin=vs.userplugin)
userplugin=vs.userplugin, pan_failback=vs.pan_failback)


@dataclass
Expand Down Expand Up @@ -171,7 +178,9 @@ def _get_internal(self):
return ge, sa

@classmethod
def _from_internal(cls, ge, sa):
def _from_internal(cls,
ge: cuvis_il.cuvis_export_general_settings_t,
sa: cuvis_il.cuvis_save_args_t):
ge = super()._from_internal(ge)
return cls(**ge.__dict__,
allow_overwrite=bool(sa.allow_overwrite),
Expand Down Expand Up @@ -202,7 +211,7 @@ def _get_internal(self):
return pa

@classmethod
def _from_internal(cls, pa):
def _from_internal(cls, pa: cuvis_il.cuvis_proc_args_t):
return cls(allow_recalib=bool(pa.allow_recalib),
processing_mode=internal.__ProcessingMode__[pa.processing_mode])

Expand Down Expand Up @@ -239,6 +248,7 @@ class ViewerSettings():
pre_pan_sharpen_cube: bool = False
complete: bool = False
blend_opacity: float = 0.0
pan_failback: bool = True

def __post_init__(self, userplugin: str):
if userplugin is not None:
Expand Down Expand Up @@ -282,6 +292,7 @@ def _get_internal(self):
vs.pre_pan_sharpen_cube = int(self.pre_pan_sharpen_cube)
vs.complete = int(self.complete)
vs.blend_opacity = float(self.blend_opacity)
vs.pan_failback = int(self.pan_failback)
return vs

@classmethod
Expand All @@ -294,4 +305,5 @@ def _from_internal(cls, vs: cuvis_il.cuvis_viewer_settings_t):
vs.pan_algorithm],
pre_pan_sharpen_cube=bool(vs.pre_pan_sharpen_cube),
complete=bool(vs.complete),
blend_opacity=float(vs.blend_opacity))
blend_opacity=float(vs.blend_opacity),
pan_failback=bool(vs.pan_failback))
28 changes: 1 addition & 27 deletions cuvis/General.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from dataclasses import dataclass


def init(settings_path: str = ".", global_loglevel: int | str = logging.DEBUG, logfile_name: str = ""):
def init(settings_path: str = ".", global_loglevel: int | str = logging.DEBUG, logfile_name: str | None = None):
if 'CUVIS_SETTINGS' in os.environ and settings_path == ".":
# env variable is set and settings path is default kwarg
settings_path = os.environ['CUVIS_SETTINGS']
Expand Down Expand Up @@ -53,29 +53,3 @@ def set_log_level(lvl: int | str):

cuvis_il.cuvis_set_log_level(internal.__CuvisLoglevel__[lvl])
logging.basicConfig(level=lvl)


@dataclass
class ComponentInfo(object):
type: ComponentType = None
display_name: str = None
sensor_info: str = None
user_field: str = None
pixel_format: str = None

def _get_internal(self):
ci = cuvis_il.cuvis_component_info_t()
ci.type = internal.__CuvisComponentType__[self.type]
ci.displayname = self.display_name
ci.sensorinfo = self.sensor_info
ci.userfield = self.user_field
ci.pixelformat = self.pixel_format
return ci

@classmethod
def _from_internal(cls, ci):
return cls(type=internal.__ComponentType__[ci.type],
display_name=ci.displayname,
sensor_info=ci.sensorinfo,
user_field=ci.userfield,
pixel_format=ci.pixelformat)
48 changes: 44 additions & 4 deletions cuvis/cuvis_aux.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,38 @@ class CalibrationInfo(object):
annotation_name: str
unique_id: str
file_path: str
cube_width: int
cube_height: int
cube_channels: int
cube_wavelengths: list[int]

def __repr__(self):
return "'Calibration: model: {}, serial no.: {}, calibration date: {}, annotation: {}, unique ID: {}, file: {}'".format(
return "'Calibration: model: {}, serial no.: {}, calibration date: {}, annotation: {}, unique ID: {}, file: {}, resolution: {}x{}x{}'".format(
self.model_name,
self.serial_no,
self.calibration_date,
self.annotation_name,
self.unique_id,
self.file_path)
self.file_path,
self.cube_width,
self.cube_height,
self.cube_channels
)

@classmethod
def _from_internal(cls, ci: cuvis_il.cuvis_calibration_info_t):
wls = cuvis_il.cuvis_read_calib_info_wl_vec(ci)
return cls(
ci.model_name,
ci.serial_no,
ci.calibration_date,
ci.annotation_name,
ci.unique_id,
ci.file_path,
ci.cube_width,
ci.cube_height,
ci.cube_channels,
wls)


@dataclass(frozen=True)
Expand Down Expand Up @@ -97,7 +120,7 @@ class SensorInfo(object):
height: int
raw_frame_id: int
pixel_format: str
binning: bool
integration_time: float

@classmethod
def _from_internal(cls, info):
Expand All @@ -110,7 +133,7 @@ def _from_internal(cls, info):
height=info.height,
raw_frame_id=info.raw_frame_id,
pixel_format=info.pixel_format,
binning=(info.binning != 0))
integration_time=info.integration_time)


@dataclass(frozen=True)
Expand All @@ -134,6 +157,23 @@ def _from_internal(cls, state):
isProcessing=bool(state.isProcessing))


@dataclass(frozen=True)
class ComponentInfo(object):
type: internal.ComponentType
display_name: str
sensor_info: str
user_field: str
pixel_format: str

@classmethod
def _from_internal(cls, ci):
return cls(type=internal.__ComponentType__[ci.type],
display_name=ci.displayname,
sensor_info=ci.sensorinfo,
user_field=ci.userfield,
pixel_format=ci.pixelformat)


class Bitset(object):
_translation_dict = {}
_inverse_dict = {}
Expand Down
1 change: 1 addition & 0 deletions cuvis/cuvis_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __inverseTranslationDict(translationDict):
__CuvisMeasurementFlag__ = {
"POOR_REFERENCE": cuvis_il.CUVIS_MESU_FLAG_POOR_REFERENCE,
"OVERILLUMINATED": cuvis_il.CUVIS_MESU_FLAG_OVERILLUMINATED,
"PAN_OVERILLUMINATED": cuvis_il.CUVIS_MESU_FLAG_PAN_OVERILLUMINATED,
"POOR_WHITE_BALANCING": cuvis_il.CUVIS_MESU_FLAG_POOR_WHITE_BALANCING,
"DARK_INTTIME": cuvis_il.CUVIS_MESU_FLAG_DARK_INTTIME,
"DARK_TEMP": cuvis_il.CUVIS_MESU_FLAG_DARK_TEMP,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "cuvis"
version = "3.3.3"
version = "3.4.0b1"
description = "CUVIS Python SDK."
readme = "README.md"
requires-python = ">=3.9"
Expand Down