diff --git a/caiman/base/movies.py b/caiman/base/movies.py index 44e461b95..4628ee134 100644 --- a/caiman/base/movies.py +++ b/caiman/base/movies.py @@ -38,7 +38,8 @@ from tqdm import tqdm from typing import Any, Dict, List, Tuple, Union import warnings -import z5py +# Flip to normal import if this is ever resolved: https://github.com/constantinpape/z5/issues/146 +# import z5py from zipfile import ZipFile import caiman as cm @@ -1288,7 +1289,7 @@ def play(self, im.axes.figure.canvas.draw() pl.pause(1) - if backend == 'notebook': + elif backend == 'notebook': # First set up the figure, the axis, and the plot element we want to animate fig = pl.figure() im = pl.imshow(self[0], interpolation='None', cmap=pl.cm.gray) @@ -1685,6 +1686,10 @@ def rgb2gray(rgb): raise Exception('Key not found in hdf5 file') elif extension in ('.n5', '.zarr'): + try: + import z5py + except ImportError: + raise Exception("z5py library not available; if you need this functionality use the conda package") with z5py.File(file_name, "r") as f: fkeys = list(f.keys()) if len(fkeys) == 1: # If the n5/zarr file we're parsing has only one dataset inside it, ignore the arg and pick that dataset diff --git a/caiman/source_extraction/cnmf/utilities.py b/caiman/source_extraction/cnmf/utilities.py index afe18b1ce..183ca73b1 100644 --- a/caiman/source_extraction/cnmf/utilities.py +++ b/caiman/source_extraction/cnmf/utilities.py @@ -35,7 +35,8 @@ import scipy.ndimage.morphology as morph import tifffile from typing import List -import z5py +# https://github.com/constantinpape/z5/issues/146 +#import z5py from .initialization import greedyROI from ...base.rois import com @@ -1029,6 +1030,11 @@ def get_file_size(file_name, var_name_hdf5='mov'): raise Exception('Variable not found. Use one of the above') T, dims = siz[0], siz[1:] elif extension in ('.n5', '.zarr'): + try: + import z5py + except: + raise Exception("z5py not available; if you need this use the conda-based setup") + with z5py.File(file_name, "r") as f: kk = list(f.keys()) if len(kk) == 1: diff --git a/requirements.txt b/requirements.txt index 3a8da3460..b5b252845 100644 --- a/requirements.txt +++ b/requirements.txt @@ -27,4 +27,3 @@ tifffile tk tqdm yapf -z5py diff --git a/requirements_gpu.txt b/requirements_gpu.txt index 525d0f538..b3e57bb6e 100644 --- a/requirements_gpu.txt +++ b/requirements_gpu.txt @@ -25,4 +25,3 @@ tifffile tk tqdm yapf -z5py