Common#
Extensions that are used for both MCorr (motion correction) and CNMF(E)
Accessor: caiman
DataFrame Extensions#
These can be called on the DataFrame
- class mesmerize_core.CaimanDataFrameExtensions(df)#
Extensions for caiman related functions
- Parameters:
df (DataFrame) –
- uloc(u)#
Return the series corresponding to the passed UUID
- Parameters:
u (str | UUID) –
- Return type:
Series
- add_item(algo, item_name, input_movie_path, params)#
Add an item to the DataFrame to organize parameters that can be used to run a CaImAn algorithm
- Parameters:
algo (str) – Name of the algorithm to run, one of
"mcorr"
,"cnmf"
or"cnmfe"
item_name (str) – User set name for the batch item
input_movie_path (str) – Full path to the input movie
params (dict) – Parameters for running the algorithm with the input movie
- save_to_disk(max_index_diff=0)#
Saves DataFrame to disk, copies to a backup before overwriting existing file.
- Parameters:
max_index_diff (int) –
- reload_from_disk()#
Returns the DataFrame on disk.
Example
df = df.caiman.reload_from_disk()
- Return type:
pd.DataFrame
- remove_item(index, remove_data=True, safe_removal=True)#
Remove a batch item from the DataFrame and delete all data associated to that batch item from disk if
remove_data=True
- Parameters:
index (int, str or UUID) – The index of the batch item to remove from the DataFrame as a numerical
int
index,str
representing a UUID, or a UUID object.remove_data (bool) – if
True
removes all output data associated to the batch item from disk. The input movie located atinput_movie_path
is not affected.safe_removal (bool) –
if
True
, this batch item is not removed and raises an exception if the output of this batch item is the input to another batch item. For example, if this is a motion correction batch item whose output is used as the input movie for a CNMF batch item.ifFalse
, this batch item is removed even if its output is the input to another batch item
- get_params_diffs(algo, item_name)#
Get the parameters that differ for a given item_name run with a given algo
- Parameters:
algo (str) – algorithm, one of “mcorr”, “cnmf”, or “cnmfe”
item_name (str) – The item name for which to get the parameter diffs
- Returns:
pandas DataFrame) with dicts containing only the parameters that vary between batch items for the given item_name. The returned index corresponds to the index of the original DataFrame
- Return type:
pd.DataFrame
- get_children(index)#
For the motion correction batch item at the provided
index
, returns a list of UUIDs for CNMF(E) batch items that use the output of this motion correction batch item.Note: Only Motion Correction items have children, CNMF(E) items do not have children.- Parameters:
index (int, str, or UUID) – the index of the mcorr item to get the children of, provided as a numerical
int
index, str representing a UUID, or a UUID object- Returns:
List of UUIDs of child CNMF items
- Return type:
List[UUID]
- get_parent(index)#
Get the UUID of the batch item whose output was used as the input for the batch item at the provided
index
.If a parent exists, it is always an mcorr batch item- Parameters:
index (int, str, or UUID) – the index of the batch item to get the parent of, provided as a numerical
int
index, str representing a UUID, or a UUID object- Returns:
- if
UUID
, this is the UUID of the batch item whose output was used for the input of the batch item atthe provided
index
ifNone
, the batch item at the providedindex
has no parent within the batch dataframe. - Return type:
UUID or None
Series Extensions#
These can be called on individual Series, or rows, of the DataFrame
- class mesmerize_core.CaimanSeriesExtensions(s)#
Extensions for caiman stuff
- Parameters:
s (Series) –
- run(backend=None, wait=True, **kwargs)#
Run a CaImAn algorithm in an external process using the chosen backend
NoRMCorre, CNMF, or CNMFE will be run for this Series. Each Series (DataFrame row) has a input_movie_path and params for the algorithm
- Parameters:
backend (str, optional) – One of the available backends, default on Linux & Mac is
"subprocess"
. Default on Windows is"local"
since Windows is inconsistent in the way it launches subprocesseswait (bool, default
True
) – if using the"subprocess"
backend, callwait()
on thePopen
instance before returning it**kwargs – any kwargs to pass to the backend
- get_input_movie_path()#
- Returns:
full path to the input movie file
- Return type:
Path
- get_input_movie(reader=None, **kwargs)#
Get the input movie
- Parameters:
reader (callable) – a function that take the input movie path and return an array-like
**kwargs – passed to
reader
function
- Return type:
ndarray | Any
- get_corr_image()#
- Returns:
correlation image
- Return type:
np.ndarray
- get_pnr_image()#
- Returns:
pnr image
- Return type:
np.ndarray
- get_projection(proj_type)#
Return the
max
,mean
, orstd
(standard deviation) projection- Parameters:
proj_type (str) – one of
"max"
,"mean"
,"std"
- Returns:
max
,mean
, orstd
projection- Return type:
np.ndarray