JinghaoLu / MIN1PIPE

A MINiscope 1-photon-based Calcium Imaging Signal Extraction PIPEline.
GNU General Public License v3.0
56 stars 25 forks source link

Error in pix_select: exceeds dimension #55

Open martinjendryka opened 3 years ago

martinjendryka commented 3 years ago

Im getting the same error message (see below) for two of my sessions and I dont know how to fix it. in pix_select (line 254)
sa = rtmp(rg(1, 1): rg(1, 2), rg(2, 1): rg(2, 2), 1: nf); rtmp has dimension 480, 725, 8975, rg(2, 2) = 726, so it throws the exceeds array bounds error

Previous processing with an earlier version of min1pipe_hpc did not cause any problems. Also for all my other sessions the latest min1pipe version worked perfectly fine. When I run the script for a single video from the same session, I also dont get any error msgs. There is enough disk space and I have all necessary toolboxes. using matlab 2020 Fsi = 20; Fsi_new = 5; spatialr = 1; se = 5; ismc = true; flag = 1;

Error msg: Index in position 2 exceeds array bounds (must not exceed 358).

Error in pix_select (line 254) sa = rtmp(rg(1, 1): rg(1, 2), rg(2, 1): rg(2, 2), 1: nf);

Error in iter_seeds_select (line 25) [roi, sig, bg, bgf, seeds, datasmth0, cutoff0, pkcutoff0] = pix_select(m_tmp, mask, sz, Fsi_new, sigthres, corrthres);

Error in min1pipe (line 142) [sigrf, roirf, seedsupdt, bgrf, bgfrf, datasmthf1, cutofff1, pkcutofff1] = iter_seeds_select(m, mask, Params, P, options, flag);

Error in demo_min1pipe (line 13) min1pipe(Fsi, Fsi_new, spatialr, se, ismc, flag);

JinghaoLu commented 3 years ago

It might be because of the small SNR that the algorithm could not correctly get the FOV in your video. You can send the session to the email min1pipe2018@gmail.com if it is not too large so that I can take a look, or just a file of the session (but I cannot guarantee that I can replicate the problem) if the whole session share is impossible.

mgraupe commented 3 years ago

Hello, I am getting the same error message for some (but not all) of my recordings. So min1pipe code runs fine but aborts when analyzing specific experiments. My configuration is the same as @martinjendryka . I am also running Matlab2020b.
Did you figure out on how to avoid error?

Thanks, Michael

martinjendryka commented 3 years ago

Hi Michael, Jinghao suggested me changing the spatial downsampling factor 'spatialr'. You can try out spatialr = 0.25. This will downsample the video by the factor 4. This worked at least for one of my sessions that could not be preprocessed with "spatialr = 1" previously.

According to Jinghao, the issue arises from the mismatch between the spatial resolution and the variable "se = 5". "se" should be selected based on the number of pixels along the radius of a typical neuron in your FOV and it is preferably 5~9.

Hope it helps! Martin

mgraupe commented 3 years ago

Dear Martin,

Thank you for the hint. Indeed, decreasing spatialr did the trick. The analysis is running without errors now.

Can se and spatialr be changed interchangeably? In other words, can I either decrease spatialr or increase se? Does it impact analysis pipeline differently?

Thanks again.

Best regards, Michael

On Mon, Mar 1, 2021 at 7:48 PM Martin Jendryka notifications@github.com wrote:

Hi Michael, Jinghao suggested me changing the spatial downsampling factor 'spatialr'. You can try out spatialr = 0.25. This will downsample the video by the factor 4. This worked at least for one of my sessions that could not be preprocessed with "spatialr = 1" previously.

According to Jinghao, the issue arises from the mismatch between the spatial resolution and the variable "se = 5". "se" should be selected based on the number of pixels along the radius of a typical neuron in your FOV and it is preferably 5~9.

Hope it helps! Martin

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JinghaoLu/MIN1PIPE/issues/55#issuecomment-788182757, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACDFLU6L54MMS6UHUQ5SSLLTBPOQZANCNFSM4XXA5GCA .

-- Michael Graupner (PhD) Université de Paris, CNRS, SPPIN, 75006 Paris, France https://www.biomedicale.parisdescartes.fr/~mgraupe/ http://www.biomedicale.parisdescartes.fr/~mgraupe/

JinghaoLu commented 3 years ago

@mgraupe spatialr = 0.5 + se = 5 is equivalent to spatialr = 1 + se = 10 in theory, but can be different due to the implementation details and simply the structure element shape for the morphological operations. However, whenever possible, it is much more beneficial to use the previous parameter set, which 1. decrease the impact of some dirts in the FOV, and most importantly 2. decrease processing time (especially motion correction) drastically.