Skip to content

About

Facilitates the creation of flythough microscopy volume videos via BigDataViewer

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

30 Commits

Folders and files

Repository files navigation

Flythrough

A GUI-driven tool for authoring fly-through movies of large 3D microscopy volumes stored as N5 or OME-Zarr (including Zarr v3). It is heavily inspired by the hand-edit movie creation workflow in hot-knife.

The general workflow is as follows:

setup → intensity/CLAHE preview → interactive keyframe capture → visual verify/reorder → JSON config → headless PNG render

Several volumes can also be authored together and rendered side by side into one movie — see Multi-volume movies.

Build

mvn clean package

produces a runnable uber-jar at target/flythrough-*.jar.

Usage

1. Author a movie (GUI)

java -jar target/flythrough-0.0.1-SNAPSHOT.jar
  • Setup: enter the data path, output (movie) directory, expansion factor, voxel size (optional), orientation, canvas size and FPS. The two path fields accept files/folders dropped from the desktop. Leave the canvas size blank to size it from the data (see Defaults from the data).
  • Intensity: a BigDataViewer window opens with the defaults. Adjust normalization, CLAHE slope, clip min/max and invert, press Reload preview to see them (the current view is kept), and OK when you are happy. The screen size can be changed here too — Apply size resizes the viewer immediately, with no reload, so the movie canvas can be judged against the live image.
  • Navigate: the same BigDataViewer window; Pan / zoom / scroll to a view you like and press T to capture it as a key point. Key points are stored, in order, as the full viewer transform, so rotation is preserved.
  • Verify: each key point gets a thumbnail. Set the number of frames and the acceleration curve for each segment between key points, optionally hold on the first key point, and optionally return to the first key point at the end. Drag thumbnails to reorder. Save the config and/or render.

2. Edit a saved movie

Drop a saved movie-config.json onto the Edit saved config(s) field on the setup page, or type a path there and press Edit. Its values fill the form, and Start → Intensity walks it back through the same stages — intensity, navigate, verify — with the existing key points and timing in place. The viewer opens on the movie's first key point, so the preview shows the movie as it starts rather than BigDataViewer's default view. Capture more key points with T, reorder or retime them, then save.

The field takes globs, and dropping several files at once works too:

~/movies/one/movie-config.json              one movie
~/movies/big/panel-*/movie-config.json      every panel of a multi-volume movie
~/movies/**/movie-config.json               everything underneath

* and ? match within one name and ** crosses directories. Matches are sorted in natural order, so panel-2 comes before panel-10. One match is edited on the setup page; several open the multi-volume editor.

The edited config is written back to the file it was loaded from, not to the canonical <moviePath>/movie-config.json, so a config kept under another name stays where it is. Values you already chose are preserved rather than re-detected: a clip range that is not the full 0–65535 is left alone, and a screen size is only recomputed if you blank the field.

A glob that matches several panels goes straight to the multi-volume editor, which is the quickest way in:

~/movies/big/panel-*/movie-config.json

The same field exists there as Load saved (drop files or type a glob), so panels can be swapped in after the fact. One tab per config, prefilled; the run then proceeds exactly as authoring does — intensity for all panels, then key points panel by panel — with each panel's existing key points and timing in place.

Loaded panels keep their own output directories, so their rendered frames stay where they are; the shared directory field is prefilled from their common parent and is only used for combined and for any panel you Add afterwards. The grid is not stored in a config, so rows and columns have to be set again.

3. Render from a config (headless)

java -jar target/flythrough-0.0.1-SNAPSHOT.jar --config movie-config.json

Writes img-0000.png, img-0001.png, … into an images/ subfolder of the movie directory (so the frames stay separate from movie-config.json). Assemble into a video with e.g. ffmpeg:

cd <moviePath>/images
ffmpeg -r 60 -i img-%04d.png -c:v libx264 -pix_fmt yuv420p ../movie.mp4

(For a multi-volume movie this is the combined/images folder.)

