Skip to content

Commit

Permalink
Skip phase distribution check; handle NaNs in stim move before go cue
Browse files Browse the repository at this point in the history
  • Loading branch information
k1o0 committed Dec 11, 2023
1 parent f3f057c commit f5290b0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ibllib/qc/task_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,6 @@ def compute_session_status(self):

class HabituationQC(TaskQC):

criteria = dict()
criteria['default'] = {'PASS': 0.99, 'WARNING': 0.90, 'FAIL': 0} # Note: WARNING was 0.95 prior to Aug 2022
criteria['_task_phase_distribution'] = {'PASS': 0.99, 'NOT_SET': 0} # This rarely passes due to low trial num

def compute(self, download_data=None, **kwargs):
"""Compute and store the QC metrics.
Expand Down Expand Up @@ -368,7 +364,7 @@ def compute(self, download_data=None, **kwargs):
check = prefix + 'phase_distribution'
metric, _ = np.histogram(data['phase'])
_, p = chisquare(metric)
passed[check] = p < 0.05
passed[check] = p < 0.05 if len(data['phase']) >= 400 else None # skip if too few trials
metrics[check] = metric

# Checks common to training QC
Expand Down Expand Up @@ -1075,7 +1071,7 @@ def check_wheel_integrity(data, re_encoding='X1', enc_res=None, **_):
# === Pre-stimulus checks ===
def check_stimulus_move_before_goCue(data, photodiode=None, **_):
""" Check that there are no visual stimulus change(s) between the start of the trial and the
go cue sound onset, expect for stim on.
go cue sound onset, except for stim on.
Metric: M = number of visual stimulus change events between trial start and goCue_times
Criterion: M == 1
Expand All @@ -1088,6 +1084,7 @@ def check_stimulus_move_before_goCue(data, photodiode=None, **_):
-----
- There should be exactly 1 stimulus change before goCue; stimulus onset. Even if the stimulus
contrast is 0, the sync square will still flip at stimulus onset, etc.
- If there are no goCue times (all are NaN), the status should be NOT_SET.
"""
if photodiode is None:
_log.warning('No photodiode TTL input in function call, returning None')
Expand All @@ -1100,6 +1097,7 @@ def check_stimulus_move_before_goCue(data, photodiode=None, **_):
metric = np.append(metric, np.count_nonzero(s[s > i] < c))

passed = (metric == 1).astype(float)
passed[np.isnan(data['goCue_times'])] = np.nan
assert data['intervals'].shape[0] == len(metric) == len(passed)
return metric, passed

Expand Down

0 comments on commit f5290b0

Please sign in to comment.