Skip to content

Commit

Permalink
#21 Add test_qc5_1
Browse files Browse the repository at this point in the history
  • Loading branch information
kwabenantim committed Nov 18, 2024
1 parent 0e9a781 commit 69ba7ba
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
2 changes: 0 additions & 2 deletions pcpostprocess/hergQC.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,6 @@ def qc5(self, recording1, recording2, win=None, label=''):
max_diff = recording1[i:f][wherepeak] - recording2[i:f][wherepeak]
max_diffc = self.max_diffc * recording1[i:f][wherepeak]

logging.debug(f"qc5: max_diff = {max_diff}, max_diffc = {max_diffc}")

if (max_diff < max_diffc) or not (np.isfinite(max_diff)
and np.isfinite(max_diffc)):
self.logger.debug(f"max_diff: {max_diff}, max_diffc: {max_diffc}")
Expand Down
38 changes: 36 additions & 2 deletions tests/test_herg_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_qc3(self):
recording0 = np.asarray([0, 1] * 1000)
recording1 = recording0 + i
result = hergqc.qc3(recording0, recording1)
self.assertEqual(result[0], expected, f"({result[1]})")
self.assertEqual(result[0], expected, f"({i}: {result[1]})")

# TODO: Test on select data

Expand Down Expand Up @@ -206,7 +206,41 @@ def test_qc5(self):
recording0 = np.asarray([0, 1] * 1000)
recording1 = recording0 + i
result = hergqc.qc5(recording0, recording1)
self.assertEqual(result[0], expected, f"({result[1]})")
self.assertEqual(result[0], expected, f"({i}: {result[1]})")

# TODO: Test on select data

def test_qc5_1(self):
plot_dir = os.path.join(self.output_dir, "test_qc5")
if not os.path.exists(plot_dir):
os.makedirs(plot_dir)

hergqc = hERGQC(
sampling_rate=self.sampling_rate, plot_dir=plot_dir, voltage=self.voltage
)

# qc5_1 checks that the RMSD to zero of staircase protocol changes
# by at least 50% of the raw trace after E-4031 addition.
test_matrix = [
(0.1, True),
(0.2, True),
(0.3, True),
(0.4, True),
(0.49, True),
(0.5, True),
(0.51, False),
(0.6, False),
(0.7, False),
(0.8, False),
(0.9, False),
(1.0, False),
]

for i, expected in test_matrix:
recording0 = np.asarray([0, 1] * 1000)
recording1 = recording0 * i
result = hergqc.qc5_1(recording0, recording1)
self.assertEqual(result[0], expected, f"({i}: {result[1]})")

# TODO: Test on select data

Expand Down

0 comments on commit 69ba7ba

Please sign in to comment.