flatironinstitute / CaImAn

Computational toolbox for large scale Calcium Imaging Analysis, including movie handling, motion correction, source extraction, spike deconvolution and result visualization.
https://caiman.readthedocs.io
GNU General Public License v2.0
639 stars 370 forks source link

Embedded timestamp (UCLA Miniscope Question) #736

Closed donglabimaging closed 4 years ago

donglabimaging commented 4 years ago

They have posted a sample Matlab code (listed below), but I am not sure how to do that in the CaImAn environment. footer = (frame(end,(end-7):end)); timestamp = footer(1) + bitshift(footer(2),8) + bitshift(footer(3),16) + bitshift(footer(4),24);

I have tried cv.imread / cv.videocapture and try to gain access the pixels of each frame without any success. I would really appreciate it, if I could get some help here. Many thanks!

epnev commented 4 years ago

@donglabimaging

  1. You can load the file fname as usual (but save it as a 32 bit integer). m = cm.load(fname).astype(np.uint32))

  2. Then it is not clear whether the last 8th, 7th, 6th, and 5th pixels occur in the last row or the last column of each frame. You'll have to find that out yourself, but depending on where they are you can extract them by pixel_values = m[:, -1, -8:-4] or pixel_values = m[:, -8:-4, -1]. This will give you an array where each row has the values of the pixels you're interested in.

  3. You will have to find a python equivalent to MATLAB's bitshift function or implement it yourself. We cannot help with this but maybe the Miniscope team has done this already. @daharoni