Skip to content

Commit

Permalink
Merge pull request #455 from flatironinstitute/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
epnev authored Feb 13, 2019
2 parents cf67385 + a488af5 commit 6cb6b32
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 53 deletions.
42 changes: 5 additions & 37 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
FROM ubuntu
FROM continuumio/anaconda3

RUN apt-get update
RUN apt-get install -y libglib2.0-0
RUN apt-get install -y git wget
RUN apt-get install bzip2
RUN apt-get install -y gcc
RUN apt-get install -y g++
RUN apt-get install -y libgtk2.0-0
RUN apt-get install -y xvfb
RUN export MINICONDA=$HOME/miniconda
RUN export PATH="$MINICONDA/bin:$PATH"
RUN hash -r
RUN wget -q https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda2-2.5.0-Linux-x86_64.sh -O anaconda.sh
# RUN bash anaconda.sh -b -p $ANACONDA
RUN bash anaconda.sh -p /anaconda -b
ENV PATH=/anaconda/bin:${PATH}
RUN conda config --set always_yes yes
RUN conda update --yes conda
RUN conda info -a
RUN CONDA_SSL_VERIFY=false conda update pyopenssl
# RUN conda install -c menpo opencv3=3.1.0
# RUN conda install -c cvxgrp cvxpy
# RUN conda install -c https://conda.anaconda.org/conda-forge tifffile
# RUN git clone --recursive -b agiovann-master https://github.com/valentina-s/Constrained_NMF.git
# RUN git clone --recursive https://github.com/agiovann/Constrained_NMF.git
# RUN git clone --recursive -b dev https://github.com/agiovann/Constrained_NMF.git
ADD . /CaImAn
WORKDIR /CaImAn/
RUN conda env update -f environment.yml -n root
#RUN conda install --file requirements_conda.txt
#RUN pip install -r requirements_pip.txt
RUN apt-get install libc6-i386
RUN apt-get install -y libsm6 libxrender1
RUN conda install pyqt=4.11.4
RUN python setup.py install
RUN python setup.py build_ext -i
RUN apt-get install -y gcc g++ libgl1
RUN mkdir src && cd src && git clone -b dev https://github.com/flatironinstitute/CaImAn.git && cd CaImAn && conda env create -n caiman -f environment.yml && conda install --override-channels -c conda-forge -n caiman pip
RUN /bin/bash -c "cd src/CaImAn && source activate caiman && /opt/conda/envs/caiman/bin/pip install ."
RUN /bin/bash -c "source activate caiman && caimanmanager.py install"

# RUN nosetests

EXPOSE 8080
11 changes: 6 additions & 5 deletions caiman/mmapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,14 @@ def save_portion(pars):
del big_mov
else:
with open(big_mov, 'r+b') as f:
f.seek(idx_start * Yr_tot.dtype.itemsize * tot_frames)
f.seek(idx_start * int(Yr_tot.dtype.itemsize) * tot_frames)
f.write(Yr_tot)
if f.tell() != idx_end * Yr_tot.dtype.itemsize * tot_frames:
logging.debug(f.tell())
logging.debug(idx_end * Yr_tot.dtype.itemsize * tot_frames)
computed_position = idx_end * int(Yr_tot.dtype.itemsize) * tot_frames
if f.tell() != computed_position:
logging.critical(f"Error in mmap portion write: at position {f.tell()}")
logging.critical(f"But should be at position {idx_end} * {Yr_tot.dtype.itemsize} * {tot_frames} = {computed_position}")
f.close()
raise Exception('Writing at the wrong location!')
raise Exception('Internal error in mmapping: Actual position does not match computed position')

del Yr_tot
logging.debug('done')
Expand Down
2 changes: 1 addition & 1 deletion caiman/source_extraction/cnmf/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ def get_file_size(file_name, var_name_hdf5=None):
T, dims = siz[0], siz[1:]
elif extension == '.avi':
cap = cv2.VideoCapture(file_name)
dims = (0, 0)
dims = [0, 0]
try:
T = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
dims[0] = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
Expand Down
17 changes: 7 additions & 10 deletions caiman/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
See Also
------------
https://docs.python.org/2/library/urllib.html
https://docs.python.org/3/library/urllib.request.htm
"""

Expand Down Expand Up @@ -36,11 +36,7 @@
except:
pass

# TODO: Simplify conditional imports below
try:
from urllib2 import urlopen
except ImportError:
from urllib.request import urlopen
from urllib.request import urlopen
from ..external.cell_magic_wand import cell_magic_wand
from ..source_extraction.cnmf.spatial import threshold_components

Expand Down Expand Up @@ -84,7 +80,8 @@ def download_demo(name='Sue_2x_3000_40_-46.tif', save_folder=''):
path_movie = os.path.join(base_folder, save_folder, name)
if not os.path.exists(path_movie):
url = file_dict[name]
logging.info("downloading " + str(name) + " with urllib")
logging.info(f"downloading {name} with urllib")
logging.info(f"GET {url} HTTP/1.1")
f = urlopen(url)
data = f.read()
with open(path_movie, "wb") as code:
Expand Down Expand Up @@ -410,8 +407,8 @@ def recursively_save_dict_contents_to_group(h5file, path, dic):
item = np.array(item)
if not isinstance(key, str):
raise ValueError("dict keys must be strings to save to hdf5")
# save strings, numpy.int64, and numpy.float64 types
if isinstance(item, (np.int64, np.float64, str, np.float, float, np.float32,int)):
# save strings, numpy.int64, numpy.int32, and numpy.float64 types
if isinstance(item, (np.int64, np.int32, np.float64, str, np.float, float, np.float32,int)):
h5file[path + key] = item
if not h5file[path + key].value == item:
raise ValueError('The data representation in the HDF5 file does not match the original dict.')
Expand Down Expand Up @@ -442,7 +439,7 @@ def recursively_save_dict_contents_to_group(h5file, path, dic):
elif type(item).__name__ in ['CNMFParams', 'Estimates']: # parameter object
recursively_save_dict_contents_to_group(h5file, path + key + '/', item.__dict__)
else:
raise ValueError('Cannot save %s type.' % type(item))
raise ValueError("Cannot save %s type for key '%s'." % (type(item), key))


def recursively_load_dict_contents_from_group( h5file, path):
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies:
- cython
- future
- h5py
- ipykernel=4.10
- ipython
- ipyparallel
- jupyter
Expand Down

0 comments on commit 6cb6b32

Please sign in to comment.