Skip to content

Commit

Permalink
Merge pull request #337 from arayabrain/feature/add-multisession-params
Browse files Browse the repository at this point in the history
add multisession params
  • Loading branch information
ReiHashimoto authored Apr 15, 2024
2 parents 14cf459 + 546b1f3 commit 74d7286
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
19 changes: 18 additions & 1 deletion studio/app/optinist/wrappers/caiman/cnmf_multisession.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def caiman_cnmf_multisession(

Ain = reshaped_params.pop("Ain", None)
roi_thr = reshaped_params.pop("roi_thr", None)

# mulisiession params
n_reg_files = reshaped_params.pop("n_reg_files", 2)
if n_reg_files < 2:
raise Exception(f"Set n_reg_files to a integer value gte 2. Now {n_reg_files}.")
Expand All @@ -54,6 +56,13 @@ def caiman_cnmf_multisession(
)
reg_file_rate = 1.0

align_flag = reshaped_params.pop("align_flag", True)
max_thr = reshaped_params.pop("max_thr", 0)
use_opt_flow = reshaped_params.pop("use_opt_flow", True)
thresh_cost = reshaped_params.pop("thresh_cost", 0.7)
max_dist = reshaped_params.pop("max_dist", 10)
enclosed_thr = reshaped_params.pop("enclosed_thr", None)

split_image_paths = images.split_image(output_dir, n_files=n_reg_files)
n_split_images = len(split_image_paths)

Expand Down Expand Up @@ -97,7 +106,15 @@ def caiman_cnmf_multisession(
dims = templates[0].shape

spatial_union, assignments, matchings = register_multisession(
A=spatial, dims=dims, templates=templates
A=spatial,
dims=dims,
templates=templates,
align_flag=align_flag,
max_thr=max_thr,
use_opt_flow=use_opt_flow,
thresh_cost=thresh_cost,
max_dist=max_dist,
enclosed_thr=enclosed_thr,
)

reg_files = int(len(split_image_paths) * reg_file_rate)
Expand Down
14 changes: 12 additions & 2 deletions studio/app/optinist/wrappers/caiman/params/cnmf_multisession.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ data_params:

init_params:
# Ain: null # TBD: need to support 2D array type.
n_reg_files: 2 # number of files to be split.
reg_file_rate: 1.0 # threshold for the cell is detected in how many files
K: 4
gSig: [4, 4]
ssub: 1
Expand All @@ -32,6 +30,18 @@ patch_params:
merge_params:
merge_thr: 0.85

multisession_params:
# Following 2 parameters are optinist specific.
n_reg_files: 2 # number of files to be split.
reg_file_rate: 1.0 # threshold for the cell is detected in how many files
# Following parameters are from CaImAn register_multisession.
align_flag: True # align the templates before matching
max_thr: 0 # max threshold parameter before binarization
use_opt_flow: True # use dense optical flow to align templates
thresh_cost: 0.7 # maximum distance considered
max_dist: 10 # max distance between centroids
enclosed_thr: null # float, if not None set distance to at most the specified value
# when ground truth is a subset of inferred

# ----------------------------------------
# Advanced Parameters
Expand Down

0 comments on commit 74d7286

Please sign in to comment.