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

Exporting h5 file too big? #125

Open
KClay98 opened this issue Mar 18, 2024 · 1 comment
Open

Exporting h5 file too big? #125

KClay98 opened this issue Mar 18, 2024 · 1 comment

Comments

@KClay98
Copy link

KClay98 commented Mar 18, 2024

I have mp4 files (about 1.5 mins long) of worms moving in a dish. I want to measure speed and use animal tracking which shouldn't be much different than drosophila larvae behavior tracking. I was able to use a free online converter to make the mp4 into avi files and the FFmpeg plugin for ImageJ to open it. When I try to save it as hdf5 (either using the hdf5 plugin or the elastik for imageJ plugin), it outputs a file that is huge and way too big for elastik to read/process (between 5 and 1000mb). The example tutorials showed h5 files about 600kb, which is what I was expecting. I cannot seem to get my files in a readable format for elastik. How does everyone else convert videos of animals to readable formats for elastik?
Here's the link to the mp4: https://drive.google.com/file/d/1bcFYG_FIv6ju6JXXwonF_1H33FXG08Si/view?usp=share_link

@k-dominik
Copy link
Contributor

Dear @KClay98,

thank you for reaching out and providing example data! That makes it so much easier to reproduce.

First of all, it is expected to end up with much larger files after converting from mp4 video to an image format. Very hand-wavy: video compression can exploit similarities between time frames to reduce the amount of data that is needed to be saved. So for a given time frame, partial information from multiple ones might be combined. Whereas after conversion to an image format each time frame is on its own. Adding to that, formats typically used in bioimage analysis use only lossless compression (like hdf5).
It is however no problem at all to use larger data in ilastik. You can make your life for the given task a bit easier though, but that depends of course, on your analysis goals. I had a quick look and did the following:

  • converted the .mp4 to .avi with ffmpeg (this involves using the command line/terminal, but I'd personally prefer that instead of uploading my data to some webservice). For reference I used the following command (which I found on the imagej mailing list via the image.sc forum:
    ffmpeg -i KBCtestvideo1.mp4 -pix_fmt nv12 -f avi -vcodec rawvideo convertedFile.avi
    
  • .avi can be loaded into Fiji, as you have mentioned. I'm not sure the color information is important for your analysis. I think the tracking task doesn't need it, so I converted the data to grayscale on import:
    Screenshot 2024-03-19 at 14 02 08
  • After import, the axes in Fiji are not recognized correctly - which should be corrected via Image -> Properties:
    Screenshot 2024-03-19 at 14 06 22
  • I noticed that the time resolution is quite high in your video - for tracking I don't think it is really necessary to have it that high, so I created a substack with lower time resolution (only picking every 5th time frame) via Image › Stacks › Tools › Make Substack...:
    Screenshot 2024-03-19 at 14 03 46
  • that I exported to hdf5 with the ilastik plugin - the file size there is 45mb
  • Then I'd recommend to do Pixel Classification for foreground/background segmentation, and Animal Tracking for tracking. Maybe some hints:
    • Pixel Classification: two classes, one for foreground, one for background. I'd use only size one brushes, label some worm pixels very carefully in a couple of time frames, and also add some background labels. The shadows of the worms can be trained away into the background class. Check in various time frames. Don't worry if there are some little objects in the background with some foreground pixels. In tracking there will be a "false detection" class that can filter these out relatively easily.
    • Tracking: in the object count classifier, be sure to check the uncertainty layer - it will require some labeling to get low uncertainty values (white-ish).

Hope this helps - good luck with the analysis. Furthermore, I think your question could be of interest to many users. The github issues are more for tracking bugs in the ilastik software. Usage questions get a wider audience on forum.image.sc.

Cheers

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