Skip to content

Commit

Permalink
added more additional data functions
Browse files Browse the repository at this point in the history
  • Loading branch information
RBEGamer committed Oct 8, 2024
1 parent a42f121 commit 8b0cd91
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
49 changes: 49 additions & 0 deletions src/MagneticReadoutProcessing/MRP/MRPReading.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,55 @@ def load_from_file(self, _filepath_name: str):
except Exception as e:
sys.stderr.write(str(e))


def has_additional_data(self, _keys: list[str]) -> bool:
"""
Checks if all the provided keys exist in the `additional_data` dictionary.
Args:
_keys (list[str]): A list of keys to be checked in the `additional_data` dictionary.
Returns:
bool:
- True if all keys in the list exist in `additional_data`.
- False if any key in the list is missing from `additional_data`.
This function iterates over a list of keys and checks if each one exists in the
`additional_data` dictionary by calling the `has_additional_data` method for each key.
If any key is missing, the function returns `False`; otherwise, it returns `True` when all keys are present.
"""
# Iterate over each key in the provided list of keys
for k in _keys:
# If any key is not found in additional_data, return False
if not self.has_additional_data(k):
return False
# If all keys are found, return True
return True


def has_additional_data(self, _k: str) -> bool:
"""
Checks if the provided key exists and is valid in the `additional_data` dictionary.
Args:
_k (str): The key to be checked in the `additional_data` dictionary.
Returns:
bool:
- True if the key exists and is non-empty.
- False if the key is None, empty, or not found in `additional_data`.
The function first ensures that the input key `_k` is not None and has a length greater than zero.
If the key passes this condition, it checks if the key exists in the `additional_data` dictionary.
"""
if _k is not None and len(_k) > 0:
# If the key exists in the additional_data dictionary, return its value
if _k in self.additional_data:
return True
return False



def get_additional_data(self, _k: str) -> any:
"""
Retrieve additional data associated with the given key from the instance's
Expand Down
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 = "2.0.0"
version = "2.0.1"
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 = 2.0.0
version = 2.0.1
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='2.0.0',
version='2.0.1',
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 8b0cd91

Please sign in to comment.