4. Multi-volume movies (several volumes side by side)

A multi-volume movie is N independent movies tiled into a grid: each panel has its own dataset, key points, timing and canvas size, and only the frame index couples them.

Set the grid — rows and columns, both required, no default — and the panels fill it in reading order: panel 1 top left, then right, wrapping to the next row. Four panels at 2 × 2 give a square; at 1 × 4 a horizontal strip; at 4 × 1 a vertical stack. The grid must have at least as many cells as there are panels; spare cells at the end stay empty, so five panels at 2 × 3 leave the last cell blank.

Each column is as wide as its widest panel and each row as tall as its tallest, with panels centred in their cell, so mismatched sizes are letterboxed with black rather than stretched. The canvas is padded to even dimensions, which h.264 requires.

Authoring from scratch — New multi-volume…

Press New multi-volume… on the setup page. This runs the same stages as a single movie, reordered so the panels can be matched before any of them is committed to:

panels → intensity (all at once, comparable) → key points (one panel at a time) → combine
  • Panels: one dataset tab per volume (Add panel / Remove panel), each with its own screen size. The movie output directory, FPS and the grid are shared. Then Open all → Intensity.

    One directory holds the whole movie — each panel renders into its own panel-N subfolder, and the tiled frames into combined:

    <movie output directory>/
      panel-1/movie-config.json, images/img-0000.png, …
      panel-2/movie-config.json, images/…
      combined/images/img-0000.png, …
    

    The subfolders are numbered in tab order, so reusing a directory for a movie with fewer panels leaves the old higher-numbered folders behind.

  • Intensity: every panel's viewer opens, and the tabs switch from dataset settings to intensity controls — one window, one tab per panel, so normalization, CLAHE slope, clipping and invert can be tuned against each other. Selecting a tab raises that panel's viewer window, which is how you pick one out of a stack of them. Reload preview rebuilds that panel's viewer. Screen size can also be changed here and applies live without a reload, so panel sizes can be judged against each other in the grid. Compare layout tiles what the viewers are showing right now, which is how you tell whether the panels match and whether the grid looks right. Then Done → Key points (which reloads first if a tab was edited but never previewed).

  • Key points: the panels are walked one at a time through the ordinary navigate (press T) and verify stages. The panel's viewer is raised to the front as its turn starts, and every window is labelled with it — the viewer windows are named Panel 2 — fused.ome.zarr, and the stage windows Panel 2 of 4 – Navigate / – Verify. Done → next panel saves that panel's movie-config.json and moves on.

  • Combine: the saved configs are handed to the multi-volume window below.

Combining configs you already have — Combine configs…

If the panels were authored separately as ordinary single movies, press Combine configs… instead: add the configs, set the grid, use Preview to see them composited at a given key point index, reorder with ◀ ▶, then Render all & compose. Compose only re-tiles frames that are already rendered, so you can iterate on the layout without re-rendering.

When combining configs authored separately, give each one a different movie output directory — panels sharing one would overwrite each other's frames, and both entry points refuse to run if they do. (Authoring from scratch handles this for you with the panel-N subfolders.)

Headless:

java -jar target/flythrough-0.0.1-SNAPSHOT.jar \
    --multi top-left.json top-right.json bottom-left.json bottom-right.json \
    --rows 2 --columns 2 --out combined

Each config renders to its own images/ folder as usual; the tiled frames go to <out>/images. Panels of unequal length hold their last frame, so the composite is as long as the longest. --rows and --columns are both required, and the layout is checked before any rendering starts.

Captions

Text drawn centred across the top of the frame, for a span of the movie — a dataset name, a stage label. Add them on the Verify page (Add caption), or by hand in the config:

"labels": [
  { "text": "Wild type", "fromKeyPoint": 0, "toKeyPoint": 2, "fontSize": 0 }
]
  • fromKeyPoint is inclusive, toKeyPoint is exclusive — the caption stops when that key point is reached. "toKeyPoint": -1 runs to the end of the movie, including the return leg.
  • Spans are given in key points, not frames, so retiming a segment or adding a hold moves the caption with the movie instead of stranding it.
  • fontSize caps the size in pixels; 0 sizes it from the frame height. Either way it shrinks further if the text would not fit across the frame, which matters for the narrow columns of a side-by-side movie.
  • Where captions overlap, the later entry in the list wins.

Captions are drawn per panel, into that panel's own frames, so a multi-volume movie labels each dataset in its own column and the tiling needs no extra configuration. They show in the verify thumbnails and in the multi-volume Preview, so you can check the fit before rendering.

Orientation

Reflect across x axis, reflect across y axis and Rotation (degrees clockwise, in the XY plane) re-orient a volume from the setup form, per dataset — so panels of a multi-volume movie can be brought into the same frame of reference. The named axis is the mirror line, so reflecting across the x axis flips top↔bottom and across the y axis flips left↔right. Reflections are applied first, then the rotation, both about the centre of the level-0 voxel grid.

They ride on the source transform, so they move the data rather than the camera, and navigating and capturing afterwards works in the re-oriented frame.

A key point stores a source-voxel-to-screen mapping, which means it absorbs the orientation it was captured under. Changing the orientation of a movie that already has key points therefore has to turn those key points too, and editing one does: each captured view is rotated about the centre of its frame, so whatever was centred stays centred and the image turns around it — the same result as having authored the movie in the new orientation. Existing key points are never invalidated. The config records the orientation its key points were captured under in keyPointOrientation, so editing reflectAcrossX, reflectAcrossY or rotationDegrees by hand in the JSON works too: the key points are turned when the file is loaded. Leave keyPointOrientation alone.

An auto-sized canvas follows the rotation too: rotating a landscape volume by 90° gives a portrait canvas.

Defaults from the data

Rather than opening at fixed constants, a new movie takes its starting values from the dataset when you press Start → Intensity (or Open all → Intensity):

  • Canvas size — leave the screen width/height blank and the canvas is built from that dataset's level-0 X:Y aspect ratio, 1024 px on the longest side and both sides even. A panel given an explicit size always keeps it.

    For a multi-volume movie, Auto size — match decides how much the auto-sized panels are made to agree. Each panel's standalone canvas is the baseline, and the shared values are the mean of those:

    match result
    neither each panel keeps its own canvas
    height one shared height; each width follows that panel's aspect
    width one shared width; each height follows
    both one shared canvas, averaged

    height is usually what a single-row grid wants, width a single-column one, and both a regular rectangular grid.

  • Histogram clip range — 16-bit data gets a clip range chosen the way Fiji's Image → Adjust → Brightness/Contrast → Auto does: a 256-bin histogram, cutoffs at 1/5000 of the sampled pixels, and bins holding more than a tenth of them ignored so a large flat background does not anchor the minimum at 0. The histogram is sampled from a centred box of the coarsest scale level, which costs a few blocks rather than a pass over the volume. 8-bit data is not clipped, so nothing is detected for it.

Both are only starting points — the intensity stage shows the chosen values and lets you change them, and a saved config is never re-detected, so --config renders exactly what the file says.

fps defaults to 60.

Config file

movie-config.json (written to the movie directory) is hand-editable for fine control:

