Commit 65376047 authored by lucas_miranda's avatar lucas_miranda
Browse files

Implemented outlier interpolation

parent 23168afd
Pipeline #93120 failed with stage
in 37 minutes and 52 seconds
......@@ -63,7 +63,7 @@ class project:
interpolate_outliers: bool = True,
interpolation_limit: int = 5,
interpolation_std: int = 5,
likelihood_tol: float = 0.75,
likelihood_tol: float = 0.25,
model: str = "mouse_topview",
path: str = deepof.utils.os.path.join("."),
smooth_alpha: float = 0.99,
......@@ -296,7 +296,9 @@ class project:
print("Iterative imputation of ocluded bodyparts...")
for k, value in tab_dict.items():
imputed = IterativeImputer(max_iter=250, skip_complete=True).fit_transform(value)
imputed = IterativeImputer(
max_iter=250, skip_complete=True
).fit_transform(value)
tab_dict[k] = pd.DataFrame(
imputed, index=value.index, columns=value.columns
)
......
......@@ -652,27 +652,25 @@ def tag_rulebased_frames(
)
)
if len(animal_ids) > 1:
if debug:
# Print arena for debugging
cv2.ellipse(frame, arena[0], arena[1], arena[2], 0, 360, (0, 255, 0), 3)
# Print body parts for debuging
for bpart in coords.columns.levels[0]:
if not np.isnan(coords[bpart]["x"][fnum]):
cv2.circle(
frame,
(int(coords[bpart]["x"][fnum]), int(coords[bpart]["y"][fnum])),
radius=3,
color=(
(255, 0, 0) if bpart.startswith(animal_ids[0]) else (0, 0, 255)
),
thickness=-1,
)
# Print frame number
write_on_frame("Frame " + str(fnum), (int(w * 0.3 / 10), int(h / 1.15)))
if debug:
# Print arena for debugging
cv2.ellipse(frame, arena[0], arena[1], arena[2], 0, 360, (0, 255, 0), 3)
# Print body parts for debuging
for bpart in coords.columns.levels[0]:
if not np.isnan(coords[bpart]["x"][fnum]):
cv2.circle(
frame,
(int(coords[bpart]["x"][fnum]), int(coords[bpart]["y"][fnum])),
radius=3,
color=(
(255, 0, 0)
if bpart.startswith(animal_ids[0])
else (0, 0, 255)
),
thickness=-1,
)
# Print frame number
write_on_frame("Frame " + str(fnum), (int(w * 0.3 / 10), int(h / 1.15)))
if len(animal_ids) > 1:
if tag_dict["nose2nose"][fnum] and not tag_dict["sidebyside"][fnum]:
write_on_frame("Nose-Nose", conditional_pos())
......@@ -721,7 +719,7 @@ def tag_rulebased_frames(
if len(animal_ids) > 1:
colcond = frame_speeds[_id] == max(list(frame_speeds.values()))
else:
colcond = hparams["huddle_speed"] > frame_speeds
colcond = hparams["huddle_speed"] < frame_speeds
write_on_frame(
str(
......
......@@ -460,7 +460,7 @@ def interpolate_outliers(
lag: int = 5,
n_std: int = 3,
mode: str = "or",
limit: int = 15,
limit: int = 10,
):
"""Marks all outliers in experiment and replaces them using a univariate linear interpolation approach.
Note that this approach only works for equally spaced data (constant camera acquisition rates).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment