Skip to content

Commit

Permalink
introduce parameter p_patch
Browse files Browse the repository at this point in the history
  • Loading branch information
epnev committed Aug 22, 2019
1 parent 4911022 commit 4c61126
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions caiman/source_extraction/cnmf/map_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ def cnmf_patches(args_in):
opts.set('patch', {'n_processes': 1, 'rf': None, 'stride': None})
for group in ('init', 'temporal', 'spatial'):
opts.set(group, {'nb': params.get('patch', 'nb_patch')})
for group in ('preprocess', 'temporal'):
opts.set(group, {'p': params.get('patch', 'p_patch')})

cnm = cnmf.CNMF(n_processes=1, params=opts)

Expand Down
6 changes: 5 additions & 1 deletion caiman/source_extraction/cnmf/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def __init__(self, fnames=None, dims=None, dxy=(1, 1),
only_init: bool, default: True
whether to run only the initialization
p_patch: int, default: 0
order of AR dynamics when processing within a patch
skip_refinement: bool, default: False
Whether to skip refinement of components (deprecated?)
Expand Down Expand Up @@ -575,7 +578,7 @@ def __init__(self, fnames=None, dims=None, dxy=(1, 1),
'decay_time': decay_time,
'dxy': dxy,
'var_name_hdf5': var_name_hdf5,
'caiman_version': '1.6.1',
'caiman_version': '1.6.2',
'last_commit': None,
'mmap_F': None,
'mmap_C': None
Expand All @@ -590,6 +593,7 @@ def __init__(self, fnames=None, dims=None, dxy=(1, 1),
'n_processes': n_processes,
'nb_patch': nb_patch,
'only_init': only_init_patch,
'p_patch': 0, # AR order within patch
'remove_very_bad_comps': remove_very_bad_comps,
'rf': rf,
'skip_refinement': False,
Expand Down
8 changes: 5 additions & 3 deletions demos/general/demo_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def main():

# parameters for component evaluation
opts_dict = {'fnames': fnames,
'p': p,
'fr': fr,
'nb': gnb,
'rf': rf,
Expand All @@ -187,9 +188,11 @@ def main():
opts.change_params(params_dict=opts_dict);
# %% RUN CNMF ON PATCHES
# First extract spatial and temporal components on patches and combine them
# for this step deconvolution is turned off (p=0)
# for this step deconvolution is turned off (p=0). If you want to have
# deconvolution within each patch change params.patch['p_patch'] to a
# nonzero value

opts.change_params({'p': 0})
#opts.change_params({'p': 0})
cnm = cnmf.CNMF(n_processes, params=opts, dview=dview)
cnm = cnm.fit(images)

Expand All @@ -209,7 +212,6 @@ def main():
cnm.save(fname_new[:-5]+'_init.hdf5')

# %% RE-RUN seeded CNMF on accepted patches to refine and perform deconvolution
cnm.params.change_params({'p': p})
cnm2 = cnm.refit(images, dview=dview)
# %% COMPONENT EVALUATION
# the components are evaluated in three ways:
Expand Down
13 changes: 6 additions & 7 deletions demos/notebooks/demo_pipeline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
" 'max_shifts': max_shifts,\n",
" 'max_deviation_rigid': max_deviation_rigid,\n",
" 'pw_rigid': pw_rigid,\n",
" 'p': 1,\n",
" 'p': p,\n",
" 'nb': gnb,\n",
" 'rf': rf,\n",
" 'K': K, \n",
Expand Down Expand Up @@ -306,7 +306,7 @@
"#%% MEMORY MAPPING\n",
"# memory map the file in order 'C'\n",
"fname_new = cm.save_memmap(mc.mmap_file, base_name='memmap_', order='C',\n",
" border_to_0=border_to_0) # exclude borders\n",
" border_to_0=border_to_0, dview=dview) # exclude borders\n",
"\n",
"# now load the file\n",
"Yr, dims, T = cm.load_memmap(fname_new)\n",
Expand Down Expand Up @@ -354,10 +354,10 @@
"source": [
"%%capture\n",
"#%% RUN CNMF ON PATCHES\n",
"\n",
"# First extract spatial and temporal components on patches and combine them\n",
"# for this step deconvolution is turned off (p=0)\n",
"opts.change_params({'p': 0})\n",
"# for this step deconvolution is turned off (p=0). If you want to have\n",
"# deconvolution within each patch change params.patch['p_patch'] to a\n",
"# nonzero value\n",
"cnm = cnmf.CNMF(n_processes, params=opts, dview=dview)\n",
"cnm = cnm.fit(images)"
]
Expand Down Expand Up @@ -419,7 +419,6 @@
"source": [
"%%capture\n",
"#%% RE-RUN seeded CNMF on accepted patches to refine and perform deconvolution \n",
"cnm.params.change_params({'p': p})\n",
"cnm2 = cnm.refit(images, dview=dview)"
]
},
Expand Down Expand Up @@ -648,7 +647,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.6.8"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 4c61126

Please sign in to comment.