JinghaoLu / MIN1PIPE

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

Trouble with V4 miniscope video #75

Open alexisfaure376 opened 1 week ago

alexisfaure376 commented 1 week ago

Dera Jinghao,

I first want to thank you for sharing your powerfull pipeline. I have already use it on V2 miniscope video, but on V4 it doesn't work. I use the newest Min1pipe 2023 and I get an error message like that:

"Begin data cat Error using zeros CLASSNAME input must be a valid numeric or logical class name.

Error in data_cat (line 170) frame_allt = zeros(pixh, pixw, idbatch(ib + 1) - idbatch(ib), dtype);

Error in min1pipe (line 83) [m, filename_raw, imaxn, imeanf, pixh, pixw, nf, imx1, imn1] = data_cat(path_name, file_base{i}, file_fmt{i}, Fsi, Fsi_new, spatialr);"

I suppose that video format is an issue, but I could not understand Hope you will have an idea Alexis

JinghaoLu commented 1 week ago

Hi Alexis, I think you might be right since the error message does not seem the reason and it could be due to the video format that creates wrong pixh or pixw. What is the video format, avi? It is supposed to be uncompressed avi that is compatible with MIN1PIPE.

alexisfaure376 commented 1 week ago

Dear Jinghao, my files are .avi, but with a FFV1 codec. Reading various posts, it seems that converting videos to gray, with an RGBP codec might work. I was previously using Min1PIPE with miniscope V2 videos which were with an RGBP codec, but the new miniscope V4 videos are with an FFV1 codec. However, I'm not very good at python, and I'm having trouble handling this change using FFmpeg in Anaconda3. Do you have any ideas? Thank you in advance.

JinghaoLu commented 1 week ago

I think you don't need to use python for FFmpeg. You can directly use terminal or command prompt in your OS to do that. Here is a simple command to start with: ffmpeg -i input_ffv1.avi -c:v rawvideo -pix_fmt yuv420p output_uncompressed.avi. Or alternatively, if you still have the original file from miniscope, you can use their software to save uncompressed avi.

alexisfaure77 commented 5 days ago

Thank you for your response, I have been able to made it working with a RGPB conversion (Codec : Palettized RGB with palette element R:G:B (RGBP)), but I loose resolution and I guess that I will loose neurons. And when I convert using your command, unfortunatly it does not work (error below). Do you know an uncompress codec that would work? there is still this error: Error using reshape Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.

Error in data_cat (line 215) frame = flipud(reshape(d_raw(stt(f_idx(ii)) + 1: stt(f_idx(ii)) + ndframe), pixwo, pixho)');

Error in min1pipe (line 84) [m, filename_raw, imaxn, imeanf, pixh, pixw, nf, imx1, imn1] = data_cat(path_name, file_base{i}, file_fmt{i}, Fsi, Fsi_new, spatialr);

JinghaoLu commented 4 days ago

Can you try this: ffmpeg -c:v ffv1 -i your_video_full_path.avi -an -c:v rawvideo -pix_fmt gray8 -y your_target_video_full_path.avi

alexisfaure77 commented 3 days ago

Thank you very much, it seems to work properly.