cortex-lab / Suite2P

Tools for processing 2P recordings
Other
122 stars 66 forks source link

error loading F*.mat files into GUI #100

Closed mich11 closed 7 years ago

mich11 commented 7 years ago

Hi,

I'm getting an error when trying to load F.mat files generated by Suite2P into the GUI. When I select an F.mat file in the GUI, the windows remain white and do not show my data or the Suite2P-generated ROIs. After ~30 seconds, if I click inside the blank Selected ROIs window on the GUI, I get the error:

Struct contents reference from a non-struct array object.

Error in new_main>figure1_WindowButtonDownFcn (line 377) if x>=1 && y>=1 && x<=h.dat.cl.Lx && y<=h.dat.cl.Ly && h.dat.res.iclust(y,x)>0

Error in gui_mainfcn (line 95) feval(varargin{:});

Error in new_main (line 17) gui_mainfcn(gui_State, varargin{:});

Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)new_main('figure1_WindowButtonDownFcn',hObject,eventdata,guidata(hObject)) Error while evaluating Figure WindowButtonDownFcn

If I load the F*.mat file directly into matlab, I see the variables I'm supposed to (Fcell, stat, etc), and I can plot signals from individual ROIs, so I think that the file is being built correctly but just can't be loaded by the GUI for some reason. I've gotten the same error with a couple of different input TIFFs (both 16-bit) -- 2-photon data collected with Scanimage 5.2 and epifluorescence data collected with HCImage. Is there something I might be doing incorrectly that prevents the GUI from loading my data?

Thanks, Michelle

johannasigl commented 7 years ago

Which version of Matlab are you using? I have the same problem in 2014 but not 2016...

mich11 commented 7 years ago

I've had the same problem with 2015b on a PC and 2016b on a Mac.

carsen-stringer commented 7 years ago

Have you resaved the file?

The output of suite2P will be a F.mat with stat, ops, ... . If you save the file after processing in the GUI (or in some other way), the F.mat file will be dat.stat, dat.ops, ... . When you load your F file is there a dat struct in it?

mich11 commented 7 years ago

Thanks very much for helping me troubleshoot this.

I haven't resaved the file. If I load the F*.mat file into matlab, I get the variables Fcell, FcellNeu, ops, sp, and stat. I don't see a dat struct.

carsen-stringer commented 7 years ago

That's weird, it seems like for some reason the initialization isn't running. can you check that the initialization is working? comment out "try", "catch" and "end" on lines 84,87 and 88, and see if you now get an error when you load your file

mich11 commented 7 years ago

I commented out the try/catch/end statement and still got the same error.

Looking before that with the debugger and commenting out the try/catch/end on lines 55, 68, and 69, I found an error inside the main load function (pushbutton17_Callback) on like 62. set(h.figure1,'Name',filename1) returns "Struct contents reference from a non-struct array object", which i think is triggered by h.figure1. When the try/catch is in place, this error makes the function skip the load statement, so the file is never loaded.

Could it be a version compatibility issue, as suggested by johannasiglgloeckner? I've tried a couple of recent versions of matlab (2015b, 2016b), but maybe there's a version that runs Suite2P best?

carsen-stringer commented 7 years ago

So that line is just setting the title of the GUI window. That's weird that it doesn't work though, we have other matlab 2016 users. You could try upgrading, but it could unfortunately be a Mac specific thing? See if everything works with just that line commented out.

mich11 commented 7 years ago

When I comment out that line, it works until it runs into the next set(h., , ) command, which is set(h.text50,'String', [filename1 '.mat']) on line 4 of the classROI function. Commenting out this line allows the program to run until the next set(h., , ). It looks like h should be a structure that both references figure properties and stores data (h.dat). When I run new_main, it generates the h struct with fields like dat, prior, and statLabels, but it doesn't refer to a figure in any way, so set(h.*...) returns an error.

I upgraded to 2016b on a PC and still get the same error(s). Could it be that I need something else installed to properly run Matlab GUIs? I'm just guessing that it's a dependency issue because most others don't appear to have this problem.

Thanks again for working through this with me.

carsen-stringer commented 7 years ago

Crap, I see, you're running new_main from the matlab command line? Just running new_main correct?

Also, is the path to new_main.fig in your path? This is where all the figure handle positions and everything are stored. That's the only thing I can think of being an issue...

mich11 commented 7 years ago

Problem solved -- I was opening new_main.fig from the file explorer instead of calling new_main at the command line. new_main.fig is def on the path, so once I called from the command line, everything loads as expected.

What a silly mistake! Thanks so much for helping me figure it out.

carsen-stringer commented 7 years ago

Yay! no worries glad it's working :)