Code Monkey home page Code Monkey logo

mesmerize-napari's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mesmerize-napari's Issues

TODO: Offline Analysis

  • Main Offline Gui can call CNMF and MCorr Guis respectively
  • pd dataframe creation and management
  • Adding cnmf and mcorr items to dataframe (and in list widget ui)
  • Extracting parameters from cnmf and mcorr guis, saving to respective item in dataframe
  • Removal of items (in dataframe and in list widget ui)
  • Run motion correction with input parameters
  • Run cnmf with input parameters (refit is also possible)
  • Display results of cnmf in napari
  • Selecting item in listwidget displays parameters in param_textbox
  • stdout shown in stdout_textbox on main gui
  • Read F order memmaps in napari to display mcorr results
  • show mcorr mean projection
  • Load associated CNMF video upon double click
  • Visualize correlation image as a layer
  • napari1d multi line for CNMF traces
  • Component evaluation GUI to filter components
  • Find out best way to visualize ROIs, possible to show a mask or just outline? For showing ROIs without filled color, just set face_color with alpha=0.0
  • Click on a ROI, highlight the ROI and trace @YichengZou626
  • Plot elastic shifts using napari-1d @ArjunPutcha
  • show downsampled (avg within a window) of mcorr output @ArjunPutcha
  • Fix infline of mcorr viewer @ArjunPutcha
  • Add CNMFE
  • GUI doubleSpinBox to enter framerate of video file @ArjunPutcha
  • Save new idx_components after filtering @kushalkolar
  • See how napari can do random access scrolling of tif files etc.
  • tests
  • setup.py
  • CNMF C-order memmaps should be saved with the uuid as the prefix for the filename

Nice to have's:

  • Show reconstructed movie (denoised, deconvolved etc.), try to compute it on the fly @kushalkolar
  • View raw and mcorr movie side by side
  • View windowed mean mcorr video, button for this in the viz tab in the main GUI
    • np.mean(movie[i - 2: i + 2], axis=0)
  • Visualization tab in the main GUI
  • Draw a square ROI and display traces within this square
  • In addition to current CNMF GUI, a separate window that shows stitched spatial components, one component per frame, as user moves sliders show the temporal component.
  • Viz tab, option to view ROIs as a mask or outline. Outline doesn't work when ROIs look really bad.
  • Dropdown menu to select which movie to use as input file path for param selection @kushalkolar

Eval GUI is broken

Eval GUI appears to be broken? Tested with the Sue demo movie.

@ArjunPutcha have you tried the eval gui recently?

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~/Insync/kushalkolar@gmail.com/drive/repos/mesmerize-napari/mesmerize_napari/evaluate_components.py:49, in EvalComponentsWidgets.update_components(self=)
     46 cnmf_obj: CNMF = self.cnmf_viewer.cnmf_obj
     47 cnmf_obj.params.quality.update(params)
