From a583961b36b0a4f9a48d09c1265d9f3edc02a962 Mon Sep 17 00:00:00 2001 From: birkholz-cubert Date: Tue, 24 Jun 2025 14:59:37 +0200 Subject: [PATCH 01/10] added pan overilluminated flag --- cuvis/cuvis_types.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cuvis/cuvis_types.py b/cuvis/cuvis_types.py index 2f998de..9c9140b 100644 --- a/cuvis/cuvis_types.py +++ b/cuvis/cuvis_types.py @@ -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, From 945577d998e4a17507bf1fbad1dfb27119383cb8 Mon Sep 17 00:00:00 2001 From: birkholz-cubert Date: Tue, 24 Jun 2025 15:31:16 +0200 Subject: [PATCH 02/10] added pan_failback to ViewExportSettings and ViewerSettings --- cuvis/FileWriteSettings.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cuvis/FileWriteSettings.py b/cuvis/FileWriteSettings.py index 015245b..240f48e 100644 --- a/cuvis/FileWriteSettings.py +++ b/cuvis/FileWriteSettings.py @@ -94,6 +94,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: @@ -130,13 +131,14 @@ 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): ge = super()._from_internal(ge) return cls(**ge.__dict__, - userplugin=vs.userplugin) + userplugin=vs.userplugin, pan_failback=vs.pan_failback) @dataclass @@ -239,6 +241,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: @@ -282,6 +285,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 @@ -294,4 +298,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)) From 517b9e99e35c6703ca64f2e0f5a197c74296a20f Mon Sep 17 00:00:00 2001 From: birkholz-cubert Date: Tue, 24 Jun 2025 15:34:02 +0200 Subject: [PATCH 03/10] removed binning --- cuvis/AcquisitionContext.py | 25 ------------------------- cuvis/cuvis_aux.py | 4 +--- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/cuvis/AcquisitionContext.py b/cuvis/AcquisitionContext.py index ccbc594..ce57a40 100644 --- a/cuvis/AcquisitionContext.py +++ b/cuvis/AcquisitionContext.py @@ -463,31 +463,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() diff --git a/cuvis/cuvis_aux.py b/cuvis/cuvis_aux.py index d6eed45..9983d5f 100644 --- a/cuvis/cuvis_aux.py +++ b/cuvis/cuvis_aux.py @@ -97,7 +97,6 @@ class SensorInfo(object): height: int raw_frame_id: int pixel_format: str - binning: bool @classmethod def _from_internal(cls, info): @@ -109,8 +108,7 @@ def _from_internal(cls, info): width=info.width, height=info.height, raw_frame_id=info.raw_frame_id, - pixel_format=info.pixel_format, - binning=(info.binning != 0)) + pixel_format=info.pixel_format) @dataclass(frozen=True) From 4b64f49108a480153adb60eef98d2be65e114c33 Mon Sep 17 00:00:00 2001 From: birkholz-cubert Date: Tue, 24 Jun 2025 15:35:39 +0200 Subject: [PATCH 04/10] added sensors real integration time to SensorInfo --- cuvis/cuvis_aux.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cuvis/cuvis_aux.py b/cuvis/cuvis_aux.py index 9983d5f..2370e5e 100644 --- a/cuvis/cuvis_aux.py +++ b/cuvis/cuvis_aux.py @@ -97,6 +97,7 @@ class SensorInfo(object): height: int raw_frame_id: int pixel_format: str + integration_time: float @classmethod def _from_internal(cls, info): @@ -108,7 +109,8 @@ def _from_internal(cls, info): width=info.width, height=info.height, raw_frame_id=info.raw_frame_id, - pixel_format=info.pixel_format) + pixel_format=info.pixel_format, + integration_time=info.integration_time) @dataclass(frozen=True) From da9d6371b9b8d35974194c7a5065f32acb12869c Mon Sep 17 00:00:00 2001 From: birkholz-cubert Date: Tue, 24 Jun 2025 15:41:43 +0200 Subject: [PATCH 05/10] added cube resolution and wavelengths to CalibrationInfo --- cuvis/Calibration.py | 8 +------- cuvis/cuvis_aux.py | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/cuvis/Calibration.py b/cuvis/Calibration.py index e781ea4..67234c8 100644 --- a/cuvis/Calibration.py +++ b/cuvis/Calibration.py @@ -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: diff --git a/cuvis/cuvis_aux.py b/cuvis/cuvis_aux.py index 2370e5e..2c99944 100644 --- a/cuvis/cuvis_aux.py +++ b/cuvis/cuvis_aux.py @@ -55,15 +55,37 @@ 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): + 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, + ci.cube_wavelengths) @dataclass(frozen=True) From 565c5ee5d7b3432a8c299b6931ac636a87b27951 Mon Sep 17 00:00:00 2001 From: birkholz-cubert Date: Tue, 24 Jun 2025 15:44:49 +0200 Subject: [PATCH 06/10] added additional typing annotations --- cuvis/FileWriteSettings.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cuvis/FileWriteSettings.py b/cuvis/FileWriteSettings.py index 240f48e..ec72d50 100644 --- a/cuvis/FileWriteSettings.py +++ b/cuvis/FileWriteSettings.py @@ -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, @@ -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__) @@ -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__[ @@ -135,7 +138,9 @@ def _get_internal(self): 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, pan_failback=vs.pan_failback) @@ -173,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), @@ -204,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]) From de745263eaba1e459da22436e1e51fccf10dbd53 Mon Sep 17 00:00:00 2001 From: birkholz-cubert Date: Tue, 24 Jun 2025 16:01:53 +0200 Subject: [PATCH 07/10] set correct default for log file name --- cuvis/General.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cuvis/General.py b/cuvis/General.py index 4bcea3f..150fe86 100644 --- a/cuvis/General.py +++ b/cuvis/General.py @@ -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'] From 698a4cdf3ba7cc11bac359c86acf5a61079c6866 Mon Sep 17 00:00:00 2001 From: birkholz-cubert Date: Wed, 25 Jun 2025 10:08:25 +0200 Subject: [PATCH 08/10] parse wl vec directly to numpy array --- cuvis/cuvis_aux.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cuvis/cuvis_aux.py b/cuvis/cuvis_aux.py index 2c99944..0a458dc 100644 --- a/cuvis/cuvis_aux.py +++ b/cuvis/cuvis_aux.py @@ -75,6 +75,7 @@ def __repr__(self): @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, @@ -85,7 +86,7 @@ def _from_internal(cls, ci: cuvis_il.cuvis_calibration_info_t): ci.cube_width, ci.cube_height, ci.cube_channels, - ci.cube_wavelengths) + wls) @dataclass(frozen=True) From 92e0a7569265053ed3e1417bfe7b5fbdd638e261 Mon Sep 17 00:00:00 2001 From: birkholz-cubert Date: Wed, 25 Jun 2025 10:15:06 +0200 Subject: [PATCH 09/10] moved ComponentInfo around --- cuvis/AcquisitionContext.py | 3 +-- cuvis/General.py | 26 -------------------------- cuvis/cuvis_aux.py | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/cuvis/AcquisitionContext.py b/cuvis/AcquisitionContext.py index ce57a40..abacc57 100644 --- a/cuvis/AcquisitionContext.py +++ b/cuvis/AcquisitionContext.py @@ -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 diff --git a/cuvis/General.py b/cuvis/General.py index 150fe86..5ce9b6f 100644 --- a/cuvis/General.py +++ b/cuvis/General.py @@ -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) diff --git a/cuvis/cuvis_aux.py b/cuvis/cuvis_aux.py index 0a458dc..4fd77e6 100644 --- a/cuvis/cuvis_aux.py +++ b/cuvis/cuvis_aux.py @@ -157,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 = {} From 9c9f5d995f13531f5aeb89bc4d96a80011d4a430 Mon Sep 17 00:00:00 2001 From: birkholz-cubert Date: Wed, 25 Jun 2025 10:15:26 +0200 Subject: [PATCH 10/10] upped version number --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 95c8382..fc7b6bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"