Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CaImAn utilities for compatibility with latest CaImAn #113

Merged
merged 4 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions element_interface/caiman_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,10 @@ def _get_image(self, img_type):
)
else:
img_ = np.dstack(
pln_cm.motion_correction[img_type][...]
for pln_cm in self.planes.values()
[
pln_cm.motion_correction[img_type][...]
for pln_cm in self.planes.values()
]
)
return img_

Expand Down
12 changes: 9 additions & 3 deletions element_interface/run_caiman.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pathlib

import cv2
import os
import pathlib
import shutil

try:
cv2.setNumThreads(0)
Expand Down Expand Up @@ -65,6 +66,11 @@ def run_caiman(

cnmf_output_file = pathlib.Path(cnmf_output.mmap_file[:-4] + "hdf5")
assert cnmf_output_file.exists()
assert cnmf_output_file.parent == pathlib.Path(output_dir)
output_files = os.listdir(cnmf_output_file.parent)
for output_file in output_files:
try:
shutil.copy(cnmf_output_file.parent / output_file, output_dir)
except FileExistsError:
print(f"File {output_file.name} already exists in {output_dir}. Skipping.")

_save_mc(mc_output, cnmf_output_file.as_posix(), parameters["is3D"])
Loading