-
Notifications
You must be signed in to change notification settings - Fork 1
Fix reversal potential inference and docstring for detect_ramp_bounds #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6e118d9
Update ramp bound function and docstring
df4dd88
Fix infer reversal
cfabef3
Add test for reversal inference
7380b62
Fix test output folders
2f3913a
Update ramp bound function and docstring
87e3313
Fix infer reversal
e26b206
Add test for reversal inference
63fcb98
Fix test infer reversal
7f919d5
Merge branch 'js_fix_infer_reversal' of github.com:CardiacModelling/p…
ccae122
Update test
93d4ca4
Update test
72cd27a
Modify test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These lines were causing infer reversal potential to fail for every single trace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/usr/bin/env python3 | ||
| import os | ||
| import unittest | ||
|
|
||
| from syncropatch_export.trace import Trace | ||
|
|
||
| from pcpostprocess import infer_reversal, leak_correct | ||
| from pcpostprocess.detect_ramp_bounds import detect_ramp_bounds | ||
|
|
||
|
|
||
| class TestInferReversal(unittest.TestCase): | ||
| def setUp(self): | ||
| test_data_dir = os.path.join('tests', 'test_data', '13112023_MW2_FF', | ||
| "staircaseramp (2)_2kHz_15.01.07") | ||
| json_file = "staircaseramp (2)_2kHz_15.01.07.json" | ||
|
|
||
| self.output_dir = os.path.join('test_output', self.__class__.__name__) | ||
|
|
||
| if not os.path.exists(self.output_dir): | ||
| os.makedirs(self.output_dir) | ||
|
|
||
| self.test_trace = Trace(test_data_dir, json_file) | ||
|
|
||
| # get currents and QC from trace object | ||
| self.currents = self.test_trace.get_all_traces(leakcorrect=False) | ||
| self.currents['times'] = self.test_trace.get_times() | ||
| self.currents['voltages'] = self.test_trace.get_voltage() | ||
|
|
||
| self.protocol_desc = self.test_trace.get_voltage_protocol().get_all_sections() | ||
| self.leak_ramp_bound_indices = detect_ramp_bounds(self.currents['times'], | ||
| self.protocol_desc, | ||
| ramp_index=0) | ||
|
|
||
| self.voltages = self.test_trace.get_voltage() | ||
| self.correct_Erev = -89.57184330525791438049054704606533050537109375 | ||
|
|
||
| def test_plot_leak_fit(self): | ||
| well = "A03" | ||
| sweep = 0 | ||
|
|
||
| voltage = self.test_trace.get_voltage() | ||
| times = self.test_trace.get_times() | ||
|
|
||
| current = self.test_trace.get_trace_sweeps(sweeps=[sweep])[well][0, :] | ||
| params, Ileak = leak_correct.fit_linear_leak(current, voltage, times, | ||
| *self.leak_ramp_bound_indices, | ||
| output_dir=self.output_dir, | ||
| save_fname=f"{well}_sweep{sweep}_leak_correction") | ||
|
|
||
| I_corrected = current - Ileak | ||
|
|
||
| E_rev = infer_reversal.infer_reversal_potential( | ||
| I_corrected, times, self.protocol_desc, | ||
| self.voltages, | ||
| output_path=os.path.join(self.output_dir, | ||
| f"{well}_staircase"), | ||
| known_Erev=self.correct_Erev) | ||
| self.assertLess(abs(E_rev - self.correct_Erev), 1e-5) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter name was a bit confusing here