Skip to content

Commit

Permalink
modify to be same as codespace branch
Browse files Browse the repository at this point in the history
  • Loading branch information
sidhulyalkar committed Jan 25, 2024
1 parent 79c9e1b commit 12ff9d6
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions element_facemap/facial_behavior_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,6 @@ def make(self, key):
find_full_path(get_facemap_root_data_dir(), file_path)
).as_posix()

# Manually assign fps based on file location, as fps cannot be determined from files
if "face_camera" or "Whisker" in file_path:
fps = 100
elif (
("front_camera" or "Front" in file_path)
or ("right_camera" or "Right" in file_path)
or ("left_camera" or "Left" in file_path)
):
fps = 30
else:
raise ValueError(
"fps cannot be determined due to unknown filepath type!"
)

cap = cv2.VideoCapture(file_path)
info = (
int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)),
Expand Down Expand Up @@ -327,15 +313,13 @@ def make(self, key):
for video_file in video_files
]
]

output_dir = find_full_path(get_facemap_root_data_dir(), output_dir)
params["savepath"] = output_dir.as_posix()
params["motSVD"] = params.get("motSVD", True)
params["movSVD"] = params.get("movSVD", False)
facemap_run(
video_files,
sbin=params["sbin"],
proc=params,
savepath=params["savepath"],
savepath=output_dir.as_posix(),
motSVD=params["motSVD"],
movSVD=params["movSVD"],
)
Expand Down Expand Up @@ -447,9 +431,8 @@ def make(self, key):
Facemap outputs to the database."""

dataset, _ = get_loader_result(key, FacemapTask)

# Keep only the SVD regions (e.g. no pupil)
dataset["rois"] = [roi for roi in dataset["rois"] if "SVD" in roi["rtype"]]
# Only motion SVD region type is supported.
dataset["rois"] = [x for x in dataset["rois"] if x["rtype"] == "motion SVD"]

self.insert1(key)

Expand All @@ -466,9 +449,10 @@ def make(self, key):
yrange_bin=dataset["rois"][i]["yrange_bin"]
if "yrange_bin" in dataset["rois"][i]
else None,
motion=dataset["motion"][i],
motion=dataset["motion"][i + 1],
)
for i in range(len(dataset["rois"]))
if dataset["rois"][i]["rtype"] == "motion SVD"
]
)

Expand All @@ -485,7 +469,7 @@ def make(self, key):
motmask=dataset["motMask_reshape"][roi_no + 1][:, :, i],
projection=dataset["motSVD"][roi_no + 1][i],
)
for roi_no in range(0, len(dataset["rois"]))
for roi_no in range(len(dataset["rois"]))
for i in range(dataset["motSVD"][roi_no + 1].shape[1])
]
self.MotionSVD.insert(entry)
Expand All @@ -503,9 +487,8 @@ def make(self, key):
movmask=dataset["movMask_reshape"][roi_no + 1][:, :, i],
projection=dataset["movSVD"][roi_no + 1][i],
)
for roi_no in range(0, len(dataset["rois"]))
for roi_no in range(len(dataset["rois"]))
for i in range(dataset["movSVD"][roi_no + 1].shape[1])
if "SVD" in dataset["rois"][roi_no]["rtype"]
]
self.MovieSVD.insert(entry)

Expand Down Expand Up @@ -544,4 +527,4 @@ def get_loader_result(
loaded_dataset = np.load(output_file, allow_pickle=True).item()
creation_time = datetime.fromtimestamp(Path(output_file).stat().st_ctime)

return loaded_dataset, creation_time
return loaded_dataset, creation_time

0 comments on commit 12ff9d6

Please sign in to comment.