-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:CardiacModelling/pcpostprocess into…
… readme-link-fix
- Loading branch information
Showing
11 changed files
with
372 additions
and
213 deletions.
There are no files selected for viewing
This file contains 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 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,27 @@ | ||
import numpy as np | ||
|
||
|
||
def detect_ramp_bounds(times, voltage_sections, ramp_no=0): | ||
""" | ||
Extract the the times at the start and end of the nth ramp in the protocol. | ||
@param times: np.array containing the time at which each sample was taken | ||
@param voltage_sections 2d np.array where each row describes a segment of the protocol: (tstart, tend, vstart, end) | ||
@param ramp_no: the index of the ramp to select. Defaults to 0 - the first ramp | ||
@returns tstart, tend: the start and end times for the ramp_no+1^nth ramp | ||
""" | ||
|
||
ramps = [(tstart, tend, vstart, vend) for tstart, tend, vstart, vend | ||
in voltage_sections if vstart != vend] | ||
try: | ||
ramp = ramps[ramp_no] | ||
except IndexError: | ||
print(f"Requested {ramp_no+1}th ramp (ramp_no={ramp_no})," | ||
" but there are only {len(ramps)} ramps") | ||
|
||
tstart, tend = ramp[:2] | ||
|
||
ramp_bounds = [np.argmax(times > tstart), np.argmax(times > tend)] | ||
return ramp_bounds | ||
|
This file contains 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 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 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 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
Oops, something went wrong.