Skip to content

Draft: WIP Positive/negative standard deviation refinement

Camilla Compton requested to merge camilla.compton/locklost:pos_neg_std into master

I have changed the function find_transition in 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 but now the sign doesn't matter, only the magnitude. Signs have been removed and comments added too 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 Screen_Shot_2020-05-15_at_12.01.35_PM

New version, refined gps = .0429 (i.e. 25.9ms sooner) Screen_Shot_2020-05-15_at_12.03.27_PM

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.

Edited by Camilla Compton

Merge request reports