ibllib.qc.base

Functions

sign_off_dict

Create sign off dictionary.

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.

Returns:

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

The overall session outcome.

Type:

one.alf.spec.QC

static overall_outcome(outcomes: iter, agg=<built-in function max>) QC[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 (iterable of one.alf.spec.QC, str or int) – An iterable of QC outcomes.

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

Returns:

The overall outcome.

Return type:

one.alf.spec.QC

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 (str, int, one.alf.spec.QC) – A QC outcome; one of “CRITICAL”, “FAIL”, “WARNING”, “PASS” or “NOT_SET”.

  • namespace (str) – The extended QC key specifying the type of QC associated with the outcome.

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

Returns:

The current QC outcome on Alyx.

Return type:

one.alf.spec.QC

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]

Return the session outcome computed from aggregating the extended QC.

sign_off_dict(exp_dec, sign_off_categories=None)[source]

Create sign off dictionary.

Creates a dict containing ‘sign off’ keys for each device and task protocol in the provided experiment description.

Parameters:
  • exp_dec (dict) – A loaded experiment description file.

  • sign_off_categories (dict of list) – A dictionary of custom JSON keys for a given device in the acquisition description file.

Returns:

The sign off dictionary with the main key ‘sign_off_checklist’ containing keys for each device and task protocol.

Return type:

dict of dict