{
  "dataPath": "/path/to/fused.ome.zarr",
  "moviePath": "/path/to/output",
  "voxelSize": "535 nm",
  "expansionFactor": 30.0,
  "reflectAcrossX": false,
  "reflectAcrossY": false,
  "rotationDegrees": 0.0,
  "normalization": "CLAHE",
  "claheSlope": 1.5,
  "histogramMin": 250,
  "histogramMax": 2000,
  "screenWidth": 1050,
  "screenHeight": 750,
  "fps": 60,
  "holdFirstFrames": 120,
  "returnToFirst": true,
  "returnFrames": 120,
  "returnAccel": 3,
  "keyPoints": [
    { "transform": [ 0.117432, 0.0, 0.0, -4875.53, 0.0, 0.117432, 0.0, -393.13, 0.0, 0.0, 0.117432, -3181.94 ] }
  ],
  "segments": [
    { "frames": 0, "accel": 0 }
  ],
  "labels": [
    { "text": "Wild type", "fromKeyPoint": 0, "toKeyPoint": 2, "fontSize": 0 }
  ]
}
  • keyPoints[i].transform is the full viewer transform as 12 row-packed doubles (m00, m01, m02, m03, m10, …, m23). Storing the full matrix — rather than a centre + zoom — preserves rotation and any orientation of the captured view. It is the movie-space viewer transform with the canvas-centre translation removed; the renderer adds the canvas centre back, so it is independent of the movie canvas size.

  • segments[k] (frames + accel) is the motion into keyPoints[k], i.e. from keyPoints[k-1] → keyPoints[k]. The list is kept the same length as keyPoints so each key point owns its incoming timing. segments[0] is never read — keyPoints[0] is the start of the movie and has no incoming motion, so it is always written as { "frames": 0, "accel": 0 }. To pause on the first key point, use holdFirstFrames, not segments[0].

  • Acceleration types: 0 symmetric, 1 slow start, 2 slow end, 3 soft symmetric, 4 soft slow start, 5 soft slow end.

  • voxelSize overrides the level-0 voxel size the scale bar is computed from, for datasets whose multiscales scale or unit is wrong (BigStitcher-Spark fusions, for instance, can end up claiming 1.0 micrometer). One number (isotropic) or three (x y z), with an optional unit: "535 nm", "0.535", "0.2 0.2 0.5 micrometer". Blank uses the metadata. It affects only the scale bar — mipmap ratios come from level-to-level ratios and key points are stored in voxel coordinates, so changing it never invalidates a captured movie.

  • channels composites several channels of a multi-channel OME-Zarr additively, each in its own color with its own normalization and clip range. The CLAHE slope, invert and orientation stay top-level and apply to every channel. Leave it out (or empty) for channel 0 in white with the top-level normalization / histogramMin / histogramMax. The intensity dialog edits it — a row per channel, with Add channel — or set it here:

    "channels": [
      { "index": 0, "color": "#ffcc99", "normalization": "CLAHE", "histogramMin": 100, "histogramMax": 1000 },
      { "index": 1, "color": "#00ffff", "normalization": "NONE",  "histogramMin": 10,  "histogramMax": 450 },
      { "index": 2, "color": "#ff00ff", "normalization": "NONE",  "histogramMin": 10,  "histogramMax": 125 }
    ]
  • keyPoints[k].hiddenChannels lists the channel indices (the index of a channels entry) switched off at that key point; leave it out to show them all. A channel switched on or off at a key point fades over the motion into it, on the same acceleration curve as the camera. Set it with the channel checkboxes on each Verify row, or by toggling channels in the viewer (Shift+1, Shift+2, …) before capturing with T.

Per-level scale / anisotropy is read automatically from the dataset's OME-NGFF multiscales metadata — there is no anisotropy parameter. The spatial unit from that metadata drives the scale bar: metric units (OME-NGFF spells them out, "micrometer", "nanometer", "centimeter", …) are converted to micrometres, which BigDataViewer then labels as nm / µm / mm / m as appropriate. Non-metric units are passed through as-is. The bar is in units of the sample before expansion, i.e. voxel size divided by expansionFactor.

Scope

  • Rendered frames carry the scale bar only. BigDataViewer's multi-box overlay (the volume-extent box in the corner) is a navigation aid: it stays in the interactive viewer but is not drawn into the movie, its thumbnails, or the multi-volume preview.
  • PNG frame-sequence output (no built-in video encoding).
  • Multi-volume panels share no timing — match their frame counts by hand if you don't want the short ones to freeze.

License

BSD 3-Clause. Copyright © 2026 Howard Hughes Medical Institute. See LICENSE.

About

Facilitates the creation of flythough microscopy volume videos via BigDataViewer

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages