Skip to content

Commit

Permalink
Pin caiman version instead of catching error from old version
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbb committed Jul 24, 2024
1 parent 0a318b3 commit 9454803
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 31 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
channels:
- conda-forge
dependencies:
- caiman >= 1.9.10
- caiman >= 1.11.2
- pandas >= 1.5.0
- requests
- click
Expand Down
2 changes: 1 addition & 1 deletion environment_rtd.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
channels:
- conda-forge
dependencies:
- caiman >= 1.9.10
- caiman >= 1.11.2
- pandas >= 1.5.0
- requests
- click
Expand Down
45 changes: 16 additions & 29 deletions mesmerize_core/algorithms/mcorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,36 +88,23 @@ def run_algo(batch_path, uuid, data_path: str = None):
)
np.save(str(proj_paths[proj_type]), p_img)

def run_correlation(remove_baseline=True) -> Path:
Cns = local_correlations_movie_offline(
str(mcorr_memmap_path),
remove_baseline=remove_baseline,
window=1000,
stride=1000,
winSize_baseline=100,
quantil_min_baseline=10,
dview=dview,
)
Cn = Cns.max(axis=0)
Cn[np.isnan(Cn)] = 0
cn_path = output_dir.joinpath(f"{uuid}_cn.npy")
np.save(str(cn_path), Cn, allow_pickle=False)

print("finished computing correlation image")
return cn_path
print("Computing correlation image")
Cns = local_correlations_movie_offline(
str(mcorr_memmap_path),
remove_baseline=True,
window=1000,
stride=1000,
winSize_baseline=100,
quantil_min_baseline=10,
dview=dview,
)
Cn = Cns.max(axis=0)
Cn[np.isnan(Cn)] = 0
cn_path = output_dir.joinpath(f"{uuid}_cn.npy")
np.save(str(cn_path), Cn, allow_pickle=False)

print("finished computing correlation image")

try:
print("Computing correlation image")
cn_path = run_correlation()

except ValueError as err:
# Test for error that occurs in movie.removeBL before bug was fixed
is3D = len(dims) == 3
if is3D and len(err.args) == 1 and err.args[0] == "axes don't match array":
print("Computing correlation on 3D image failed - trying without baseline (use caiman >= 1.11.2 to fix)")
cn_path = run_correlation(remove_baseline=False)
else:
raise

# Compute shifts
if opts.motion["pw_rigid"] == True:
Expand Down

0 comments on commit 9454803

Please sign in to comment.