porteralab / EZcalcium

Calcium Data Extraction and Analysis
GNU General Public License v3.0
43 stars 7 forks source link

Error at the time of the analysis of video files #21

Closed ggmirandac closed 1 year ago

ggmirandac commented 2 years ago

At the momento of the analysis of a Calcium signaling expression video in the format .avi there is this error message:

Unable to perform assignment because the size of the left side is 512-by-512 and the size of the right side is 512-by-512-by-3.

Error in read_file (line 63) imData(:,:,i-sframe+1) = Y1;

Error in ez_roi_detect/RunROIDetectionButtonPushed (line 337) Y = read_file(filename);

Error in appdesigner.internal.service.AppManagementService/executeCallback (line 171) callback(appOrUserComponent, event);

Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62) newCallback = @(source, event)executeCallback(ams, ...

Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback Error while evaluating Button PrivateButtonPushedFcn.

which doesn't allow me to perform the analysis. I tried everything, I tried to convert the video to TIFF format and to convert every image in the frame to index image format and nothing worked.

Is worth nothing that I'm currently working in Mac M1 and the version of Matlab is R2022b

bodayw commented 2 years ago

Hi,

Possibly a duplicate of #7.

Try the solution I suggested there and see if it works.

ggmirandac commented 2 years ago

Do you know any way to convert .avi files that store RGB files to grayscale, because the matlab function rgb2gray only changes the color of the pixel and doesn't change the amount of information per pixel. Or any way to decrease the amount of information per pixel in order to generate the change in order to change the matrix from 512x512x3 to 512x512.

bodayw commented 1 year ago

Assuming you only have one channel recorded (instead of GFP + RFP etc.), you might have duplicated data stored in all three (red, green and blue) channels, such that the image would appear to be in grayscale. In this case you can just take the data in one of the channels and discard the other two, as they're identical.

Or, you might have actual data in only one of the three channels, say, red, such that the image would appear to be in "red-scale", while the other two are filled with zeroes. In this case you would just take the channel that has real data.

The idea is simple and there are many software can do this - I guess ImageJ should be capable. You can also load and process the AVI file in MATLAB.

ggmirandac commented 1 year ago

Thanks for the insight, now I review it and solve this problem, but now I stumbled with another problem:

Unrecognized function or variable 'find_unsaturatedPixels'.

Error in preprocess_data (line 70) P.pixels = find_unsaturatedPixels(Y); % pixels that do not exhibit saturation

Error in ez_roi_detect/RunROIDetectionButtonPushed (line 365) [P, Y] = preprocess_data(Y, p, options);

Error in appdesigner.internal.service.AppManagementService/executeCallback (line 171) callback(appOrUserComponent, event);

Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62) newCallback = @(source, event)executeCallback(ams, ...

Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback Error while evaluating Button PrivateButtonPushedFcn.

The input is a .tif video that contains calcium data, and I am working on a Mac M1.

bodayw commented 1 year ago

Unrecognized function or variable 'find_unsaturatedPixels'.

20

ggmirandac commented 1 year ago

Thanks, that worked just fine, good tool by the way, just what I needed

ggmirandac commented 1 year ago

Also, running some iterations of the pipeline I stumble sometimes with this problem:

Unrecognized function or variable 'P_merged'.

Error in merge_components (line 177) P.b(nr - length(neur_id) + (1:nm)) = P_merged.b;

Error in ez_roi_detect/RunROIDetectionButtonPushed (line 423) [Am, Cm, ~, ~, Pm, ~] = merge_components(Yr, A, b, C, f, P, S, options);

Error in appdesigner.internal.service.AppManagementService/executeCallback (line 171) callback(appOrUserComponent, event);

Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62) newCallback = @(source, event)executeCallback(ams, ...

Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback Error while evaluating Button PrivateButtonPushedFcn.

The weird thing is that it appears sometimes.

bodayw commented 1 year ago

The weird thing is that it appears sometimes.

Does it always happen with certain files, but not others? Or does it happen randomly, such that it only happens sometimes, but not always even with the same file?

If it always happen with some of your files, can you detail on how to reproduce the issue, if possible? Maybe also upload a short clip of one of those files somewhere if that's convenient to you.

ggmirandac commented 1 year ago

I don't really know how to replicate it, it doesn't appears anymore. It was weird.

ggmirandac commented 1 year ago

One last question, how do I read the final output in order to get the graphs that the gui showed but after the refinement. With this I mean how do I read the .mat file in order to get the same output as the one given by your gui ones it was given by the refinement algorithm.

bodayw commented 1 year ago

how do I read the .mat file in order to get the same output as the one given by your gui ones

Just load the .mat file into MATLAB workspace. Variable names are mostly self-explanatory.

The three activity variables are F_raw, F_inferred and S_deconv. You will get additional ones with the _refined suffix if you finished the Refinement process. They are 2D matrices that each row corresponds to a trace of a single ROI, e.g. if you have 20 ROIs and 500 frames in your movie, the dimensions would be 20x500.

bodayw commented 1 year ago

Unrecognized function or variable 'P_merged'.

Likely the same issue mentioned in #22. Should be fixed now in v3.0.2.