4. Segmentation#

Extract neuronal locations and planar time-traces.

  • Apply the constrained nonnegative matrix factorization (CNMF) source separation algorithm to extract initial estimates of neuronal spatial footprints and calcium traces.

  • Apply quality control metrics to evaluate the initial estimates, and narrow down to the final set of estimates.

We will use the same strategy as for motion correction. That is, to evaluate parameter sets for a single z-plane before applying those parameters to subsequent z-planes.

%load_ext autoreload
%autoreload 2
import os
from pathlib import Path
import logging

import lbm_mc as mc
import warnings
from lbm_mc.caiman_extensions.cnmf import cnmf_cache
import lbm_caiman_python as lcp

import fastplotlib as fpl
import pandas as pd
import numpy as np
from ipywidgets import IntSlider, VBox
from sidecar import Sidecar

try:
    import cv2
    cv2.setNumThreads(0)
except():
    pass
warnings.filterwarnings('ignore')
if os.name == "nt":
    # disable the cache on windows, this will be automatic in a future version
    cnmf_cache.set_maxsize(0)

pd.options.display.max_colwidth = 120

# Unneeded in newer versions of mesmerize-core
os.environ['CONDA_PYTHON_EXE'] = "/home/flynn/miniforge3/bin/python"
os.environ['CONDA_PREFIX_1'] = "lcp"

logger = logging.getLogger("caiman")
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler()
log_format = logging.Formatter("%(relativeCreated)12d [%(filename)s:%(funcName)10s():%(lineno)s] [%(process)d] %(message)s")
handler.setFormatter(log_format)
logger.addHandler(handler)

logging.getLogger("caiman").setLevel(logging.WARNING)

4.1. Data path setup#

Data setup is similar to motion_correction notebook.

  • you can use the same batch path and simply add onto the end of it.

  • you can define a completely new batch path to store these items separately.

