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, agg=<built-in function max>) 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

  • agg – outcome code aggregate function, default is max (i.e. worst)

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.

Parameters
  • outcome – A string; one of “CRITICAL”, “FAIL”, “WARNING”, “PASS” or “NOT_SET”

  • namespace – The extended QC key specifying the type of QC associated with the outcome

  • override – If True the QC field is updated even if new value is better than previous

Returns

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.

Parameters

data – a dict of qc tests and their outcomes, typically a value between 0. and 1.

Returns

the updated extended_qc field

compute_outcome_from_extended_qc() str[source]

Returns the session outcome computed from aggregating the extended QC