Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions pcpostprocess/scripts/run_herg_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
#
import argparse
import importlib.util
import json
import logging
import multiprocessing
import os
import re
import string
import sys

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -414,7 +412,7 @@ def run(data_path, output_path, save_id, staircase_protocols,

# Store the results by adding an extra column to qc_df
qc_df['qc3.bookend'] = [qc3_bookend_dict[well] for well in qc_df.well]
del(qc3_bookend_dict)
del qc3_bookend_dict

#
# Write a file chrono.txt containing the order that protocols were run in
Expand Down Expand Up @@ -459,7 +457,7 @@ def run(data_path, output_path, save_id, staircase_protocols,
# QC Erev spread: check spread in reversal potential isn't too large
E_revs = sub_df['E_rev'].values.flatten().astype(np.float64)
E_rev_spread = E_revs.max() - E_revs.min()
del(E_revs)
del E_revs
passed_QC_Erev_spread = E_rev_spread <= reversal_spread_threshold
logging.info(f'passed_QC_Erev_spread {passed_QC_Erev_spread}')
erev_spreads[well] = E_rev_spread
Expand Down Expand Up @@ -614,8 +612,8 @@ def agg_func(x):


def run_secondary_qc(readname, savename, time_strs, selected_wells, savedir,
data_path, figure_size, reversal_potential, save_id,
write_traces):
data_path, figure_size, reversal_potential, save_id,
write_traces):
"""
Performs QC on a protocol (staircase or other), and exports the traces.

Expand Down Expand Up @@ -705,7 +703,7 @@ def run_secondary_qc(readname, savename, time_strs, selected_wells, savedir,
np.vstack((times, voltages)).T, columns=['time', 'voltage'])
voltage_df.to_csv(os.path.join(
trace_dir, f'{save_id}-{savename}-voltages.csv'))
#write_csv(times, trace_dir, f'{save_id}-{savename}-times.csv')
# write_csv(times, trace_dir, f'{save_id}-{savename}-times.csv')

qc_before = before_trace.get_onboard_QC_values()
qc_after = after_trace.get_onboard_QC_values()
Expand Down
12 changes: 9 additions & 3 deletions pcpostprocess/tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,15 @@ def test_run_herg_qc_and_summarise_herg_export(self):
qc_map = {'staircaseramp (2)_2kHz': 'staircaseramp'}
write_map = {'staircaseramp2': 'staircaseramp2'}
run_herg_qc(
data, d1, qc_map, ('A03', 'A20', 'D16'),
write_traces=True, write_map=write_map,
save_id='13112023_MW2', reversal_potential=erev)
data,
d1,
'13112023_MW2',
qc_map,
write_map,
('A03', 'A20', 'D16'),
write_traces=True,
reversal_potential=erev,
)

with open(os.path.join(d1, 'passed_wells.txt'), 'r') as f:
self.assertEqual(f.read().strip(), 'A03')
Expand Down
Loading