ibllib.qc.base

Classes

QC

A base class for data quality control

class QC(endpoint_id, one=None, log=None, endpoint='sessions')[source]

Bases: object

A base class for data quality control

abstract run()[source]

Run the QC tests and return the outcome :return: One of “CRITICAL”, “FAIL”, “WARNING” or “PASS”

abstract load_data()[source]

Load the data required to compute the QC Subclasses may implement this for loading raw data

property outcome
static overall_outcome(outcomes: iter) → str[source]

Given an iterable of QC outcomes, returns the overall (i.e. worst) outcome.

Example

QC.overall_outcome([‘PASS’, ‘NOT_SET’, None, ‘FAIL’]) # Returns ‘FAIL’

Parameters

outcomes – An iterable of QC outcomes

Returns

The overall outcome string

static code_to_outcome(code: int) → str[source]

Given an outcome id, returns the corresponding string.

Example

QC.overall_outcome([‘PASS’, ‘NOT_SET’, None, ‘FAIL’]) # Returns ‘FAIL’

Parameters

code – The outcome id

Returns

The overall outcome string

update(outcome=None, namespace='experimenter', override=False)[source]

Update the qc field in Alyx Updates the ‘qc’ field in Alyx if the new QC outcome is worse than the current value. :param outcome: A string; one of “CRITICAL”, “FAIL”, “WARNING”, “PASS” or “NOT_SET” :param namespace: The extended QC key specifying the type of QC associated with the outcome :param override: If True the QC field is updated even if new value is better than previous :return: The current QC outcome str on Alyx

Example

qc = QC(‘path/to/session’) qc.update(‘PASS’) # Update current QC field to ‘PASS’ if not set

update_extended_qc(data)[source]

Update the extended_qc field in Alyx Subclasses should chain a call to this. :param data: a dict of qc tests and their outcomes, typically a value between 0. and 1. :return: the updated extended_qc field