ibllib.qc.base

Module attributes

SIGN_OFF_CATEGORIES

Map for comparing QC outcomes

Functions

sign_off_dict

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

Classes

QC

A base class for data quality control

SIGN_OFF_CATEGORIES = {'neuropixel': ['raw', 'spike_sorting', 'alignment']}

Map for comparing QC outcomes

Type:

dict

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

sign_off_dict(exp_dec, sign_off_categories=None)[source]

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