Skip to content

Commit

Permalink
Merge pull request #60 from nel-lab/get-large-input-movie
Browse files Browse the repository at this point in the history
caiman extension to get input movie using pims or caiman.load_memmap
  • Loading branch information
kushalkolar authored Jun 27, 2022
2 parents 9b93a02 + 1498566 commit aed1328
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
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

0 comments on commit aed1328

Please sign in to comment.