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

caiman extension to get input movie using pims or caiman.load_memmap #60

Merged
merged 2 commits into from
Jun 27, 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
16 changes: 14 additions & 2 deletions mesmerize_core/caiman_extensions/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import numpy as np
import pandas as pd
import pims

from ..batch_utils import (
COMPUTE_BACKENDS,
Expand All @@ -17,10 +18,11 @@
PathsSeriesExtension,
HAS_PYQT,
)
from ..utils import validate_path, IS_WINDOWS, make_runfile
from ..utils import validate_path, IS_WINDOWS, make_runfile, warning_experimental

if HAS_PYQT:
from PyQt5 import QtCore
from caiman import load_memmap


def validate(algo: str = None):
Expand Down Expand Up @@ -254,7 +256,6 @@ def run(

return self.process

@validate()
def get_input_movie_path(self) -> Path:
"""
Returns
Expand All @@ -265,6 +266,17 @@ def get_input_movie_path(self) -> Path:

return self._series.paths.resolve(self._series["input_movie_path"])

@warning_experimental()
def get_input_movie(self) -> Union[np.ndarray, pims.FramesSequence]:
extension = self.get_input_movie_path().suffixes[-1]

if extension in ['.tiff', '.tif', '.btf']:
return pims.open(str(self.get_input_movie_path()))

elif extension in ['.mmap', '.memmap']:
Yr, dims, T = load_memmap(str(self.get_input_movie_path()))
return np.reshape(Yr.T, [T] + list(dims), order="F")

@validate()
def get_correlation_image(self) -> np.ndarray:
"""
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ matplotlib
click
psutil
PyQt5
pims