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 Using `entropy>ParseInputs` #37

Open marcoistasy opened 4 years ago

marcoistasy commented 4 years ago

Hello,

I am running the MIN1Pipeline as coded in the demo_min1pipe.m and am running into this error:

Error using entropy>ParseInputs (line 60)
Expected input number 1, I, to be nonempty.

Error in entropy (line 38)
I = ParseInputs(varargin{:});

Error in cen_gen (line 31)
    entref = entropy(Ymax(round(ar(2)) + 1: round(ar(2)) + ar(4) - 1, round(ar(1)) + 1: round(ar(1)) + ar(3) - 1));

Error in lk_ref_track (line 18)
        [p0, winsize] = cen_gen(cat(3, imref, imcur));

Error in lk_logdemons_unit (line 60)
        [PNt, imgt, sco] = lk_ref_track(imcur, imref, maskc);

Error in nonstable_section (line 99)
            parfor ii = idbatch(i) + 1: idbatch(i + 1)

Error in frame_reg (line 101)
        m = nonstable_section(m, sttn, stpn, se, pixs, scl, sigma_x, sigma_f, sigma_d, maskc);

Error in min1pipe (line 108)
                    [m, corr_score, raw_score, scl] = frame_reg(m, imaxy, se, Fsi_new, pixs, scl, sigma_x, sigma_f, sigma_d);

Below are my parameters:

Fsi = 20;
Fsi_new = 20; %%% no temporal downsampling %%%
spatialr = 1; %%% no spatial downsampling %%%
se = 5; %%% structure element for background removal %%%
ismc = true; %%% run movement correction %%%
flag = 1; %%% use auto seeds selection; 2 if manual %%%
% isvis = true; %%% do visualize %%%
ifpost = false; %%% set true if want to see post-process %%%

I'm not sure what this issue means and how I might fix it. Please advise.

JinghaoLu commented 4 years ago

The direct cause would be that the input image to entropy is empty. There might be defective pixels of extreme high intensity that dominate the ROI for entropy calculation so that the ROI window is of size 1. I suggest that you check if this is the case, for some/all frames of your video. For example, you can plot a frame from _frame_all.mat or _reg.mat and if you see almost a blue figure, or most of the neurons are of blue-ish color, then this is the case.

marcoistasy commented 4 years ago

@JinghaoLu thank you for this! how would I fix that? Would I need to create a larger window size?

marcoistasy commented 4 years ago

@JinghaoLu thank you for this! how would I fix that? Would I need to create a larger window size?

also, you are correct - all the frames are blue.

JinghaoLu commented 4 years ago

@marcoistasy So it means at some pixel(s), you have a constantly high value. Simple solution would be to find that pixel(s) and set it with its neighbor's value. You probably need to do it in every frame, and once you see enough variance in the figure, you can rerun the program without overwriting the preprocessed data.

marcoistasy commented 4 years ago

@JinghaoLu hmm sorry I still don't quite understand this. Would I be able to share some of the frames with you and you can let me know how I might proceed? I have also tried to change the downsampling factors and will see how it results.

JinghaoLu commented 4 years ago

@marcoistasy Sure please send the file or link to min1pipe2018@gmail.com. Thanks!

JinghaoLu commented 4 years ago

Ok so the problem is the right and bottom pixel strips in the FOV are most likely software created artifacts. Did you motion correct the video using mosaic before feeding it into MIN1PIPE? If so please crop the effective FOV after doing that. Or you can feed the raw video into MIN1PIPE and use the onboard motion correction module.

marcoistasy commented 4 years ago

hmmm no, I didn't motion correct the video. I ran into this issue while feeding the raw video into MIN1PIPE. Is there an alternative way to running the motion correction module other than running demo_min1pipe.m? Because that's what I have been running.

JinghaoLu commented 4 years ago

Well that's not important. The only thing you need to do is to crop the FOV, as a separate pre-preprocessing step. Usually the video will not be like this, which contains too much weird artifacts.

marcoistasy commented 4 years ago

makes sense! thank you!