---> 49 cnmf_obj.estimates.filter_components(
        cnmf_obj = 
        cnmf_obj.estimates = 
        self.cnmf_viewer = 
        self = 
        self.cnmf_viewer.batch_item.cnmf = 
        self.cnmf_viewer.batch_item = algo                                                             cnmf
name                                                        test-cnmf
input_movie_path    a89c5872-4e50-44e4-8735-6dce4c6f2411-mcorr_els...
params              {'cnmf_kwargs': {'p': 2, 'nb': 1, 'rf': None, ...
outputs             {'mean-projection-path': 5f7a4906-9228-4868-8a...
uuid                             5f7a4906-9228-4868-8a82-c449071eb15d
Name: 1, dtype: object
        cnmf_obj.params = CNMFParams:

data:

{'caiman_version': '1.9.10',
 'decay_time': 1,
 'dims': b'NoneType',
 'dxy': (1, 1),
 'fnames': b'NoneType',
 'fr': 30,
 'last_commit': 'GITW-ae589c04ca7f8bead391b2dd14573c8cc9b3015e',
 'mmap_C': b'NoneType',
 'mmap_F': b'NoneType',
 'var_name_hdf5': 'mov'}

spatial_params:

{'block_size_spat': 5000,
 'dist': 3,
 'expandCore':  (5, 5) int64,
 'extract_cc': True,
 'maxthr': 0.1,
 'medw': b'NoneType',
 'method_exp': 'dilate',
 'method_ls': 'lasso_lars',
 'n_pixels_per_process': 208,
 'nb': 1,
 'normalize_yyt_one': True,
 'nrgthr': 0.9999,
 'num_blocks_per_run_spat': 20,
 'se': b'NoneType',
 'ss': b'NoneType',
 'thr_method': 'nrg',
 'update_background_components': True}

temporal_params:

{'ITER': 2,
 'bas_nonneg': False,
 'block_size_temp': 5000,
 'fudge_factor': 0.96,
 'lags': 5,
 'memory_efficient': False,
 'method_deconvolution': 'oasis',
 'nb': 1,
 'noise_method': 'mean',
 'noise_range':  (2,) float64,
 'num_blocks_per_run_temp': 20,
 'optimize_g': False,
 'p': 2,
 's_min': b'NoneType',
 'solvers':  (2,) |S4,
 'verbosity': False}

init_params:

{'K': 10,
 'SC_kernel': 'heat',
 'SC_nnn': 20,
 'SC_normalize': True,
 'SC_sigma': 1,
 'SC_thr': 0,
 'SC_use_NN': False,
 'alpha_snmf': 100,
 'center_psf': False,
 'gSig':  (2,) int64,
 'gSiz':  (2,) int64,
 'init_iter': 2,
 'kernel': b'NoneType',
 'lambda_gnmf': 1,
 'maxIter': 5,
 'max_iter_snmf': 500,
 'method_init': 'greedy_roi',
 'min_corr': 0.85,
 'min_pnr': 20,
 'nIter': 5,
 'nb': 1,
 'normalize_init': True,
 'options_local_NMF': b'NoneType',
 'perc_baseline_snmf': 20,
 'ring_size_factor': 1.5,
 'rolling_length': 100,
 'rolling_sum': True,
 'seed_method': 'auto',
 'sigma_smooth_snmf': (0.5, 0.5, 0.5),
 'ssub': 1,
 'ssub_B': 2,
 'tsub': 1}

preprocess_params:

{'check_nan': True,
 'compute_g': False,
 'include_noise': False,
 'lags': 5,
 'max_num_samples_fft': 3072,
 'n_pixels_per_process': 208,
 'noise_method': 'mean',
 'noise_range':  (2,) float64,
 'p': 2,
 'pixels': b'NoneType',
 'sn': b'NoneType'}

patch_params:

{'border_pix': 0,
 'del_duplicates': False,
 'in_memory': True,
 'low_rank_background': True,
 'memory_fact': 1,
 'n_processes': 23,
 'nb_patch': 1,
 'only_init': False,
 'p_patch': 0,
 'p_ssub': 2,
 'p_tsub': 2,
 'remove_very_bad_comps': False,
 'rf': b'NoneType',
 'skip_refinement': False,
 'stride': 30}

online:

{'N_samples_exceptionality': 30,
 'W_update_factor': 1,
 'batch_update_suff_stat': False,
 'dist_shape_update': False,
 'ds_factor': 1,
 'epochs': 1,
 'expected_comps': 500,
 'full_XXt': False,
 'init_batch': 2000,
 'init_method': 'bare',
 'iters_shape': 5,
 'max_comp_update_shape': inf,
 'max_num_added': 5,
 'max_shifts_online': 10,
 'min_SNR': 2.5,
 'min_num_trial': 5,
 'minibatch_shape': 100,
 'minibatch_suff_stat': 5,
 'motion_correct': True,
 'movie_name_online': 'online_movie.mp4',
 'n_refit': 0,
 'normalize': False,
 'num_times_comp_updated': inf,
 'opencv_codec': 'H264',
 'path_to_model': '/home/kushal/caiman_data/model/cnn_model_online.h5',
 'ring_CNN': False,
 'rval_thr': 0.8,
 'save_online_movie': False,
 'show_movie': False,
 'simultaneously': False,
 'sniper_mode': False,
 'stop_detection': False,
 'test_both': False,
 'thresh_CNN_noisy': 0.5,
 'thresh_fitness_delta': -50,
 'thresh_fitness_raw': -152.44944831836074,
 'thresh_overlap': 0.5,
 'update_freq': 200,
 'update_num_comps': True,
 'use_corr_img': False,
 'use_dense': True,
 'use_peak_max': True}

quality:

{'SNR_lowest': 0.0,
 'cnn_lowest': 0.0,
 'gSig_range': b'NoneType',
 'max_ecc': 3,
 'min_SNR': 0.5,
 'min_cnn_thr': 0.5,
 'rval_lowest': 0.2000000000000001,
 'rval_thr': 0.0,
 'use_cnn': True,
 'use_ecc': False}

merging:

{'do_merge': True,
 'max_merge_area': b'NoneType',
 'merge_parallel': False,
 'merge_thr': 0.8}

motion:

{'border_nan': 'copy',
 'gSig_filt': b'NoneType',
 'indices':  (2,) |S32,
 'is3D': False,
 'max_deviation_rigid': 3,
 'max_shifts': (6, 6),
 'min_mov': b'NoneType',
 'niter_rig': 1,
 'nonneg_movie': True,
 'num_frames_split': 80,
 'num_splits_to_process_els': b'NoneType',
 'num_splits_to_process_rig': b'NoneType',
 'overlaps': (32, 32),
 'pw_rigid': False,
 'shifts_opencv': True,
 'splits_els': 14,
 'splits_rig': 14,
 'strides': (96, 96),
 'upsample_factor_grid': 4,
 'use_cuda': False}

ring_CNN:

{'loss_fn': 'pct',
 'lr': 0.001,
 'lr_scheduler': b'NoneType',
 'max_epochs': 100,
 'n_channels': 2,
 'path_to_model': b'NoneType',
 'patience': 3,
 'pct': 0.01,
 'remove_activity': False,
 'reuse_model': False,
 'use_add': False,
 'use_bias': False,
 'width': 5}
     50     imgs=self.cnmf_viewer.batch_item.cnmf.get_input_memmap(),
     51     params=cnmf_obj.params,
     52 )
     54 self.cnmf_viewer.update_visible_components()

File ~/Insync/kushalkolar@gmail.com/drive/repos/CaImAn/caiman/source_extraction/cnmf/estimates.py:1142, in Estimates.filter_components(self=, imgs= (2000, 60, 80) float32, params=CNMFParams:

data:

{'caiman_version': '1.9.10',...use_add': False,
 'use_bias': False,
 'width': 5}, new_dict={}, dview=None, select_mode='All')
   1139     self.evaluate_components(imgs, params, dview=dview)
   1140 else:
   1141     self.idx_components, self.idx_components_bad, self.cnn_preds = \
-> 1142     select_components_from_metrics(self.A, dims, params.get('init', 'gSig'),
        self.idx_components_bad =  (1,) int64
        self = 
        self.idx_components, self.idx_components_bad, self.cnn_preds = ( (9,) int64,  (1,) int64,  (10,) float32)
        self.idx_components =  (9,) int64
        self.cnn_preds =  (10,) float32
        dims = (60, 80)
        params = CNMFParams:

data:

{'caiman_version': '1.9.10',
 'decay_time': 1,
 'dims': b'NoneType',
 'dxy': (1, 1),
 'fnames': b'NoneType',
 'fr': 30,
 'last_commit': 'GITW-ae589c04ca7f8bead391b2dd14573c8cc9b3015e',
 'mmap_C': b'NoneType',
 'mmap_F': b'NoneType',
 'var_name_hdf5': 'mov'}

spatial_params:

{'block_size_spat': 5000,
 'dist': 3,
 'expandCore':  (5, 5) int64,
 'extract_cc': True,
 'maxthr': 0.1,
 'medw': b'NoneType',
 'method_exp': 'dilate',
 'method_ls': 'lasso_lars',
 'n_pixels_per_process': 208,
 'nb': 1,
 'normalize_yyt_one': True,
 'nrgthr': 0.9999,
 'num_blocks_per_run_spat': 20,
 'se': b'NoneType',
 'ss': b'NoneType',
 'thr_method': 'nrg',
 'update_background_components': True}

temporal_params:

{'ITER': 2,
 'bas_nonneg': False,
 'block_size_temp': 5000,
 'fudge_factor': 0.96,
 'lags': 5,
 'memory_efficient': False,
 'method_deconvolution': 'oasis',
 'nb': 1,
 'noise_method': 'mean',
 'noise_range':  (2,) float64,
 'num_blocks_per_run_temp': 20,
 'optimize_g': False,
 'p': 2,
 's_min': b'NoneType',
 'solvers':  (2,) |S4,
 'verbosity': False}

init_params:

{'K': 10,
 'SC_kernel': 'heat',
 'SC_nnn': 20,
 'SC_normalize': True,
 'SC_sigma': 1,
 'SC_thr': 0,
 'SC_use_NN': False,
 'alpha_snmf': 100,
 'center_psf': False,
 'gSig':  (2,) int64,
 'gSiz':  (2,) int64,
 'init_iter': 2,
 'kernel': b'NoneType',
 'lambda_gnmf': 1,
 'maxIter': 5,
 'max_iter_snmf': 500,
 'method_init': 'greedy_roi',
 'min_corr': 0.85,
 'min_pnr': 20,
 'nIter': 5,
 'nb': 1,
 'normalize_init': True,
 'options_local_NMF': b'NoneType',
 'perc_baseline_snmf': 20,
 'ring_size_factor': 1.5,
 'rolling_length': 100,
 'rolling_sum': True,
 'seed_method': 'auto',
 'sigma_smooth_snmf': (0.5, 0.5, 0.5),
 'ssub': 1,
 'ssub_B': 2,
 'tsub': 1}

preprocess_params:

{'check_nan': True,
 'compute_g': False,
 'include_noise': False,
 'lags': 5,
 'max_num_samples_fft': 3072,
 'n_pixels_per_process': 208,
 'noise_method': 'mean',
 'noise_range':  (2,) float64,
 'p': 2,
 'pixels': b'NoneType',
 'sn': b'NoneType'}

patch_params:

{'border_pix': 0,
 'del_duplicates': False,
 'in_memory': True,
 'low_rank_background': True,
 'memory_fact': 1,
 'n_processes': 23,
 'nb_patch': 1,
 'only_init': False,
 'p_patch': 0,
 'p_ssub': 2,
 'p_tsub': 2,
 'remove_very_bad_comps': False,
 'rf': b'NoneType',
 'skip_refinement': False,
 'stride': 30}

online:

{'N_samples_exceptionality': 30,
 'W_update_factor': 1,
 'batch_update_suff_stat': False,
 'dist_shape_update': False,
 'ds_factor': 1,
 'epochs': 1,
 'expected_comps': 500,
 'full_XXt': False,
 'init_batch': 2000,
 'init_method': 'bare',
 'iters_shape': 5,
 'max_comp_update_shape': inf,
 'max_num_added': 5,
 'max_shifts_online': 10,
 'min_SNR': 2.5,
 'min_num_trial': 5,
 'minibatch_shape': 100,
 'minibatch_suff_stat': 5,
 'motion_correct': True,
 'movie_name_online': 'online_movie.mp4',
 'n_refit': 0,
 'normalize': False,
 'num_times_comp_updated': inf,
 'opencv_codec': 'H264',
 'path_to_model': '/home/kushal/caiman_data/model/cnn_model_online.h5',
 'ring_CNN': False,
 'rval_thr': 0.8,
 'save_online_movie': False,
 'show_movie': False,
 'simultaneously': False,
 'sniper_mode': False,
 'stop_detection': False,
 'test_both': False,
 'thresh_CNN_noisy': 0.5,
 'thresh_fitness_delta': -50,
 'thresh_fitness_raw': -152.44944831836074,
 'thresh_overlap': 0.5,
 'update_freq': 200,
 'update_num_comps': True,
 'use_corr_img': False,
 'use_dense': True,
 'use_peak_max': True}

quality:

{'SNR_lowest': 0.0,
 'cnn_lowest': 0.0,
 'gSig_range': b'NoneType',
 'max_ecc': 3,
 'min_SNR': 0.5,
 'min_cnn_thr': 0.5,
 'rval_lowest': 0.2000000000000001,
 'rval_thr': 0.0,
 'use_cnn': True,
 'use_ecc': False}

merging:

{'do_merge': True,
 'max_merge_area': b'NoneType',
 'merge_parallel': False,
 'merge_thr': 0.8}

motion:

{'border_nan': 'copy',
 'gSig_filt': b'NoneType',
 'indices':  (2,) |S32,
 'is3D': False,
 'max_deviation_rigid': 3,
 'max_shifts': (6, 6),
 'min_mov': b'NoneType',
 'niter_rig': 1,
 'nonneg_movie': True,
 'num_frames_split': 80,
 'num_splits_to_process_els': b'NoneType',
 'num_splits_to_process_rig': b'NoneType',
 'overlaps': (32, 32),
 'pw_rigid': False,
 'shifts_opencv': True,
 'splits_els': 14,
 'splits_rig': 14,
 'strides': (96, 96),
 'upsample_factor_grid': 4,
 'use_cuda': False}

ring_CNN:

{'loss_fn': 'pct',
 'lr': 0.001,
 'lr_scheduler': b'NoneType',
 'max_epochs': 100,
 'n_channels': 2,
 'path_to_model': b'NoneType',
 'patience': 3,
 'pct': 0.01,
 'remove_activity': False,
 'reuse_model': False,
 'use_add': False,
 'use_bias': False,
 'width': 5}
        self.A = '
with 1979 stored elements in Compressed Sparse Column format>
        self.r_values =  (10,) float64
        self.SNR_comp =  (10,) float64
        opts = {'SNR_lowest': 0.0, 'cnn_lowest': 0.0, 'gSig_range': b'NoneType', 'min_SNR': 0.5, 'min_cnn_thr': 0.5, 'rval_lowest': 0.2000000000000001, 'rval_thr': 0.0, 'use_cnn': True, 'use_ecc': False, 'max_ecc': 3}
        opts['rval_thr'] = 0.0
        opts['rval_lowest'] = 0.2000000000000001
        opts['min_SNR'] = 0.5
        opts['SNR_lowest'] = 0.0
        opts['min_cnn_thr'] = 0.5
        opts['cnn_lowest'] = 0.0
        opts['use_cnn'] = True
        opts['gSig_range'] = b'NoneType'
   1143                                    self.r_values, self.SNR_comp,
   1144                                    predictions=self.cnn_preds,
   1145                                    r_values_min=opts['rval_thr'],
   1146                                    r_values_lowest=opts['rval_lowest'],
   1147                                    min_SNR=opts['min_SNR'],
   1148                                    min_SNR_reject=opts['SNR_lowest'],
   1149                                    thresh_cnn_min=opts['min_cnn_thr'],
   1150                                    thresh_cnn_lowest=opts['cnn_lowest'],
   1151                                    use_cnn=opts['use_cnn'],
   1152                                    gSig_range=opts['gSig_range'])
   1153     if opts['use_ecc']:
   1154         idx_ecc = np.where(self.ecc  opts['max_ecc'])[0]

File ~/Insync/kushalkolar@gmail.com/drive/repos/CaImAn/caiman/components_evaluation.py:673, in select_components_from_metrics(A=, dims=(60, 80), gSig= (2,) int64, r_values= (10,) float64, comp_SNR= (10,) float64, r_values_min=0.0, r_values_lowest=0.2000000000000001, min_SNR=0.5, min_SNR_reject=0.0, thresh_cnn_min=0.5, thresh_cnn_lowest=0.0, use_cnn=True, gSig_range=b'NoneType', neuron_class=1, predictions= (10,) float64, **kwargs={})
    671     predictions = np.zeros(len(r_values))
    672     for size_range in gSig_range:
--> 673         predictions = np.maximum(predictions, evaluate_components_CNN(A, dims, size_range)[0][:, neuron_class])
        predictions =  (10,) float64
        size_range = 78
        np = 
        A = '
with 1979 stored elements in Compressed Sparse Column format>
        dims = (60, 80)
        np.maximum = 
        neuron_class = 1
    675 idx_components_cnn = np.where(predictions >= thresh_cnn_min)[0]
    676 bad_comps = np.where((r_values = r_values_lowest) | (comp_SNR = min_SNR_reject) |
    677                      (predictions = thresh_cnn_lowest))[0]

File ~/Insync/kushalkolar@gmail.com/drive/repos/CaImAn/caiman/components_evaluation.py:321, in evaluate_components_CNN(A=, dims=(60, 80), gSig=78, model_name='/home/kushal/caiman_data/model/cnn_model', patch_size=50, loaded_model=, isGPU=False)
    317         loaded_model = load_graph(model_file)
    319     logging.debug("Loaded model from disk")
--> 321 half_crop = np.minimum(gSig[0] * 4 + 1, patch_size), np.minimum(gSig[1] * 4 + 1, patch_size)
        np.minimum = 
        patch_size = 50
        np = 
        gSig = 78
    322 dims = np.array(dims)
    323 coms = [scipy.ndimage.center_of_mass(mm.toarray().reshape(dims, order='F')) for mm in A.tocsc().T]

TypeError: 'int' object is not subscriptable

[BUG] Abort button needs to be functional

The Abort button needs to be made functional and the Start and Start at item buttons needs to be disabled once a batch is running. It is currently possible to flood the system with processes by clicking the Start button repeatedly.

Last things for param GUIs

  • Input movie selection by using QComboBox to select input movie file corresponding to a layer in the viewer
  • framerate QDoubleSpinBox

[BUG] strange QProcess launching

Sometimes QProcess does not launch with the first click of Start but only with the second click, weird maybe a napari thing. Isolate by launching purely from backend pandas exts.

docs to do

  • Written tutorial
    • mcorr -> cnmf(e) -> eval
    • Start off with mesmerize-core in jupyter for batch creation, napari just for viz as an option. Params GUIs also possible but jupyter is recommended
  • Video tutorial, same stuff as written tut

[BUG] Mcorr memmaps get overwritten

If the same input file is used for mcorr with multiple param variants, the output memmap is overwritten. Need to figure out if it's possible to specify the output filename for mcorr memmaps in caiman.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.