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: Index exceeds the number of array elements (750350538) #44

Open carlottarpt opened 3 years ago

carlottarpt commented 3 years ago

Hello,

Thanks for your code! I get the following error message: Index exceeds the number of array elements (750350538). I've seen that this issue has been committed before #19 #41 , but I think my data might be slightly different and therefore the issue. My data is stored in an hdf5 file. I managed to transfer this data to an .avi file format but get the following error message (see below). I noticed that my .avi movie has a bit depth of 24 even though it is grayscale and should be 8. Might this be causing the problem?

Do you expect your code to work for data aquired with other cameras? If not, is it possible to change the code such that it is usable with .avi files from different cameras or is it very specific to the Miniscope?

If I understand correctly you are trying to extract the frames out of the bit stream. What I don't understand is why you cast to uint 32 in this line: ndframe = double(typecast(dlen, 'uint32'));

Index exceeds the number of array elements (750350538).

Error in data_cat (line 200)
                                        headert = d_raw(stp + 1: stp + hstep2)';

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);

Thanks in advance!

JinghaoLu commented 3 years ago

Hi, thanks for your question. The issue is totally related to the video format, and currently MIN1PIPE only supports most popular formats, such as tiff/tif, raw unconstrained avi with grayscale and .mat. A more general reading interface could be used but it may not be optimized for reading speed or memory management in matlab.

The code should work for all compatible video format as long as the camera produces one of such. You are welcome to change the code to adapt it to other video formats, but that covers a wide range and from the developing perspective, it is impossible to add interface for any format (also due to my limited time and knowledge on the related topic).

To use it alternatively, you can consider converting your data into .mat format: assign a variable "frame_all" with the size of your video (height X width X # frame). This will remove all complexity working with video format.

For the last question, uint32 is the way .avi header file encoded, so to parse the header correctly, you have to convert the info into a block of 4 characters.