diff --git a/src/MagneticReadoutProcessing/MRP/MRPMagnetTypes.py b/src/MagneticReadoutProcessing/MRP/MRPMagnetTypes.py index b1c06222..c450c5b5 100644 --- a/src/MagneticReadoutProcessing/MRP/MRPMagnetTypes.py +++ b/src/MagneticReadoutProcessing/MRP/MRPMagnetTypes.py @@ -39,7 +39,7 @@ def from_int(_val: int): try: return MagnetType(_val) except: - return None + return MagnetType.NOT_SPECIFIED def __int__(self): diff --git a/src/MagneticReadoutProcessing/MRP/MRPReading.py b/src/MagneticReadoutProcessing/MRP/MRPReading.py index 7ace0629..b442c05c 100644 --- a/src/MagneticReadoutProcessing/MRP/MRPReading.py +++ b/src/MagneticReadoutProcessing/MRP/MRPReading.py @@ -227,6 +227,11 @@ def set_additional_data(self, _k: str, _v: any): :param _v: Value :type _v: str """ + if self.additional_data is None: + self.additional_data = { + + } + if _k is not None and len(_k) > 0: self.additional_data[str(_k)] = _v @@ -624,8 +629,8 @@ def dump_to_file(self, _filepath_name: str) -> str: self.set_additional_data('export_filepath', _filepath_name) self.set_additional_data('export_filename', os.path.basename(_filepath_name)) - if self.additional_data['name'] != 'unknown': - self.set_additional_data('name', os.path.basename(_filepath_name)) + if not self.has_additional_data("name"): + self.set_name(os.path.basename(_filepath_name)) # FINALLY EXPORT TO FILE USING THE self.dump option try: diff --git a/src/MagneticReadoutProcessing/MRP/MRPReadingEntry.py b/src/MagneticReadoutProcessing/MRP/MRPReadingEntry.py index 0ce77250..707ada05 100644 --- a/src/MagneticReadoutProcessing/MRP/MRPReadingEntry.py +++ b/src/MagneticReadoutProcessing/MRP/MRPReadingEntry.py @@ -18,7 +18,7 @@ def from_int(_val: int): try: return MRPReadingEntryUnit(_val) except: - return None + return MRPReadingEntryUnit.UNIT_UNSPECIFIED class MRPReadingEntry: """ Class holds all values for one read entry such as value and position""" @@ -34,7 +34,7 @@ class MRPReadingEntry: @property - def unit(self): + def unit(self) -> MRPReadingEntryUnit: return self._unit @unit.setter @@ -43,7 +43,7 @@ def unit(self, value: MRPReadingEntryUnit): @property - def temperature(self): + def temperature(self) -> float: return self._temperature @temperature.setter @@ -51,7 +51,7 @@ def temperature(self, value: float): self._temperature = value @property - def value(self): + def value(self) -> float: return self._value @value.setter @@ -59,7 +59,7 @@ def value(self, value: float): self._value = value @property - def phi(self): + def phi(self) -> float: return self._phi @phi.setter @@ -67,7 +67,7 @@ def phi(self, value: float): self._phi = value @property - def theta(self): + def theta(self) -> float: return self._theta @theta.setter @@ -78,7 +78,7 @@ def theta(self, value: float): @property - def reading_index_phi(self): + def reading_index_phi(self) -> int: return self._reading_index_phi @reading_index_phi.setter @@ -86,7 +86,7 @@ def reading_index_phi(self, value: int): self._reading_index_phi = value @property - def reading_index_theta(self): + def reading_index_theta(self) -> int: return self._reading_index_theta @reading_index_theta.setter @@ -94,7 +94,7 @@ def reading_index_theta(self, value: int): self._reading_index_theta = value @property - def is_valid(self): + def is_valid(self) -> bool: return self._is_valid @is_valid.setter @@ -102,7 +102,7 @@ def is_valid(self, value: bool): self._is_valid = value @property - def id(self): + def id(self) -> int: return self._id @id.setter @@ -203,5 +203,7 @@ def __dict__(self) -> dict: 'temperature': self._temperature, 'unit': self._unit.value } + + def to_dict(self) -> dict: return self.__dict__() diff --git a/src/MagneticReadoutProcessing/pyproject.toml b/src/MagneticReadoutProcessing/pyproject.toml index 8a31b9b1..346ab2b3 100644 --- a/src/MagneticReadoutProcessing/pyproject.toml +++ b/src/MagneticReadoutProcessing/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" [project] name = "MagneticReadoutProcessing" -version = "2.0.6" +version = "2.0.7" 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 = "info@marcelochsendorf.com"}] diff --git a/src/MagneticReadoutProcessing/setup.cfg b/src/MagneticReadoutProcessing/setup.cfg index d98d2a56..1874772c 100644 --- a/src/MagneticReadoutProcessing/setup.cfg +++ b/src/MagneticReadoutProcessing/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = MagneticReadoutProcessing -version = 2.0.6 +version = 2.0.7 author = Marcel Ochsendorf author_email = info@marcelochsendorf.com 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. diff --git a/src/MagneticReadoutProcessing/setup.py b/src/MagneticReadoutProcessing/setup.py index 6ba572da..5a30b2c8 100644 --- a/src/MagneticReadoutProcessing/setup.py +++ b/src/MagneticReadoutProcessing/setup.py @@ -10,7 +10,7 @@ install_requires = [str(requirement) for requirement in pkg_resources.parse_requirements(requirements_txt)] setup(name='MagneticReadoutProcessing', - version='2.0.6', + version='2.0.7', 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',