Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downsample raw movie with avi format? #124

Open
hmfeng opened this issue Feb 27, 2023 · 2 comments
Open

Downsample raw movie with avi format? #124

hmfeng opened this issue Feb 27, 2023 · 2 comments

Comments

@hmfeng
Copy link

hmfeng commented Feb 27, 2023

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
Copy link
Owner

bahanonu commented Mar 8, 2023

@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?

  • I'll push an update to ciapkg.hdf5.downsampleHdf5Movie first that will enable your to quickly start downsampling your AVIs via command window then I'll push ciatah gui integration within modelDownsampleRawMovies.

  • For ffmpeg, you can sometimes increase quality (e.g. with mp4 files using -crf or other commands) but I normally prefer using matlab, imagej, etc. if for analysis rather than display for reasons you mentioned.

  • If you have enough RAM, you can also use modelPreprocessMovie and only select spatial downsampling as below.

image

Then select the downsample amount with downsampleFactorSpace:
image

cheers!
-Biafra

@hmfeng
Copy link
Author

hmfeng commented Mar 8, 2023

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants