JinghaoLu / MIN1PIPE

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

Operands to the logical AND (&&) and OR (||) operators must be convertible to logical scalar values #64

Open aozgur360 opened 2 years ago

aozgur360 commented 2 years ago

Hi, I am trying to run the latest version of Min1pipe but am getting this error early on. Do you have any suggestions? Thank you! min1pipe_error

JinghaoLu commented 2 years ago

Hi, I am not sure what the real issue is. I would suggest you to set a breakpoint at line 53 in frame_reg.m and see if imaxn or dthres is problematic.

bscoventry commented 2 years ago

Hi all, This seems to be an error arising in the latest version of Matlab. MiniP1PE on demo data was working up until I upgraded to Matlab Version 2022a at which point this error arose. I'm attempting a fix and will report back.

bscoventry commented 2 years ago

So the problem is in fuzzy.internal.utility.isFiniteNonemptyReal. Expected behavior is for all is all(isfinite(x)) to collapse to a single logical value, but because x is an mxn frame, all(isfinite(x)) returns a column array if all rows of a column are finite, resulting in the error. All(all(isfinite(x)) fixes the problem, though I haven't checked edge cases. However, matlab restricts making changes to the fuzzy logic toolbox, so this might need to be fixed at the level of MiniP1PE.

JinghaoLu commented 2 years ago

@aozgur360 @bscoventry To be compatible with the new matlab, I replace the calling of sigmf function with direct computing the sigmoid function at the same line in demons_prep.m, so there shouldn't be any problem.

bscoventry commented 2 years ago

@aozgur360 @bscoventry To be compatible with the new matlab, I replace the calling of sigmf function with direct computing the sigmoid function at the same line in demons_prep.m, so there shouldn't be any problem.

Thank you this fixed it for me!

aozgur360 commented 2 years ago

Thank you! This seemed to fix this issue, but now later on I run into another problem of "index exceeds matrix dimensions". I don't think it's related? But I'm also unsure how to fix this min1pipe_error2 :

JinghaoLu commented 2 years ago

@aozgur360 Do you know the line # of the error message? I don't see it in the message.

aozgur360 commented 2 years ago

Sorry, maybe the image I attached isn't showing up. The error shows up as line 15: "Error using min1pipe, Index exceeds matrix dimensions. Error in demo_min1pipe_AO (line 15), [fname, frawname, fregname] = min1pipe (Fsi, Fsi_new, [], [], ismc, flag);

bscoventry commented 2 years ago

@JinghaoLu @aozgur360 if I may chime in here, I also encountered this exact error. Noteably, I found a version of Matlab 2021b and the code does not have this error on the exact same dataset, exact same properties.

I traced the index exceeds dimensions to line 206, specifically tmp = m.reg(1: pixh, 1: pixw, idbatch(j): idbatch(j + 1) - 1);

Furthermore, it seems the Gaussian filter at line 19 in merge_roi "roi_gauss(reshape(full(roi), d1, d2, nseed));" also throws this error.

JinghaoLu commented 2 years ago

@bscoventry @aozgur360 The reason I asked this was because in the error message there wasn't a specific line of code in min1pipe.m. But based on @bscoventry and one of my previous colleague who is actively using MIN1PIPE as well, it seems that after I upgraded to the automatic parameter selection, I forgot to update the pixh and pixw, which seems the reason why you have this error on line 206. I have already corrected this but not tested it yet. You guys can try it out right now, or wait for my update when my colleague test it out. Will keep you updated.

JinghaoLu commented 2 years ago

@bscoventry @aozgur360 So it seems the update is good for the first run, but if you want to rerun it without overwriting the *_frame_all.mat, there is something missing. Therefore I made some further update.

aozgur360 commented 2 years ago

@JinghaoLu Thank you so much! It works now for me

JinghaoLu commented 2 years ago

@aozgur360 Hold on to the latest version. There is some imperfection with the implementation so I am working on it. You can stick to the stable manual param selection version for now. Expect an update by the end of tomorrow. Thanks!