Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Sep 16, 2024
1 parent f887a65 commit 2eed5a9
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/MagneticReadoutProcessing/MRP/MRPBaseSensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,4 @@ def get_vector(self, _sensor_id: int = 0) -> (float, float, float):
:rtype: (float, float, float)
"""
return (self.get_reading('x', _sensor_id), self.get_reading('y', _sensor_id), self.get_reading('z', _sensor_id))

37 changes: 35 additions & 2 deletions src/MagneticReadoutProcessing/MRP/MRPReadingEntry.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
from enum import Enum

""" one datapoint for a reading """
class MRPReadingEntryException(Exception):
def __init__(self, message="MRPReadingEntryException thrown"):
self.message = message
super().__init__(self.message)


class MRPReadingEntryUnit(Enum):
UNIT_UNSPECIFIED = 0
UNIT_uT = 1
UNIT_mT = 2
UNIT_T = 3


class MRPReadingEntry:
""" Class holds all values for one read entry such as value and position"""
_value: float = None # [mT]
Expand All @@ -14,6 +24,17 @@ class MRPReadingEntry:
_is_valid: bool = False
_id: int = None
_temperature: float = -254.0
_unit: MRPReadingEntryUnit = MRPReadingEntryUnit.UNIT_UNSPECIFIED


@property
def unit(self):
return self._unit

@unit.setter
def unit(self, value: MRPReadingEntryUnit):
self._unit = value


@property
def temperature(self):
Expand Down Expand Up @@ -83,7 +104,7 @@ def id(self, value: int):
self._id = value


def __init__(self, p_id: int = None, p_value: float = None, p_phi: float = None, p_theta: float = None, p_rip: int = None, p_rit: int = None, p_is_valid: bool = False, p_temperature: float = -254.0):
def __init__(self, p_id: int = None, p_value: float = None, p_phi: float = None, p_theta: float = None, p_rip: int = None, p_rit: int = None, p_is_valid: bool = False, p_temperature: float = -254.0, p_unit: MRPReadingEntryUnit = MRPReadingEntryUnit.UNIT_UNSPECIFIED):
self._id = p_id
self._value = p_value
self._phi = p_phi
Expand All @@ -92,6 +113,7 @@ def __init__(self, p_id: int = None, p_value: float = None, p_phi: float = None,
self._reading_index_theta = p_rit
self._is_valid = p_is_valid
self._temperature = p_temperature
self._unit = p_unit

def from_dict(self, _dict: dict, _import_scale_factor: float = 1.0):
errors = 0
Expand Down Expand Up @@ -148,8 +170,18 @@ def from_dict(self, _dict: dict, _import_scale_factor: float = 1.0):
self._temperature = float(v)
errors = errors + 1

if 'unit' in _dict:
v = _dict.get('unit')
if v is None:
v = MRPReadingEntryUnit.UNIT_UNSPECIFIED
#self._unit = MRPReadingEntryUnit(v)
self._unit.value = v
errors = errors + 1

if errors < len(self.__dict__()):
raise MRPReadingEntryException("from_dict import failed")


def __dict__(self) -> dict:
return {
'value': self._value,
Expand All @@ -159,7 +191,8 @@ def __dict__(self) -> dict:
'reading_index_theta': self._reading_index_theta,
'is_valid': self._is_valid,
'id': self._id,
'temperature': self._temperature
'temperature': self._temperature,
'unit': self.value
}
def to_dict(self) -> dict:
return self.__dict__()
2 changes: 1 addition & 1 deletion src/MagneticReadoutProcessing/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "MagneticReadoutProcessing"
version = "1.9.5"
version = "1.9.6"
description = "This library was created for the Low-Field MRI project and allows processing of data measured by magnetic field sensors. The focus is on visualization, followed by the provision of simple interfaces to work with this data. In general its possible to use this lib on all kinds of sensor data."
license = {file = "LICENSE"}
authors = [{name = "Marcel Ochsendorf", email = "[email protected]"}]
Expand Down
2 changes: 1 addition & 1 deletion src/MagneticReadoutProcessing/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = MagneticReadoutProcessing
version = 1.9.5
version = 1.9.6
author = Marcel Ochsendorf
author_email = [email protected]
description = This library was created for the Low-Field MRI project and allows processing of data measured by magnetic field sensors. The focus is on visualization, followed by the provision of simple interfaces to work with this data. In general its possible to use this lib on all kinds of sensor data.
Expand Down
2 changes: 1 addition & 1 deletion src/MagneticReadoutProcessing/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
install_requires = [str(requirement) for requirement in pkg_resources.parse_requirements(requirements_txt)]

setup(name='MagneticReadoutProcessing',
version='1.9.5',
version='1.9.6',
license='Apache 2',
description='This library was created for the Low-Field MRI project and allows processing of data measured by magnetic field sensors. The focus is on visualization, followed by the provision of simple interfaces to work with this data. In general its possible to use this lib on all kinds of sensor data.',
author='Marcel Ochsendorf',
Expand Down

0 comments on commit 2eed5a9

Please sign in to comment.