nel-lab / mesmerize-napari

Mesmerize plugin for the napari viewer
Apache License 2.0
6 stars 0 forks source link

Eval GUI is broken #41

Closed kushalkolar closed 2 years ago

kushalkolar commented 2 years ago

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
ArjunPutcha commented 2 years ago

It's working for me on my end with the Demo Movie and k53 movies. Can you tell me how you got this error, I'll try to replicate. Was this before or after the mesmerize-core branch consolidations

ArjunPutcha commented 2 years ago

@YichengZou626 can you also test to see if you can replicate or find more errors with eval gui?

kushalkolar commented 2 years ago

It's working for me on my end with the Demo Movie and k53 movies. Can you tell me how you got this error, I'll try to replicate. Was this before or after the mesmerize-core branch consolidations

there is currently no interface for eval in mesmerize-core, the GUI interfaces directly with caiman

YichengZou626 commented 2 years ago

it works for me!