Draft: WIP Positive/negative standard deviation refinement
I have changed the function find_transition
in refine.py look at threshold crossings above and below the channel's mean by a given standard deviation. This makes the refinement more accurate by around 25ms in some cases (see images below) and does not effect the refinement in others. The tuple returned by find_transition
is threshold, refined_gps
from the first threshold crossing (or only threshold crossing or None
if no crossings exist).
The number of standard deviations is still taken from config.py but now the sign doesn't matter, only the magnitude. Signs have been removed and comments added too config.py to indicate that.
find_transition
now creates a list dictionary containing a list of first ind where threshold crosses and threshold, sorts that list so the first ind (crossing) comes first and then outputs ind and threshold from the beginning of the list. This list only contains entries if the ind exists.
eg: thresh_crossing_list = [[ind_that_comes_first, associated_threshold],[ind_that_comes_second, associated_threshold]]
eg: thresh_crossing_dict = {'thresh': {'lower': lower_threshold, 'upper': upper_threshold}, 'ind': {'lower': lower_ind, 'upper': upper_ind} }
The key of the minimum ind is retuned as first_crossing
and will be upper
, lower
or None
if no crossings exist. The threshold and refined_gps is then retuned using the first_crossing
key.
I have removed the logic that was: if no threshold crossing exists, choose the max/min channel value for use in plotting the threshold. Do we think that is okay to do?
Closes #158
Old version, refined gps = .0688
New version, refined gps = .0429 (i.e. 25.9ms sooner)
Additionally, I have changed to input params of plot_indicators
from taking the dictionary params
to just taking channel
. Previously the plotting looked at whether the upper or lower threshold was used in order to place the annotation "threshold" above or below the plotted line. This seemed tricky to do with the variable thresholds so I removed the dependence and put the annotation always below. This doesn't always look as smart if anyone can think of a better way of doing this Plotting will still look at whether threshold is above or below mean and plot "threshold" annotation in the correct place.
Merge request reports
Activity
- Resolved by Camilla Compton
- Resolved by Camilla Compton
added 1 commit
- 35f4b9ac - add thresh=lower_t if no threshold crossings found for clearer graphs
added 1 commit
- 328f6316 - assign threshold=None in find_transition so no error when channel < min
added 1 commit
- 26e4fef9 - add threshold for graphs if refinment fails and edit annotate location
added 1 commit
- 36ae78a7 - change postion of threshold annotation to keep it on right side of graph
added 1 commit
- df15b0dc - add logic to decide side of threshold annotation and clarify 'if threshold is None'
added 1 commit
- 2f1bffb5 - change from list to dictionary in refine.py refine_transistion
added 1 commit
- 083c4e33 - refine.py plot_indicators to use mean not y_ind[0] to place thresh label
added 1 commit
- 069e037f - fix error: use y_ind sample rate for refine.py plot_indicators mean
added 1 commit
- ab93ba1f - fix error: agaain use bufs for sample_rate in refine.py plot_indicators
added 1 commit
- 07e19d1e - fix error: typo in refine.py plot_indicators bufs[1][0] swaps with y_ind
added 1 commit
- a6dd91d3 - fix error: change bufs indexing to get sample rate for plot_indicators
@jameson.rollins this merge request is now ready to be looked at.
@camilla.compton This might also be a good time to expand the standard deviation thresholding value, as recommended by Sheila in #97.
Yes, I will have a look at this and similar problem mentioned by Arnaud in #161