Skip to content

Choose the annotation trial by movie data, not file size - #55

Merged
KasparP merged 1 commit into
mainfrom
annotation-trial-frames
Nov 24, 2026
Merged

KasparP merged 1 commit into
mainfrom
annotation-trial-frames

Conversation

@KasparP

@KasparP KasparP commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

getAnnotationImage annotates ROIs on the mean image of a path's longest valid trial, and it measured trial length by the file size of the registered movie. That works for TIFF movies, whose size grows with the number of frames. HDF5 movies (saveTif=false, and the default in GIAnT-Python since AllenNeuralDynamics/GIAnT-Python#14) are deflate-compressed, so their size also depends on content. For example, among the equal-length trials of a continuous recording, the noisiest trial has the largest file, and a long trial with many empty pixels can look shorter than a short one. TIFF and HDF5 registrations of the same data could therefore annotate on different trials.

HDF5 movies are now sized by their dataset (frames × frame size, as single), as localizationTrialBytes already does when it sizes SILo's pool. TIFF movies are still sized by their file, so TIFF runs pick the same trial as before. Ties still go to the first trial, and a missing movie still counts as 0. When the alignment file has no meanIM, the mean image of an HDF5 movie is now read with h5read; previously this path always used the TIFF reader. Both GIAnT-MATLAB and GIAnT-Python write meanIM, so this fallback is rarely used.

tests/unit/dependencies/TestGetAnnotationImage.m adds six tests:

  • a longer HDF5 trial whose compressed file is smaller than a shorter, noisy trial's;
  • equal HDF5 trials of different compressed size;
  • excluded and missing trials;
  • TIFF sizing;
  • an HDF5 movie without meanIM;
  • a path with no valid trials.

On main, the three HDF5 tests fail and the other three pass. With this change, the full unit suite passes locally (198 of 198, R2024b).

🤖 Generated with Claude Code

getAnnotationImage annotates on a path's longest valid trial and used
the registered movie's file size as its length. Compressed h5 movies
(saveTif=false, and GIAnT-Python's default) have file sizes that depend
on content as well, so it could pick a shorter or a different equal
trial than the TIFF movies of the same data. h5 movies are now sized by
their dataset, as localizationTrialBytes does; TIFF movies are still
sized by their file, so TIFF runs pick the same trial as before. Ties
still go to the first trial. Without meanIM in the alignment file, the
mean image of an h5 movie is now read with h5read instead of the TIFF
reader.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the HDF5 trial-selection and mean-image fallback changes.

No open issues 🎉

What changed in this PR

Updates annotation-image selection to choose HDF5 trials by movie data size rather than compressed file size, while preserving existing TIFF selection behavior.

Changes:

  • Sizes HDF5 movies by dataset dimensions, preserving first-trial tie handling and zero sizing for missing movies.
  • Reads HDF5 movie data when the alignment file lacks meanIM.
  • Adds six unit tests covering trial selection, exclusions, missing movies, TIFF behavior, and the HDF5 fallback.
File Description
tests/​unit/​dependencies/​TestGetAnnotationImage.m Adds regression tests for trial selection and mean-image fallback.
dependencies/​io/​getAnnotationImage.m Uses dataset-based HDF5 sizing and adds an HDF5 mean-image fallback.

Review effort: Balanced

@KasparP
KasparP merged commit 3142ece into main Nov 24, 2026
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants