bahanonu / ciatah

CIAtah (pronounced cheetah): a software package for calcium imaging analysis of one- and two-photon imaging datasets. Documentation: https://git.io/ciatah_docs. Formerly known as calciumImagingAnalysis (ciapkg).
https://git.io/ciatah_docs
MIT License
80 stars 20 forks source link

Downsample raw movie with avi format? #124

Open hmfeng opened 1 year ago

hmfeng commented 1 year ago

Hi,

Is it possible that modelDownSampleRawMovies method can support the avi file? We got the avi video from UCLA miniscope directly but it is too big to be processed in ciatah (30 min video with 4 gb size). I'm considering to downsample these videos but found only TIFF/H5/ISXD are supported. Do you have any ideas that avi file can be downsampled in ciatah or I can use other software to downsample them?

PS: I tried ffmpeg to downscale or crop the raw video but found the output files lost much quality than I expected. So I'm worried about the following cell extraction effect.

Thank you! Hemin

bahanonu commented 1 year ago

@hmfeng, how much RAM does your analysis computer have? As normally 4 GB file sizes should be handled by ciatah. e.g. is it crashing during a certain step in modelPreprocessMovie?

image

Then select the downsample amount with downsampleFactorSpace: image

cheers! -Biafra

hmfeng commented 1 year ago

@bahanonu Thank you very much for your reply and updates!

My analysis computer has 64GB memory and encountered the 'out of memory' error during the modelPreprocess step which I think should result from the pre-allocation of the matrix with the size of the raw video (752pixel x 480pixel x 35976 frame, as I recorded video for 30 min with 20 fps).

So I decided to crop the video so as to keep the area with visible Ca2+ signal only. In the beginning I found the quality of video was dropped dramatically after cropping. After some searching, I forced the ffmpeg to re-encode the video with 'ffv1' codec can solve this problem and the output video can keep original quality with the 8bit grayscale decoded format, which is good enough for the downstream processing.

My original 30min raw avi movie has a size of 4 GB and after cropping I had a 1.5 GB movie. After preprocessing the h5 file is less than 4 GB (with all default settings and only downsample in time, no downsampling in space). And eventually I can successfully extract the signal with the CNMF-E algorithm, with the help from my colleague.

I will try your updated method and thank you very much for your hard work for maintaining this software!

Best, Hemin