Closed davegrays closed 5 years ago
@davegrays My guess is that the patch that throws the error might have not components. What is the value of rf
that you're using, and do you have large areas in your FOV with no activity?
@epnev Yes, there are large areas with no activity because the tissue is enclosed by the bounding box. Increasing the rf to 60 still results in errors like these. The attached image shows the first (120x120) patch that produces this error. How can we tell caiman to ignore empty patches like these? Is it really necessary to fail when NaNs are produced, or can it just move on to the next patch?
@davegrays Thanks. I thought we had dealt with this is the past, but apparently not. I'll take a look tomorrow. In the meantime, you can try using a larger rf
value to make sure more signal is captured within each patch.
@davegrays I actually could not reproduce your error in a file where I intentionally filled a patch which random noise (or just zeros). The pipeline detects no neurons and leaves the results empty. So it's not exactly clear what's happening.
I created a new branch issue_513
with the changes shown here: https://github.com/flatironinstitute/CaImAn/commit/5f53fc7b53ccbdca93d84ab60b4e4f9a56403e64
Can you tell me if you can process your file with no errors by using this branch? Thanks
@epnev Your fix got us past that error, but we hit another NaN error during NMF on the background component. Proposed a fix here: #517 - is this a reasonable way to get around this problem? Thanks!
I merged everything into dev. I'm closing this issue but feel free to reopen if you still see the same problem.
Ubuntu 18, python 3.6.7, tested on Jupyter and command line
ValueError running cmnf.fit() on calcium videos with no nans, infs, negative values, or pixels with temporal stdev = 0
2019-04-18 19:09:38,337 [114] INFO root: Memory mapping 2019-04-18 19:09:38,339 [114] INFO root: Updating Spatial Components using lasso lars 2019-04-18 19:09:38,979 [114] INFO root: thresholding components 2019-04-18 19:09:38,986 [114] INFO root: Computing residuals 2019-04-18 19:09:38,987 [114] INFO root: Updating done in 0s 2019-04-18 19:09:38,988 [114] INFO root: Removing created tempfiles 2019-04-18 19:09:38,990 [114] INFO root: update temporal ... 2019-04-18 19:09:38,991 [114] INFO root: deconvolution ... 2019-04-18 19:09:38,993 [114] INFO root: Generating residuals 2019-04-18 19:09:38,999 [114] INFO root: entering the deconvolution 2019-04-18 19:09:39,001 [114] INFO root: 1 out of total 4 temporal components updated 2019-04-18 19:09:39,003 [114] INFO root: 3 out of total 4 temporal components updated 2019-04-18 19:09:39,006 [114] INFO root: 4 out of total 4 temporal components updated 2019-04-18 19:09:39,008 [114] INFO root: 1 out of total 4 temporal components updated 2019-04-18 19:09:39,011 [114] INFO root: 3 out of total 4 temporal components updated 2019-04-18 19:09:39,012 [114] INFO root: 4 out of total 4 temporal components updated 2019-04-18 19:09:39,014 [114] INFO root: stopping: overall temporal component not changing significantly 2019-04-18 19:09:39,016 [114] INFO root: refinement... 2019-04-18 19:09:39,017 [114] INFO root: merging components ... 2019-04-18 19:09:39,019 [114] WARNING py.warnings: /caiman/caiman/source_extraction/cnmf/merging.py:142: SparseEfficiencyWarning: Changing the sparsity structure of a csc_matrix is expensive. lil_matrix is more efficient. C_corr[ii, overlap_indeces] = corr_values
2019-04-18 19:09:39,046 [114] INFO root: Merging components [0 1 2] 2019-04-18 19:09:39,059 [114] INFO root: Updating spatial ... 2019-04-18 19:09:39,060 [114] INFO root: Computing support of spatial components 2019-04-18 19:09:39,065 [114] WARNING py.warnings: /caiman/caiman/source_extraction/cnmf/spatial.py:903: SparseEfficiencyWarning: Changing the sparsity structure of a csc_matrix is expensive. lil_matrix is more efficient. dist_indicator[:, i] = scipy.sparse.coo_matrix(np.squeeze(np.reshape(A_temp, (d, 1)))[:,None] > 0)
2019-04-18 19:09:39,099 [114] INFO root: Memory mapping 2019-04-18 19:09:39,101 [114] INFO root: Updating Spatial Components using lasso lars 2019-04-18 19:09:39,711 [114] INFO root: thresholding components 2019-04-18 19:09:39,716 [114] INFO root: Computing residuals 2019-04-18 19:09:39,717 [114] INFO root: Updating done in 0s 2019-04-18 19:09:39,718 [114] INFO root: Removing created tempfiles 2019-04-18 19:09:39,721 [114] INFO root: update temporal ... 2019-04-18 19:09:39,724 [114] INFO root: Generating residuals 2019-04-18 19:09:39,730 [114] INFO root: entering the deconvolution 2019-04-18 19:09:39,733 [114] INFO root: 1 out of total 2 temporal components updated 2019-04-18 19:09:39,736 [114] INFO root: 2 out of total 2 temporal components updated 2019-04-18 19:09:39,740 [114] INFO root: 1 out of total 2 temporal components updated 2019-04-18 19:09:39,743 [114] INFO root: 2 out of total 2 temporal components updated 2019-04-18 19:09:39,745 [114] INFO root: stopping: overall temporal component not changing significantly 2019-04-18 19:09:39,753 [114] WARNING py.warnings: /usr/local/lib/python3.6/dist-packages/numpy/core/memmap.py:331: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use
arr[tuple(seq)]
instead ofarr[seq]
. In the future this will be interpreted as an array index,arr[np.array(seq)]
, which will result either in an error or a different result. res = super(memmap, self).getitem(index)2019-04-18 19:09:39,778 [114] WARNING root: Parallel processing in a single patch is not available for loaded in memory or sliced data. 2019-04-18 19:09:39,802 [114] INFO root: (300, 31, 31) 2019-04-18 19:09:39,803 [114] INFO root: Using 1 processes 2019-04-18 19:09:39,804 [114] INFO root: using 225 pixels per process 2019-04-18 19:09:39,805 [114] INFO root: using 5000 block_size_spat 2019-04-18 19:09:39,806 [114] INFO root: using 5000 block_size_temp 2019-04-18 19:09:39,807 [114] INFO root: preprocessing ... 2019-04-18 19:09:39,809 [114] INFO root: Checking for missing data entries (NaN) 2019-04-18 19:09:39,855 [114] INFO root: initializing ... 2019-04-18 19:09:39,856 [114] INFO root: Variance Normalization 2019-04-18 19:09:39,858 [114] INFO root: Roi Initialization... 2019-04-18 19:09:39,859 [114] INFO root: Greedy initialization of spatial and temporal components using spatial Gaussian filtering 2019-04-18 19:09:39,877 [114] INFO root: Using rolling sum for initialization (RollingGreedyROI) 2019-04-18 19:09:39,993 [114] INFO root: Refining Components using HALS NMF iterations 2019-04-18 19:09:39,998 [114] WARNING py.warnings: /caiman/caiman/source_extraction/cnmf/initialization.py:864: RuntimeWarning: invalid value encountered in true_divide V[m, m]), 0, np.inf)
2019-04-18 19:09:40,054 [114] INFO root: update spatial ... 2019-04-18 19:09:40,056 [114] INFO root: Computing support of spatial components 2019-04-18 19:09:40,060 [114] WARNING py.warnings: /caiman/caiman/source_extraction/cnmf/spatial.py:903: RuntimeWarning: invalid value encountered in greater dist_indicator[:, i] = scipy.sparse.coo_matrix(np.squeeze(np.reshape(A_temp, (d, 1)))[:,None] > 0)
2019-04-18 19:09:40,100 [114] INFO root: Memory mapping 2019-04-18 19:09:40,102 [114] INFO root: Updating Spatial Components using lasso lars 2019-04-18 19:09:40,112 [114] INFO root: thresholding components 2019-04-18 19:09:40,119 [114] INFO root: eliminating 5 empty spatial components 2019-04-18 19:09:40,121 [114] INFO root: Computing residuals 2019-04-18 19:09:40,123 [114] INFO root: Updating done in 0s 2019-04-18 19:09:40,124 [114] INFO root: Removing created tempfiles 2019-04-18 19:09:40,126 [114] INFO root: update temporal ... 2019-04-18 19:09:40,127 [114] INFO root: deconvolution ... 2019-04-18 19:09:40,129 [114] INFO root: Generating residuals 2019-04-18 19:09:40,134 [114] INFO root: entering the deconvolution
ValueError Traceback (most recent call last)