Here, to keep data organized, we will:

  1. define our previous analaysis path as mcorr_batch_path

  2. create a new ‘cnmf.pickle` to save our cnmf results.

# Load MCORR batch and set raw data path
parent_path = Path().home() / "caiman_data"
data_path = parent_path / 'high_res'                # where the output files from the assembly step are located
mcorr_batch_path = data_path / 'batch.pickle'  # same as motion correction

mc.set_parent_raw_data_path(str(parent_path))

mcorr_df = mc.load_batch(mcorr_batch_path)
mcorr_df
# Now create/load a new CNMF batch
cnmf_df_path = data_path / 'cnmf_batch.pickle'
if not cnmf_df_path.exists():
    print(f'creating batch: {cnmf_df_path}')
    # cnmf_df = mc.create_batch(cnmf_df_path)
else:
    cnmf_df = mc.load_batch(cnmf_df_path)
cnmf_df
# we get metadata from our raw files
tiff_files = [mcorr_df.iloc[i].caiman.get_input_movie_path() for i in mcorr_df.index]
data = mcorr_df.iloc[0].caiman.get_input_movie()
metadata = lcp.get_metadata(tiff_files[0])
metadata

4.2. CNMF Parameters#

In this section, we’ll define a parameters object that will subsequently be used to initialize our different estimators.

Parameter

Description

Default/Typical Value

decay_time

Length of a typical transient in seconds. Approximation of the time scale for significant shifts in calcium signal. Defaults to 0.4 for fast indicators (e.g., GCaMP6f). Use 1 or more for slow indicators. Precise fitting is not necessary.

0.4 (fast indicators)

p

Order of the autoregressive model. Use p=0 to turn off deconvolution. Set p=1 for instantaneous transients (e.g., low sample rate or slow indicator). Set p=2 for visible rise time transients. Incorrect order leads to unreliable spike extraction.

1 (slow), 2 (visible rise time)

nb

Number of global background components. Defaults to 2 for relatively homogeneous backgrounds. Use 3 for more complex noise, 1 is usually too low. Too low nb causes noisy traces; too high absorbs neuronal signals, reducing transients.

2

merge_thr

Merging threshold for components after initialization. Components correlated above this threshold are merged, useful for splitting neurons during initialization.

Typically between 0.7 and 0.9

rf

Half-size of patches in pixels. Should be at least 3–4 times larger than neuron size to capture the neuron and local background. Larger patches reduce parallelization.

3–4 × expected neuron size

stride

Overlap between patches in pixels. Typically set to neuron diameter. Larger values increase computational load but improve reconstruction/denoising.

Neuron diameter (~10–20 pixels)

K

Expected number of components per patch. Adjust based on patch size (rf) and component density.

Varies based on data

gSig

Expected half-size of neurons in pixels [rows X columns]. This is a crucial parameter for accurate component detection.

Typically matches neuron half-size

method_init

Initialization method. Depends on the recording method: use greedy_roi for 2p data, corr_pnr for 1p data, and sparse_nmf for dendritic/axonal data.

greedy_roi, corr_pnr, sparse_nmf

ssub/tsub

Spatial and temporal subsampling during initialization. Defaults to 1 (no compression). Increase (e.g., 2 or more) to save resources but at the potential cost of impaired detection/extraction quality.

1 (no compression), 2+ (for resource saving)

4.2.1. The most important step#

We need to tell CaImAn our neuron size, and how many neurons to expect.

  • gSig: Your neurons half-size, in um.

    • if your typical neuron is 14um, gSig should be around 6-10.

  • K : How many neurons should CaImAn expect, PER PATCH

Warning

gSig_filt controls the filter applied in registration. Don’t confuse the two parameters!

mcorr_params = mcorr_df.params[0]
mcorr_strides = mcorr_params['main']['strides']
mcorr_overlaps = mcorr_params['main']['overlaps']
(mcorr_strides, mcorr_overlaps)
from caiman.utils.visualization import view_quilt
q = view_quilt(data[1, ...], mcorr_strides[0], mcorr_overlaps[0])

4.3. Get values for K and gSig#

get_single_patch_coords() takes your image dimensions and strides/overlaps values from registration to show you a single patch of your movie.

Use the last parameter, patch_index, to select a patch with activity. This can be a list [] or tuple (), of the row/column you want to select.

Use this widget to get an idea for the size of your neuron (in pixels) and the number of neurons you expect per-patch.

Tip

You want to slightly over-estimate the number of neurons for a value of K.

# patch at row/col 2/3
y_start, y_end, x_start, x_end = lcp.get_single_patch_coords(data.shape[1:], mcorr_strides[0], mcorr_overlaps[0], (2, 3))
data_patch_1 = data[:, y_start:y_end, x_start:x_end] 
# patch at row/col 4/6
y_start, y_end, x_start, x_end = lcp.get_single_patch_coords(data.shape[1:], mcorr_strides[0], mcorr_overlaps[0], (4, 6))
data_patch_2 = data[:, y_start:y_end, x_start:x_end] 
iw = fpl.ImageWidget(data=[data_patch_1, data_patch_2], names=["Patch [2, 3]", "Patch [4, 6]"], figure_kwargs={'size': (1600, 800)})
iw.show()
iw = fpl.ImageWidget(data=[data_patch_1.max(axis=0), data_patch_2.max(axis=0)], names=["Patch [2, 3]", "Patch [4, 6]"],  figure_kwargs={'size': (1600, 800)})
iw.show()

4.4. Set new parameters#

mcorr_strides[0] / 2
from copy import deepcopy

K = 12    # I counted 9/10 easily visible neurons in the above movie. Overestimating to 12 to account for neuron overlap / borders.
gSig = 7  # Set this to half the size of your neuron, so 7 um for an approximate neuron size of 12-15um.
rf = int(mcorr_strides[0] / 2)   # To mirror your motion correction size, mcorr_strides / 2 
stride = mcorr_overlaps[0]

cnmf_params = deepcopy(mcorr_params)
cnmf_params['main']['K'] = K
cnmf_params['main']['gSig'] = gSig
cnmf_params['main']['stride'] = stride
(rf, gSig, stride)

4.5. Run the CNMF algorithm#

The API is identical to running mcorr.

You can provide the mcorr item row to input_movie_path and it will resolve the path of the input movie from the entry in the DataFrame.

cnmf_df = cnmf_df.caiman.reload_from_disk()

cnmf_df.caiman.add_item(
    algo='cnmf',
    input_movie_path=mcorr_df.iloc[0], # our registration results row
    params=cnmf_params,
    item_name='cnmf-highres',
)
cnmf_df

Warning

If calling caiman.run() on Windows, avoid queueing / calling other jupyter cells. This can lead to the algorithm stalling.

cnmf_df.iloc[-1].caiman.run()

4.6. Checking for an errors#

After a batch run, check the results to make sure the outputs do not contain a “traceback” error.

An error-free processing run will yield “None” in the cell below. Otherwise, an error will be printed.

import pprint
# Only need to reload on windows, but it doesn't hurt.
cnmf_df = cnmf_df.caiman.reload_from_disk()
pprint.pprint(cnmf_df.iloc[-1].outputs["traceback"])

4.7. Evaluate CNMF outputs#

Similar to mcorr, you can use the mesmerize-core API to fetch the outputs.

API reference for mesmerize-CNMF API reference for caiman-CNMF

We can get a look at the total number of traces by counting how many values are in our estimates.C, which holds time-traces for each neuron (both accepted and rejected).

cnmf_model = cnmf_df.iloc[0].cnmf.get_output()

4.8. Plot CNMF Components#

lcp.plot_cnmf_components(df, marker_size=3) plots the estimates produced by CaImAn

This is essentially a small region around each “neuron”, or what CaImAn considers a neuron.

The marker is simply a dot at the center of the neuron. Red = Accepted Neuron Blue = Rejected Neuronn

lcp.plot_cnmf_components(cnmf_df)
# set the marker_size to 0 to remove center-markers
lcp.plot_cnmf_components(cnmf_df, marker_size=0)

4.9. View accepted neurons on a summary image#

  • get_contours() can take a while, ~3 minutes on a larger (1000x1000 4um/px) dataset.

  • To view rejected neurons, simply rerun with get_contours("bad", swap_dim=False)

Now we’re going to display a summary image to plot our segmentation results on top of.

You can try a variety of these images to see which gives you the clearest picture of your neurons at their most active state.

  1. Correlation Image

  2. Mean Image

  3. Standard-deviation Image

corr = cnmf_df.iloc[-1].caiman.get_corr_image()
mean_img = cnmf_df.iloc[-1].caiman.get_projection('mean')
std_img = cnmf_df.iloc[-1].caiman.get_projection('std')
corr = cnmf_df.iloc[-1].caiman.get_corr_image()
contours = cnmf_df.iloc[-1].cnmf.get_contours("good", swap_dim=False)
filtered = [a for a in contours[0] if a.size > 1]
figure = fpl.Figure(size=(700, 560))
image_graphic = figure[0, 0].add_image(data=corr, name="Correlation Image")
subplot = figure[0, 0]
graphic = subplot.add_line_collection(
    filtered,
    name="contours"
)
figure.show()
figure.close()

4.10. What happened?#

We see many more neurons than we expect. Why is this?

Lets check the patches used for CNMF.

Below is internally how CaImAn uses the rf and stride parameters to define patches.

cnmf_patch_width = cnmf_model.params.patch['rf']*2 + 1
cnmf_patch_overlap = cnmf_model.params.patch['stride'] + 1
cnmf_patch_stride = cnmf_patch_width - cnmf_patch_overlap
print(f'Patch width: {cnmf_patch_width} , Stride: {cnmf_patch_stride}, Overlap: {cnmf_patch_overlap}');

# plot the patches
patch_ax = view_quilt(corr, 
                      cnmf_model.params.patch['rf'], 
                      cnmf_model.params.patch['stride']);

4.11. Patches are tiny!#

There was an error in how we set up our patches.

from copy import deepcopy

K = 12    # I counted 9/10 easily visible neurons in the above movie. Overestimating to 12 to account for neuron overlap / borders.
gSig = 7  # Set this to half the size of your neuron, so 7 um for an approximate neuron size of 12-15um.
rf = int(mcorr_strides[0] / 2)   # To mirror your motion correction size, mcorr_strides / 2 
stride = mcorr_overlaps[0]

cnmf_params = deepcopy(mcorr_params)
cnmf_params['main']['K'] = K
cnmf_params['main']['gSig'] = gSig
cnmf_params['main']['stride'] = stride

# this time, actually set the RF parameter!
cnmf_params['main']['rf'] = rf

4.12. Rerun CNMF#

Note

Setting multiple batch-items with the same item_name allows us to call df.caiman.get_params_diffs, which gives us a nice table of parameters that differ between runs.

cnmf_df.caiman.add_item(
    algo='cnmf',
    input_movie_path=mcorr_df.iloc[0], # our registration results row
    params=cnmf_params,
    item_name='cnmf-highres',
)
cnmf_df.iloc[-1].caiman.run()
cnmf_df = cnmf_df.caiman.reload_from_disk()
cnmf_df
lcp.plot_cnmf_components(cnmf_df)
contours = cnmf_df.iloc[-1].cnmf.get_contours("good", swap_dim=False)
filtered = [a for a in contours[0] if a.size > 1]

figure = fpl.Figure(size=(700, 560))
image_graphic = figure[0, 0].add_image(data=corr, name="Correlation Image")
subplot = figure[0, 0]
graphic = subplot.add_line_collection(
    filtered,
    name="contours"
)
figure.show()
figure.close()
cnmf_model = cnmf_df.iloc[0].cnmf.get_output()
cnmf_model.dview.terminate()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[97], line 2
      1 cnmf_model = cnmf_df.iloc[0].cnmf.get_output()
----> 2 cnmf_model.dview.terminate()

AttributeError: 'NoneType' object has no attribute 'terminate'
# we overestimated by ~2 neurons, now overestimte by ~10 neurons
cnmf_params['main']['K'] = 20
cnmf_df.caiman.add_item(
    algo='cnmf',
    input_movie_path=mcorr_df.iloc[0], # our registration results row
    params=cnmf_params,
    item_name='K_20',
)
cnmf_df.iloc[-1].caiman.run()
Running db90a859-df8a-49d9-9cb8-f7a671258057 with local backend
************************************************************************

Starting CNMF item:
algo                                                                                                                                   cnmf
item_name                                                                                                                              K_20
input_movie_path    906ceafb-8dc4-4d21-8938-dd31795285de\906ceafb-8dc4-4d21-8938-dd31795285de-plane_1_els__d1_600_d2_576_d3_1_order_F_fr...
params              {'main': {'pw_rigid': True, 'max_shifts': (10, 10), 'strides': (58, 58), 'overlaps': (17, 17), 'min_mov': None, 'gSi...
outputs                                                                                                                                None
added_time                                                                                                              2025-01-10T12:32:53
ran_time                                                                                                                               None
algo_duration                                                                                                                          None
comments                                                                                                                               None
uuid                                                                                                   db90a859-df8a-49d9-9cb8-f7a671258057
Name: 2, dtype: object
With params:{'main': {'pw_rigid': True, 'max_shifts': (10, 10), 'strides': (58, 58), 'overlaps': (17, 17), 'min_mov': None, 'gSig_filt': (0, 0), 'max_deviation_rigid': 3, 'border_nan': 'copy', 'splits_els': 14, 'upsample_factor_grid': 4, 'use_cuda': False, 'num_frames_split': 50, 'niter_rig': 1, 'is3D': False, 'indices': (slice(None, None, None), slice(None, None, None)), 'splits_rig': 14, 'num_splits_to_process_rig': None, 'fr': 10, 'dxy': (1.0, 1.0), 'decay_time': 0.4, 'p': 2, 'nb': 1, 'K': 20, 'rf': 29, 'gSig': 7, 'gSiz': (25, 25), 'stride': 17, 'method_init': 'greedy_roi', 'rolling_sum': True, 'use_cnn': False, 'ssub': 1, 'tsub': 1, 'merge_thr': 0.7, 'bas_nonneg': True, 'min_SNR': 1.4, 'rval_thr': 0.8}}
       79143 [cluster.py:setup_cluster():225] [15352] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
       79218 [params.py:change_params():1151] [15352] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
making memmap
       90092 [cluster.py:setup_cluster():225] [15352] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
performing CNMF
fitting images
performing eval
<lbm_mc.caiman_extensions.common.DummyProcess at 0x1b6ef53d450>

4.13. Evaluate CNMF Results#

The next step is to adjust evaluation parameters, min_SNR and rval_thr (and cnn_thr if you used use_cnn=True).

These parameters will not compensate for poorly-calculated initialization parameters.

If you did not properly set K (number of neurons per-patch) to your patch size, and you see too many neurons, you should instead rereun segmentation with these parameters tuned to the dataset.

Note

Neurons cannot be “added” after initialization (calling caiman.run() is initialization). They can be removed quite easily.

For this reason, you should overestimate K by a few values per patch.

from mesmerize_viz import *
viz = cnmf_df.cnmf.viz(start_index=-1)
viz.show()
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\traitlets\traitlets.py:1385: DeprecationWarning: Passing unrecognized arguments to super(Layout).__init__(disabled=True).
object.__init__() takes exactly one argument (the instance to initialize)
This is deprecated in traitlets 4.2.This error will be raised in a future release of traitlets.
  warn(
c:\users\rbo\repos\mesmerize-viz\mesmerize_viz\_cnmf.py:633: DeprecationWarning: the description_tooltip argument is deprecated, use tooltip instead
  self.checkbox_zoom_components = Checkbox(
c:\users\rbo\repos\mesmerize-viz\mesmerize_viz\_cnmf.py:639: DeprecationWarning: the description_tooltip argument is deprecated, use tooltip instead
  self.zoom_components_scale = FloatSlider(
c:\users\rbo\repos\mesmerize-viz\mesmerize_viz\_cnmf.py:662: DeprecationWarning: the description_tooltip argument is deprecated, use tooltip instead
  self._radio_visible_components = RadioButtons(
c:\users\rbo\repos\mesmerize-viz\mesmerize_viz\_cnmf.py:670: DeprecationWarning: the description_tooltip argument is deprecated, use tooltip instead
  self._spinbox_alpha_invisible_contours = FloatSlider(
c:\users\rbo\repos\mesmerize-viz\mesmerize_viz\_cnmf.py:176: DeprecationWarning: the description_tooltip argument is deprecated, use tooltip instead
  spinbox = BoundedFloatText(
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\traitlets\traitlets.py:1385: DeprecationWarning: Passing unrecognized arguments to super(BoundedFloatText).__init__(readout_format='.2f').
object.__init__() takes exactly one argument (the instance to initialize)
This is deprecated in traitlets 4.2.This error will be raised in a future release of traitlets.
  warn(
c:\users\rbo\repos\mesmerize-viz\mesmerize_viz\_cnmf.py:176: DeprecationWarning: the description_tooltip argument is deprecated, use tooltip instead
  spinbox = BoundedFloatText(
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\traitlets\traitlets.py:1385: DeprecationWarning: Passing unrecognized arguments to super(BoundedFloatText).__init__(readout_format='.2f').
object.__init__() takes exactly one argument (the instance to initialize)
This is deprecated in traitlets 4.2.This error will be raised in a future release of traitlets.
  warn(
c:\users\rbo\repos\mesmerize-viz\mesmerize_viz\_cnmf.py:176: DeprecationWarning: the description_tooltip argument is deprecated, use tooltip instead
  spinbox = BoundedFloatText(
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\traitlets\traitlets.py:1385: DeprecationWarning: Passing unrecognized arguments to super(BoundedFloatText).__init__(readout_format='.2f').
object.__init__() takes exactly one argument (the instance to initialize)
This is deprecated in traitlets 4.2.This error will be raised in a future release of traitlets.
  warn(
c:\users\rbo\repos\mesmerize-viz\mesmerize_viz\_cnmf.py:176: DeprecationWarning: the description_tooltip argument is deprecated, use tooltip instead
  spinbox = BoundedFloatText(
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\traitlets\traitlets.py:1385: DeprecationWarning: Passing unrecognized arguments to super(BoundedFloatText).__init__(readout_format='.2f').
object.__init__() takes exactly one argument (the instance to initialize)
This is deprecated in traitlets 4.2.This error will be raised in a future release of traitlets.
  warn(
c:\users\rbo\repos\mesmerize-viz\mesmerize_viz\_cnmf.py:176: DeprecationWarning: the description_tooltip argument is deprecated, use tooltip instead
  spinbox = BoundedFloatText(
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\traitlets\traitlets.py:1385: DeprecationWarning: Passing unrecognized arguments to super(BoundedFloatText).__init__(readout_format='.2f').
object.__init__() takes exactly one argument (the instance to initialize)
This is deprecated in traitlets 4.2.This error will be raised in a future release of traitlets.
  warn(
c:\users\rbo\repos\mesmerize-viz\mesmerize_viz\_cnmf.py:176: DeprecationWarning: the description_tooltip argument is deprecated, use tooltip instead
  spinbox = BoundedFloatText(
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\traitlets\traitlets.py:1385: DeprecationWarning: Passing unrecognized arguments to super(BoundedFloatText).__init__(readout_format='.2f').
object.__init__() takes exactly one argument (the instance to initialize)
This is deprecated in traitlets 4.2.This error will be raised in a future release of traitlets.
  warn(
c:\users\rbo\repos\mesmerize-viz\mesmerize_viz\_cnmf.py:191: DeprecationWarning: the description_tooltip argument is deprecated, use tooltip instead
  self.use_cnn_checkbox = Checkbox(
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\traitlets\traitlets.py:1385: DeprecationWarning: Passing unrecognized arguments to super(Button).__init__(description_tooltip='Reset eval from disk').
object.__init__() takes exactly one argument (the instance to initialize)
This is deprecated in traitlets 4.2.This error will be raised in a future release of traitlets.
  warn(
viz.close()

4.14. Parameter Gridsearch#

Once you have a close approximation for a value of K, rf, stride and gSig, we can further tune these values with a grid-search.

Note

Don’t include min_SNR or rval_thr in your parameter search. These can be more effectively assessed in via mesmerize-viz.

cnmf_df.iloc[-1].params['main']['K']
cnmf_df.iloc[-1].params['main']['gSig']
(7, 7)
# itertools.product makes it easy to loop through parameter variants
# basically, it's easier to read that deeply nested for loops
from copy import deepcopy
from itertools import product

# variants of several parameters
gSig_variants = [4, 10]
K_variants = [10, 25]

# always use deepcopy like before
new_params_cnmf = deepcopy(params_cnmf)

# create a parameter grid
parameter_grid = product(gSig_variants, K_variants)

# a single for loop to go through all the various parameter combinations
for gSig, K in parameter_grid:
    # deep copy params dict just like before
    new_params_cnmf = deepcopy(new_params_cnmf)

    new_params_cnmf["main"]["gSig"] = [gSig, gSig]
    new_params_cnmf["main"]["K"] = K

    # add param combination variant to batch
    cnmf_df.caiman.add_item(
        algo="cnmf",
        # TODO: This may not be a solution to choosing a name if you want a parameter variant in the name
        item_name=cnmf_df.iloc[-1]["item_name"],
        input_movie_path=cnmf_df.iloc[-1].caiman.get_input_movie_path(),
        params=new_params_cnmf
    )
cnmf_df.caiman.get_params_diffs(algo="cnmf", item_name=cnmf_df.iloc[-1]["item_name"])
gSig K
1 (7, 7) 5
2 (4, 4) 10
3 (4, 4) 25
4 (10, 10) 10
5 (10, 10) 25

4.15. Run the cnmf batch items#

for i, row in cnmf_df.iterrows():
    if row["outputs"] is not None: # item has already been run
        continue # skip

    process = row.caiman.run()

    # on Windows you MUST reload the batch dataframe after every iteration because it uses the `local` backend.
    # this is unnecessary on Linux & Mac
    # "DummyProcess" is used for local backend so this is automatic
    if process.__class__.__name__ == "DummyProcess":
        cnmf_df = cnmf_df.caiman.reload_from_disk()
Running a5561c84-a784-433d-9e92-44112397245f with local backend
************************************************************************

Starting CNMF item:
algo                                                                                                                                   cnmf
item_name                                                                                                                          k_5_cnmf
input_movie_path    d2323217-2056-4681-9656-2ddebc721ac4\d2323217-2056-4681-9656-2ddebc721ac4-plane_10_els__d1_600_d2_576_d3_1_order_F_f...
params              {'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 10, 'gSig': (4, 4),...
outputs                                                                                                                                None
added_time                                                                                                              2024-12-07T17:11:24
ran_time                                                                                                                               None
algo_duration                                                                                                                          None
comments                                                                                                                               None
uuid                                                                                                   a5561c84-a784-433d-9e92-44112397245f
Name: 2, dtype: object
With params:{'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 10, 'gSig': (4, 4), 'gSiz': (15, 15), 'merge_thr': 0.7, 'p': 2, 'tsub': 1, 'ssub': 1, 'rf': 30, 'stride': 12, 'method_deconvolution': 'oasis', 'low_rank_background': None, 'update_background_components': True, 'del_duplicates': True, 'min_SNR': 1.5, 'rval_thr': 0.8}}
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\caiman\cluster.py:225: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
  logger.warn('The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman')
    94307817 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94307817 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94307817 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94307817 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94307817 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94307817 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94307817 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94307817 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94307817 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94307817 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94307912 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94307912 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94307912 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94307912 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94307912 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94307912 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94307912 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94307912 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94307912 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94307912 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
making memmap
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\caiman\cluster.py:225: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
  logger.warn('The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman')
    94323262 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94323262 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94323262 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94323262 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94323262 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94323262 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94323262 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94323262 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94323262 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94323262 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
performing CNMF
fitting images
performing eval
Running 65c34bc6-8f23-480e-a96a-7643afa52653 with local backend
************************************************************************

Starting CNMF item:
algo                                                                                                                                   cnmf
item_name                                                                                                                          k_5_cnmf
input_movie_path    d2323217-2056-4681-9656-2ddebc721ac4\d2323217-2056-4681-9656-2ddebc721ac4-plane_10_els__d1_600_d2_576_d3_1_order_F_f...
params              {'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 25, 'gSig': (4, 4),...
outputs                                                                                                                                None
added_time                                                                                                              2024-12-07T17:11:24
ran_time                                                                                                                               None
algo_duration                                                                                                                          None
comments                                                                                                                               None
uuid                                                                                                   65c34bc6-8f23-480e-a96a-7643afa52653
Name: 3, dtype: object
With params:{'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 25, 'gSig': (4, 4), 'gSiz': (15, 15), 'merge_thr': 0.7, 'p': 2, 'tsub': 1, 'ssub': 1, 'rf': 30, 'stride': 12, 'method_deconvolution': 'oasis', 'low_rank_background': None, 'update_background_components': True, 'del_duplicates': True, 'min_SNR': 1.5, 'rval_thr': 0.8}}
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\caiman\cluster.py:225: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
  logger.warn('The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman')
    94416773 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94416773 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94416773 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94416773 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94416773 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94416773 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94416773 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94416773 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94416773 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94416773 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94416868 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94416868 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94416868 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94416868 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94416868 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94416868 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94416868 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94416868 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94416868 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94416868 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
making memmap
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\caiman\cluster.py:225: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
  logger.warn('The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman')
    94431435 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94431435 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94431435 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94431435 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94431435 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94431435 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94431435 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94431435 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94431435 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94431435 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
performing CNMF
fitting images
performing eval
Running b322669d-7a04-4823-9003-97f6c96c9d7f with local backend
************************************************************************

Starting CNMF item:
algo                                                                                                                                   cnmf
item_name                                                                                                                          k_5_cnmf
input_movie_path    d2323217-2056-4681-9656-2ddebc721ac4\d2323217-2056-4681-9656-2ddebc721ac4-plane_10_els__d1_600_d2_576_d3_1_order_F_f...
params              {'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 10, 'gSig': (10, 10...
outputs                                                                                                                                None
added_time                                                                                                              2024-12-07T17:11:24
ran_time                                                                                                                               None
algo_duration                                                                                                                          None
comments                                                                                                                               None
uuid                                                                                                   b322669d-7a04-4823-9003-97f6c96c9d7f
Name: 4, dtype: object
With params:{'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 10, 'gSig': (10, 10), 'gSiz': (15, 15), 'merge_thr': 0.7, 'p': 2, 'tsub': 1, 'ssub': 1, 'rf': 30, 'stride': 12, 'method_deconvolution': 'oasis', 'low_rank_background': None, 'update_background_components': True, 'del_duplicates': True, 'min_SNR': 1.5, 'rval_thr': 0.8}}
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\caiman\cluster.py:225: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
  logger.warn('The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman')
    94597409 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94597409 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94597409 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94597409 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94597409 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94597409 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94597409 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94597409 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94597409 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94597409 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94597513 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94597513 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94597513 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94597513 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94597513 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94597513 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94597513 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94597513 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94597513 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94597513 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
making memmap
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\caiman\cluster.py:225: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
  logger.warn('The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman')
    94612117 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94612117 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94612117 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94612117 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94612117 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94612117 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94612117 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94612117 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94612117 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94612117 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
performing CNMF
fitting images
performing eval
Running 8661d079-d63e-470e-a2a9-4bb74ea29dc2 with local backend
************************************************************************

Starting CNMF item:
algo                                                                                                                                   cnmf
item_name                                                                                                                          k_5_cnmf
input_movie_path    d2323217-2056-4681-9656-2ddebc721ac4\d2323217-2056-4681-9656-2ddebc721ac4-plane_10_els__d1_600_d2_576_d3_1_order_F_f...
params              {'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 25, 'gSig': (10, 10...
outputs                                                                                                                                None
added_time                                                                                                              2024-12-07T17:11:24
ran_time                                                                                                                               None
algo_duration                                                                                                                          None
comments                                                                                                                               None
uuid                                                                                                   8661d079-d63e-470e-a2a9-4bb74ea29dc2
Name: 5, dtype: object
With params:{'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 25, 'gSig': (10, 10), 'gSiz': (15, 15), 'merge_thr': 0.7, 'p': 2, 'tsub': 1, 'ssub': 1, 'rf': 30, 'stride': 12, 'method_deconvolution': 'oasis', 'low_rank_background': None, 'update_background_components': True, 'del_duplicates': True, 'min_SNR': 1.5, 'rval_thr': 0.8}}
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\caiman\cluster.py:225: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
  logger.warn('The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman')
    94703685 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94703685 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94703685 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94703685 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94703685 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94703685 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94703685 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94703685 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94703685 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94703685 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94703778 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94703778 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94703778 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94703778 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94703778 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94703778 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94703778 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94703778 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94703778 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
    94703778 [params.py:change_params():1151] [16948] In setting CNMFParams, non-pathed parameters were used; this is deprecated. In some future version of Caiman, allow_legacy will default to False (and eventually will be removed)
making memmap
C:\Users\RBO\miniforge3\envs\lcp\lib\site-packages\caiman\cluster.py:225: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
  logger.warn('The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman')
    94718135 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94718135 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94718135 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94718135 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94718135 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94718135 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94718135 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94718135 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94718135 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
    94718135 [cluster.py:setup_cluster():225] [16948] The local backend is an alias for the multiprocessing backend, and the alias may be removed in some future version of Caiman
performing CNMF
fitting images
performing eval
cnmf_df = cnmf_df.caiman.reload_from_disk()
cnmf_df
algo item_name input_movie_path params outputs added_time ran_time algo_duration comments uuid
0 cnmf mcorr_cnmf d2323217-2056-4681-9656-2ddebc721ac4\d2323217-2056-4681-9656-2ddebc721ac4-plane_10_els__d1_600_d2_576_d3_1_order_F_f... {'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 50, 'gSig': (7, 7),... {'mean-projection-path': a5c2f791-6d1b-4712-a66f-2c92adde5d61\a5c2f791-6d1b-4712-a66f-2c92adde5d61_mean_projection.n... 2024-12-07T14:25:59 2024-12-07T16:01:05 363.6 sec None a5c2f791-6d1b-4712-a66f-2c92adde5d61
1 cnmf k_5_cnmf d2323217-2056-4681-9656-2ddebc721ac4\d2323217-2056-4681-9656-2ddebc721ac4-plane_10_els__d1_600_d2_576_d3_1_order_F_f... {'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 5, 'gSig': (7, 7), ... {'mean-projection-path': b9d43fcf-3aa8-4cf8-b186-c934afd77aa1\b9d43fcf-3aa8-4cf8-b186-c934afd77aa1_mean_projection.n... 2024-12-07T16:24:46 2024-12-07T16:26:18 90.23 sec None b9d43fcf-3aa8-4cf8-b186-c934afd77aa1
2 cnmf k_5_cnmf d2323217-2056-4681-9656-2ddebc721ac4\d2323217-2056-4681-9656-2ddebc721ac4-plane_10_els__d1_600_d2_576_d3_1_order_F_f... {'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 10, 'gSig': (4, 4),... {'mean-projection-path': a5561c84-a784-433d-9e92-44112397245f\a5561c84-a784-433d-9e92-44112397245f_mean_projection.n... 2024-12-07T17:11:24 2024-12-07T17:15:25 108.93 sec None a5561c84-a784-433d-9e92-44112397245f
3 cnmf k_5_cnmf d2323217-2056-4681-9656-2ddebc721ac4\d2323217-2056-4681-9656-2ddebc721ac4-plane_10_els__d1_600_d2_576_d3_1_order_F_f... {'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 25, 'gSig': (4, 4),... {'mean-projection-path': 65c34bc6-8f23-480e-a96a-7643afa52653\65c34bc6-8f23-480e-a96a-7643afa52653_mean_projection.n... 2024-12-07T17:11:24 2024-12-07T17:18:26 180.61 sec None 65c34bc6-8f23-480e-a96a-7643afa52653
4 cnmf k_5_cnmf d2323217-2056-4681-9656-2ddebc721ac4\d2323217-2056-4681-9656-2ddebc721ac4-plane_10_els__d1_600_d2_576_d3_1_order_F_f... {'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 10, 'gSig': (10, 10... {'mean-projection-path': b322669d-7a04-4823-9003-97f6c96c9d7f\b322669d-7a04-4823-9003-97f6c96c9d7f_mean_projection.n... 2024-12-07T17:11:24 2024-12-07T17:20:12 106.26 sec None b322669d-7a04-4823-9003-97f6c96c9d7f
5 cnmf k_5_cnmf d2323217-2056-4681-9656-2ddebc721ac4\d2323217-2056-4681-9656-2ddebc721ac4-plane_10_els__d1_600_d2_576_d3_1_order_F_f... {'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 25, 'gSig': (10, 10... {'mean-projection-path': 8661d079-d63e-470e-a2a9-4bb74ea29dc2\8661d079-d63e-470e-a2a9-4bb74ea29dc2_mean_projection.n... 2024-12-07T17:11:24 2024-12-07T17:23:20 188.52 sec None 8661d079-d63e-470e-a2a9-4bb74ea29dc2
image_data_options = [ "input", ]
viz = cnmf_df.cnmf.viz(start_index=0, image_data_options=image_data_options)
viz.show()
viz.close()

4.16. Pick the best parameter set#

rows_keep = [0]
for i, row in cnmf_df.iterrows():
    if i not in rows_keep:
        cnmf_df.caiman.remove_item(row.uuid, safe_removal=False)
cnmf_df
algo item_name input_movie_path params outputs added_time ran_time algo_duration comments uuid
0 cnmf k_5_cnmf d2323217-2056-4681-9656-2ddebc721ac4\d2323217-2056-4681-9656-2ddebc721ac4-plane_10_els__d1_600_d2_576_d3_1_order_F_f... {'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 10, 'gSig': (4, 4),... {'mean-projection-path': a5561c84-a784-433d-9e92-44112397245f\a5561c84-a784-433d-9e92-44112397245f_mean_projection.n... 2024-12-07T17:11:24 2024-12-07T17:15:25 108.93 sec None a5561c84-a784-433d-9e92-44112397245f

4.17. Adjust quality metrics based on evaluation parameters#

min_SNR: float
    trace SNR threshold
SNR_lowest: float
    minimum required trace SNR
rval_thr: float
    space correlation threshold
rval_lowest: float
    minimum required space correlation
use_cnn: bool
    flag for using the CNN classifier
min_cnn_thr: float
    CNN classifier threshold
from copy import deepcopy

new_params = deepcopy(cnmf_df.iloc[0].params)

# assign the "max_shifts"
new_params["main"]["min_SNR"] = 2.1
new_params["main"]["SNR_lowest"] = 3.25
new_params["main"]["rval_thr"] = 0.3
# new_params["main"]["rval_lowest"] = 0.0
cnmf_df = cnmf_df.caiman.reload_from_disk()
cnmf_df
algo item_name input_movie_path params outputs added_time ran_time algo_duration comments uuid
0 cnmf k_5_cnmf d2323217-2056-4681-9656-2ddebc721ac4\d2323217-2056-4681-9656-2ddebc721ac4-plane_10_els__d1_600_d2_576_d3_1_order_F_f... {'main': {'fr': 9.60806, 'use_cnn': False, 'dxy': (1.04, 1.0), 'method_init': 'greedy_roi', 'K': 10, 'gSig': (4, 4),... {'mean-projection-path': a5561c84-a784-433d-9e92-44112397245f\a5561c84-a784-433d-9e92-44112397245f_mean_projection.n... 2024-12-07T17:11:24 2024-12-07T17:15:25 108.93 sec None a5561c84-a784-433d-9e92-44112397245f
output_path = Path(cnmf_df.iloc[0].input_movie_path).stem
for i, row in mcorr_df.iterrows():
    # Don't process the same file twice
    if Path(row.mcorr.get_output_path()).stem == output_path:
        continue

    cnmf_df.caiman.add_item(
        algo='cnmf',
        input_movie_path=row,
        params=new_params,          # use the same parameters
        item_name=f'cnmf_batch',  # filename of the movie, but can be anything
    )
# double check that the new value is set properly
cnmf_df.iloc[-1].params['main']['min_SNR']
2.1
for i, row in cnmf_df.iterrows():
    if row["outputs"] is not None: # item has already been run
        continue # skip

    process = row.caiman.run()

    # on Windows you MUST reload the batch dataframe after every iteration because it uses the `local` backend.
    # this is unnecessary on Linux & Mac
    # "DummyProcess" is used for local backend so this is automatic
    if process.__class__.__name__ == "DummyProcess":
        cnmf_df = cnmf_df.caiman.reload_from_disk()

4.18. Extras#

import fastplitlib as fpl

# create image widget for raw neural activity
raw_iw = fpl.Figure()

# re-add our identified good components from before using the SNR mapping
contours_graphic = raw_iw[0,0].add_line_collection(data=contours, cmap="spring", thickness=2, name="contours")

# get temporal components
temporal = df.iloc[row_ix].cnmf.get_temporal(component_indices="good")

# temporal plot
plot_temporal = fpl.Figure(size=(600,100))
plot_temporal[0,0].add_line(temporal[0], colors="magenta")

# add a linear selector to temporal trace
plot_temporal[0,0].graphics[0].add_linear_selector()

# show temporal plot and mcorr/rcm plot in ipywidgets VBox
sc = Sidecar()

# with sc:
display(VBox([raw_iw.show(), plot_temporal.show()]))
index = -1  # the last item added

rcb = df.iloc[index].cnmf.get_rcb()
residuals = df.iloc[index].cnmf.get_residuals()
input_movie = df.iloc[index].caiman.get_input_movie()

# temporal components
temporal = df.iloc[index].cnmf.get_temporal()

temporal_good = df.iloc[index].cnmf.get_temporal("good")
temporal_bad = df.iloc[index].cnmf.get_temporal("bad")

temporal_with_residuals = df.iloc[index].cnmf.get_temporal(add_residuals=True)

correlation_image = df.iloc[-1].caiman.get_corr_image()

components_good = df.iloc[-1].cnmf.get_good_components()
components_bad = df.iloc[-1].cnmf.get_bad_components()

mean_img = df.iloc[-1].caiman.get_projection('mean')
std_img = df.iloc[-1].caiman.get_projection('std')

masks = df.iloc[-1].cnmf.get_masks()

print(f'Temporal Components (good/bad): {temporal_good.shape} / {temporal_bad.shape}')
print(f'Spatial Components (good/bad): {components_good.shape} / {components_bad.shape}')
Temporal Components (good/bad): (2111, 1000) / (2683, 1000)
Spatial Components (good/bad): (2111,) / (2683,)
row_ix = 1
# get the contours and center of masses using lbm_mc
contours, coms = df.iloc[row_ix].cnmf.get_contours(component_indices="good", swap_dim=False)

# get the signal-to-noise ratio of each "good" component to color components
snr_comps = df.iloc[row_ix].cnmf.get_output().estimates.SNR_comp

# get the good component_ixs
good_ixs = df.iloc[row_ix].cnmf.get_good_components()

# only get snr_comps of good_ixs
snr_comps = snr_comps[good_ixs]

np.log10(snr_comps)[:10]