From 75972db3dadd3f6af0be175015c10a99c5cf1dd3 Mon Sep 17 00:00:00 2001 From: ru57y34nn Date: Fri, 8 Oct 2021 13:32:04 -0700 Subject: [PATCH] GH #533 - Default to vm_delta_mv if autobias_v is None If autobias_v is None for a given sweep, then default to previous method of measuring delta between pre and post-stimulus baselines as vm_delta_mv. --- ipfx/qc_feature_evaluator.py | 7 +++++-- ipfx/qc_feature_extractor.py | 11 ++++++++--- ipfx/qc_features.py | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ipfx/qc_feature_evaluator.py b/ipfx/qc_feature_evaluator.py index fde7b9aa..28506864 100644 --- a/ipfx/qc_feature_evaluator.py +++ b/ipfx/qc_feature_evaluator.py @@ -169,10 +169,13 @@ def qc_current_clamp_sweep(sweep, is_ramp, qc_criteria=None): fail_tags.append("slow noise: %.3f above threshold: %.3f" % (sweep["slow_noise_rms_mv"], qc_criteria["slow_noise_rms_mv_max"]) ) if sweep["pre_vm_delta_mv"] is not None and sweep["pre_vm_delta_mv"] > qc_criteria["vm_delta_mv_max"]: - fail_tags.append("pre Vm delta: %.3f above threshold:%.3f" % (sweep["pre_vm_delta_mv"], qc_criteria["vm_delta_mv_max"])) + fail_tags.append("pre Vm delta: %.3f above threshold: %.3f" % (sweep["pre_vm_delta_mv"], qc_criteria["vm_delta_mv_max"])) if sweep["post_vm_delta_mv"] is not None and sweep["post_vm_delta_mv"] > qc_criteria["vm_delta_mv_max"]: - fail_tags.append("post Vm delta: %.3f above threshold:%.3f" % (sweep["post_vm_delta_mv"], qc_criteria["vm_delta_mv_max"])) + fail_tags.append("post Vm delta: %.3f above threshold: %.3f" % (sweep["post_vm_delta_mv"], qc_criteria["vm_delta_mv_max"])) + + if sweep["vm_delta_mv"] is not None and sweep["vm_delta_mv"] > qc_criteria["vm_delta_mv_max"]: + fail_tags.append("Vm delta: %.3f above threshold: %.3f" % (sweep["vm_delta_mv"], qc_criteria["vm_delta_mv_max"])) if fail_tags: logging.info("sweep: {}, {}, {}".format(sweep["sweep_number"], sweep["stimulus_name"], fail_tags)) diff --git a/ipfx/qc_feature_extractor.py b/ipfx/qc_feature_extractor.py index 82603ad9..44487def 100644 --- a/ipfx/qc_feature_extractor.py +++ b/ipfx/qc_feature_extractor.py @@ -379,9 +379,14 @@ def current_clamp_sweep_qc_features(sweep, is_ramp): qc_features["pre_vm_mv"] = mean_first_stability_epoch qc_features["slow_vm_mv"] = mean_first_stability_epoch qc_features["slow_noise_rms_mv"] = rms_first_stability_epoch - - qc_features["pre_vm_delta_mv"] = qcf.measure_vm_delta(mean_first_stability_epoch, autobias_v) - qc_features["post_vm_delta_mv"] = qcf.measure_vm_delta(mean_last_stability_epoch, autobias_v) + if autobias_v != None: + qc_features["pre_vm_delta_mv"] = qcf.measure_vm_delta(mean_first_stability_epoch, autobias_v) + qc_features["post_vm_delta_mv"] = qcf.measure_vm_delta(mean_last_stability_epoch, autobias_v) + qc_features["vm_delta_mv"] = None + else: + qc_features["vm_delta_mv"] = qcf.measure_vm_delta(mean_first_stability_epoch, mean_last_stability_epoch) + qc_features["pre_vm_delta_mv"] = None + qc_features["post_vm_delta_mv"] = None return qc_features diff --git a/ipfx/qc_features.py b/ipfx/qc_features.py index c79f1106..b1454c9b 100644 --- a/ipfx/qc_features.py +++ b/ipfx/qc_features.py @@ -39,6 +39,22 @@ def measure_vm(vals): def measure_vm_delta(mean_baseline, target_v): + """Measure delta between mean baseline and autobias target voltage, + or if autobias is not available then measure delta between + pre and post stimulus baselines. + + + Parameters + ---------- + mean_baseline : float mean baseline membrane voltage + target_v : float autobias taget voltage or post-stimulus + mean baseline membrane voltage + + Returns + ------- + delta: absolute voltage diff + + """ if mean_baseline is not None and target_v is not None: delta = abs(mean_baseline - target_v)