|
33 | 33 | from scipy import signal |
34 | 34 |
|
35 | 35 |
|
36 | | -def nimbaldetach( |
| 36 | +def detach( |
37 | 37 | x_values: np.ndarray, |
38 | 38 | y_values: np.ndarray, |
39 | 39 | z_values: np.ndarray, |
@@ -73,16 +73,9 @@ def nimbaldetach( |
73 | 73 |
|
74 | 74 |
|
75 | 75 | Returns: |
76 | | - A tuple with (start_stop_df, vert_nonwear_array) as defined below: |
77 | | -
|
78 | | - start_stop_df: A dataframe with the start and end datapoints of non-wear. |
79 | | - vert_nonwear_array: numpy array with length of the accelerometer data marked as |
| 76 | + A numpy array with length of the accelerometer data marked as |
80 | 77 | either wear (0) or non-wear (1). |
81 | 78 | """ |
82 | | - vert_nonwear_array = np.zeros(len(x_values)) |
83 | | - vert_nonwear_start_datapoints = [] |
84 | | - vert_nonwear_end_datapoints = [] |
85 | | - |
86 | 79 | x_std_fwd = pd.Series(x_values)[::-1].rolling(round(accel_freq * 60)).std()[::-1] |
87 | 80 | y_std_fwd = pd.Series(y_values)[::-1].rolling(round(accel_freq * 60)).std()[::-1] |
88 | 81 | z_std_fwd = pd.Series(z_values)[::-1].rolling(round(accel_freq * 60)).std()[::-1] |
@@ -197,6 +190,7 @@ def nimbaldetach( |
197 | 190 |
|
198 | 191 | end_crit_combined = np.sort(np.unique(np.concatenate((end_crit_1, end_crit_2)))) |
199 | 192 |
|
| 193 | + vert_nonwear_array = np.zeros(len(x_values)) |
200 | 194 | previous_end = 0 |
201 | 195 | for ind in candidate_nw_starts[0]: |
202 | 196 | if ind < previous_end: |
@@ -226,20 +220,10 @@ def nimbaldetach( |
226 | 220 | accel_start_dp = int(start_ind * accel_freq / temperature_freq) |
227 | 221 | accel_end_dp = int(bout_end_index * accel_freq / temperature_freq) |
228 | 222 | vert_nonwear_array[accel_start_dp:accel_end_dp] = 1 |
229 | | - vert_nonwear_start_datapoints.append(accel_start_dp) |
230 | | - vert_nonwear_end_datapoints.append(accel_end_dp) |
231 | 223 |
|
232 | 224 | previous_end = bout_end_index |
233 | 225 |
|
234 | | - start_stop_df = pd.DataFrame( |
235 | | - { |
236 | | - "Start Datapoint": vert_nonwear_start_datapoints, |
237 | | - "End Datapoint": vert_nonwear_end_datapoints, |
238 | | - }, |
239 | | - index=range(1, len(vert_nonwear_start_datapoints) + 1), |
240 | | - ) |
241 | | - |
242 | | - return start_stop_df, vert_nonwear_array |
| 226 | + return vert_nonwear_array |
243 | 227 |
|
244 | 228 |
|
245 | 229 | def _lowpass_filter_signal( |
|
0 commit comments