Skip to content

Commit

Permalink
caiman extension to get input movie using pims or caiman.load_memmap
Browse files Browse the repository at this point in the history
  • Loading branch information
kushalkolar committed Jun 24, 2022
1 parent b8e7723 commit b719257
Showing 1 changed file with 14 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

0 comments on commit b719257

Please sign in to comment.