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

dev into master #36

Merged
merged 5 commits into from
Jun 1, 2022
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
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
111 changes: 111 additions & 0 deletions docs/source/api/extensions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
Caiman Extensions
*****************

Pandas extensions for CaImAn functionality with DataFrames.

Common
======

Extensions that are used for both MCorr (motion correction) and CNMF(E)

.. autoclass:: mesmerize_core.CaimanDataFrameExtensions
:members:

.. autoclass:: mesmerize_core.CaimanSeriesExtensions
:members:

MCorr
=====

Extensions that are exlusive to motion correction

.. autoclass:: mesmerize_core.MCorrExtensions
:members:


CNMF
====

.. autoclass:: mesmerize_core.CNMFExtensions
:members:

Example
=======

.. code-block:: python

from mesmerize_core import COMPUTE_BACKENDS, COMPUTE_BACKEND_QPROCESS, COMPUTE_BACKEND_SLURM, \
COMPUTE_BACKEND_SUBPROCESS, set_parent_data_path, get_parent_data_path, get_full_data_path, \
load_batch, create_batch
from mesmerize_core.caiman_extensions import *

# set the parent directory as the top-level directory for your experiment data
set_parent_data_path('/home/kushal/my_exps_dir')

batch_path = '/home/kushal/my_exps_dir/my_batches/exp_1_batch.pickle'

# create a new batch
df = create_batch(batch_path)

# path to raw movie tiff file
movie_path = '/home/kushal/my_exps_dir/exp_1/my_movie.tif'

# params, exactly the same as what you'd directly use with CaImAn
mcorr_params1 =
{
'mcorr_kwargs': # this key is necessary for specifying that these are mcorr kwargs
{
'max_shifts': [24, 24],
'strides': [48, 48],
'overlaps': [24, 24],
'max_deviation_rigid': 3,
'border_nan': 'copy',
'pw_rigid': True,
'gSig_filt': None
},
}

df.caiman.add_item(
algo='mcorr',
name='my_movie',
input_movie_path=movie_path,
params=mcorr_params1
)

# We create another set of params, useful for gridsearches for example
mcorr_params2 =\
{
'mcorr_kwargs': # this key is necessary for specifying that these are mcorr kwargs
{
'max_shifts': [24, 24],
'strides': [24, 24],
'overlaps': [12, 12],
'max_deviation_rigid': 3,
'border_nan': 'copy',
'pw_rigid': True,
'gSig_filt': None
},
}

df.caiman.add_item(
algo='mcorr',
name='my_movie',
input_movie_path=movie_path,
params=mcorr_params2
)

# run the first "batch item"
process = df.iloc[0].caiman.run(
batch_path=batch_path,
backend=COMPUTE_BACKEND_SUBPROCESS, # this is for non-GUI use, COMPUTE_BACKEND_QPROCESS is for use within a Qt GUI
callbacks_finished=[lambda: print("yay finished")], # callback function for when this item finishes
)

# run the second item
# you can also use a loop to run all these items
# just call process.wait() to run them one after another
process = df.iloc[1].caiman.run(
batch_path=batch_path,
backend=COMPUTE_BACKEND_SUBPROCESS,
callbacks_finished=[lambda: print("yay finished")],
)
54 changes: 54 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'mesmerize-core'
copyright = '2022, Kushal Kolar, Arjun Putcha, Caitlin Lewis'
author = 'Kushal Kolar, Arjun Putcha, Caitlin Lewis'

# The full version, including alpha/beta/rc tags
release = '0.1'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["sphinx.ext.napoleon"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
23 changes: 23 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.. mesmerize-core documentation master file, created by
sphinx-quickstart on Wed Jun 1 17:14:50 2022.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to mesmerize-core's documentation!
==========================================

.. toctree::
:maxdepth: 2
:caption: Contents:

./api/extensions




Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
2 changes: 0 additions & 2 deletions mesmerize_core/caiman_extensions/cnmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def get_output_path(self) -> Path:
"""
return get_full_data_path(self._series["outputs"]["cnmf-hdf5-path"])

# @lru_cache(MESMERIZE_LRU_CACHE)
@validate("cnmf")
def get_output(self) -> CNMF:
"""
Expand Down Expand Up @@ -129,7 +128,6 @@ def get_spatial_masks(

# TODO: Cache this globally so that a common upper cache limit is valid for ALL batch items
@staticmethod
@lru_cache(5)
def _get_spatial_contours(
cnmf_obj: CNMF, ixs_components: Optional[np.ndarray] = None
):
Expand Down