qualitycontrol

The purpose of the qualitycontrol package is to provide the means for users to check their IPASC data for completeness and consistency.

It can also be used to check the data for general integrity.

class CompletenessChecker(verbose: bool = False, log_file_path: Optional[str] = None)[source]

Bases: object

Tests a given AcquisitionMetadata dictionary or a given DeviceMetadata dictionary for completeness.

For these purposes, the check_acquisition_meta_data and check_device_meta_data methods can be used:

pa_data = #TODO load pa_data here
cc = CompletenessChecker(verbose=True)
acquisition_metadata_complete = cc.check_acquisition_meta_data(pa_data.meta_data_acquisition)
device_metadata_complete = cc.check_device_meta_data(pa_data.meta_data_device)
Parameters:
  • verbose (bool) – A flag to indicate whether the log should be printed to the console.

  • log_file_path (str) – A string with the path to where the log file should be written to. If ‘None’, then no log file is written.

check_acquisition_meta_data(meta_data_dictionary: dict) bool[source]

This function will evaluate the completeness of the given acquisition metadata. It can be used to generate a report to the console by setting verbose to True. When setting a file path to log_file, it will also save the report as a txt file in the designated path.

Parameters:

meta_data_dictionary (dict) – A dictionary containing all acquisition meta data.

Raises:
  • ValueError: – if meta_data_dictionary was None

  • TypeError: – if one of the arguments ws not of the correct type

Returns:

True, if the meta_data_dictionary is complete

Return type:

bool

check_device_meta_data(device_meta_data: dict)[source]

This function will evaluate the completeness of the given device metadata. It can be used to generate a report to the console by setting verbose to True. When setting a file path to log_file, it will also save the report as a txt file in the designated path.

Parameters:

device_meta_data (dict) – A dictionary containing all device meta data.

Raises:
  • ValueError: – if meta_data_dictionary was None

  • TypeError: – if one of the arguments ws not of the correct type

Returns:

True, if the meta_data_dictionary is complete

Return type:

bool

static check_metadatum_from_dict(dictionary: dict, metadatum: MetaDatum)[source]

Internal method to systematically test a metadata field.

Parameters:
  • dictionary (dict) – The dictionary supposedly containing the metadatum at the top level

  • metadatum (MetaDatum) – The metadatum to test

Returns:

A tuple with the log string and an integer that is 0 if everything was fine and 1 if there was an error.

Return type:

(str, int)

class ConsistencyChecker(verbose: bool = False, log_file_path: Optional[str] = None)[source]

Bases: object

The purpose of this class is to go beyond the capabilities of the CompletenessChecker and to test the consistency of the metadata. To this end, every meta datum is assigned a possible value range by definition. The Consistency checker unit_tests if the assigned values fall inside this value range.

Parameters:
  • verbose (bool) – A flag to indicate whether the log should be printed to the console.

  • log_file_path (str) – A string with the path to where the log file should be written to. If ‘None’, then no log file is written.

check_acquisition_meta_data(acquisition_meta_data: dict) bool[source]

Tests the given dictionary with acquisition metadata for consistency.

Parameters:

acquisition_meta_data (dict) – A dictionary containing all the acquisition metadata to check

Returns:

Returns True if all data is consistent

Return type:

bool

check_binary_data(binary_data) bool[source]

This method unit_tests if the given binary data has the correct data type and if each value in the binary data in a Number.

Parameters:

binary_data (np.ndarray) – The binary data to check

check_device_meta_data(device_meta_data: dict) bool[source]

Tests the given dictionary with device metadata for consistency.

Parameters:

device_meta_data (dict) – A dictionary containing all the device metadata to check

Returns:

Returns True if all data is consistent

Return type:

bool

quality_check_pa_data(pa_data: PAData, verbose: bool = False, log_file_path: Optional[str] = None) bool[source]

This is a convenience method that instantiates both a completeness and a consistency checker and evaluates the given PAData instance.

Parameters:
  • pa_data (PAData) – The PAData instance to check

  • verbose (bool) – Specifies if the log report should be printed to the console

  • log_file_path (str) – A path to a log file to write to

Returns:

True if and only if all completeness and quality checks are passed.

Return type:

bool