py2ls 0.1.7.7__py3-none-any.whl → 0.1.7.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
py2ls/sleep_events_detectors.py
CHANGED
@@ -139,7 +139,7 @@ def filter_bandpass(data=None, ord=4, freq_range=[11, 16], fs=1000):
|
|
139
139
|
def moving_average(data, window_size):
|
140
140
|
return convolve1d(data, np.ones(window_size) / window_size)
|
141
141
|
|
142
|
-
def detect_cross(data, thr=0):
|
142
|
+
def detect_cross(data, thr=0, match=True):
|
143
143
|
if isinstance(data, list):
|
144
144
|
data = np.array(data)
|
145
145
|
if data.ndim == 1:
|
@@ -166,7 +166,14 @@ def detect_cross(data, thr=0):
|
|
166
166
|
return rising_before, falling_before
|
167
167
|
else:
|
168
168
|
signal_shifted = data - thr
|
169
|
-
|
169
|
+
signal_sign = np.sign(signal_shifted)
|
170
|
+
sign_diff = np.diff(signal_sign)
|
171
|
+
rising_before, falling_before=np.where(sign_diff > 0)[0],np.where(sign_diff < 0)[0]
|
172
|
+
if match:
|
173
|
+
# make sure they are matched
|
174
|
+
min_length = min(len(rising_indices), len(falling_indices))
|
175
|
+
rising_before, falling_before=rising_before[:min_length], falling_before[:min_length]
|
176
|
+
return rising_before, falling_before
|
170
177
|
## debug
|
171
178
|
# a = np.sin(np.arange(0, 10 * np.pi, np.pi / 100))
|
172
179
|
|
@@ -138,10 +138,10 @@ py2ls/ips.py,sha256=KkrkGAF0VQ-N0rH4FQFLyP-C-skY6EPpeO8t_5RngWw,88519
|
|
138
138
|
py2ls/netfinder.py,sha256=MY_0TQY_zaRBZ6wfR4RxNCGrU93HFmDVDRRy1EXl75o,47566
|
139
139
|
py2ls/plot.py,sha256=8_33-1wpkGZrDUuvRBfTPUi_BRKdf1njoR725OLSLSY,48579
|
140
140
|
py2ls/setuptools-70.1.0-py3-none-any.whl,sha256=2bi3cUVal8ip86s0SOvgspteEF8SKLukECi-EWmFomc,882588
|
141
|
-
py2ls/sleep_events_detectors.py,sha256=
|
141
|
+
py2ls/sleep_events_detectors.py,sha256=OzXn_uWr3x2aecOOymKDhKj6TAny-T-8C7vAM1zI6Io,52101
|
142
142
|
py2ls/stats.py,sha256=Wd9yCKQ_61QD29WMEgMuEcreFxF91NmlPW65iWT2B5w,39041
|
143
143
|
py2ls/translator.py,sha256=bc5FB-wqC4TtQz9gyCP1mE38HqNRJ_pmuRIgKnAlMzM,30581
|
144
144
|
py2ls/wb_detector.py,sha256=7y6TmBUj9exCZeIgBAJ_9hwuhkDh1x_-yg4dvNY1_GQ,6284
|
145
|
-
py2ls-0.1.7.
|
146
|
-
py2ls-0.1.7.
|
147
|
-
py2ls-0.1.7.
|
145
|
+
py2ls-0.1.7.8.dist-info/METADATA,sha256=AY6ORoiV4L48RkIU4yhh3WwK7e-M9VxhTtvlDxEVYOk,20017
|
146
|
+
py2ls-0.1.7.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
147
|
+
py2ls-0.1.7.8.dist-info/RECORD,,
|
File without changes
|