SILo: set the activity-image peak threshold per recording from trial-to-trial variation

Open
#42 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
12/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Domain
data

Research direction

Start with getActImPeaks, where the fixed peakth = 8 threshold is applied, and find where actAligned is built just before it. The issue proposes a sign-flip null and an FDR-based threshold, and the open points cover split sources, few trials, and validation with makeTransplantSLAP2. Done would mean params.peakth = 'auto' with a peakFDR option, with the chosen threshold and FDR curve recorded in the experiment summary.

Written by the indexing model from the issue text.

Description

SILo seeds sources at peaks of the trial-averaged activity image that exceed a fixed threshold, peakth = 8 in robust z units (median and MAD over all scanned pixels, in getActImPeaks). The best threshold depends on recording length, brightness, labeling density and the number of trials, so a fixed value doesn't fit all recordings. On SLAP2 sessions trimmed to 180 s in the integration-test capsule, 8 gives 5–31 sources per path on three continuous recordings (803121, 878030, 885233) and 76–106 on 780125. On these recordings the number of candidate peaks above 8 keeps rising with every trial added to the average. As a stopgap, the default goes down to 3, the value the estimate below suggests for these recordings.

Estimating the threshold

SILo already holds the per-trial aligned activity images (actAligned) just before getActImPeaks, so the false-discovery rate can be estimated for each threshold in each path.

  1. Null images. Multiply each trial's deviation from the trial mean by a random sign, average, and scale by sqrt(T/(T−1)). This keeps the noise of the trial average but removes everything that is consistent across trials. Each null image gets the same 5×5 local-median subtraction and the same peak rule (second-largest value of the 3×3 neighbourhood above threshold, at a local maximum), expressed in the real image's z units.
  2. Measurement noise only. Synapses that respond in some trials and not others also change sign under the flip. In these recordings 45–88% of the null peaks fell within 2 px of a real source (7–106 times more than chance), and the trial-to-trial SE near sources was 1.8–2.6 times that elsewhere. Null peaks are therefore counted only in pixels more than 4 px from any candidate at z ≥ 3.
  3. Brightness. The null-peak density is measured per quintile of mean brightness and applied to each quintile's whole area. The dependence on brightness was weak, because the per-trial activity image is already normalized for photon noise. The remaining trend differed between recordings (most noise peaks in the dimmest pixels of 780125, in the brightest of 803121).
  4. Threshold. FDR(th) is the expected number of null peaks above th divided by the number of real peaks above th. The threshold is the lowest one from which the FDR stays at or below a target.

With 50 null draws per path, the thresholds came out as follows (compensated registrations from the capsule, 7–10 trials of about 18 s per path):

recording threshold at FDR 5% / 10% / 20% seeds at FDR 10% sources at peakth 8
780125 DMD1 3.75 / 3.0 / 2.25 387 106
780125 DMD2 2.5 / 2.25 / 2.0 519 76
803121 DMD1 3.0 / 2.5 / 2.25 200 18
803121 DMD2 3.25 / 2.75 / 2.25 174 8
878030 DMD1 3.25 / 2.75 / 2.25 69 5
878030 DMD2 3.0 / 2.75 / 2.25 75 8
885233 DMD1 2.5 / 2.25 / 2.0 167 31
885233 DMD2 2.5 / 2.25 / 2.0 133 22

The current threshold is conservative partly because the MAD of the whole image includes real activity. The noise measured away from sources was 0.64–0.90 of the MAD-based sigma, so z = 8 corresponds to roughly 9–12 noise standard deviations.

Open points

  • Split sources. At low thresholds one synapse can produce several neighbouring peaks, which the null does not count as false. At the 10% thresholds 6–46% of seeds had another seed within 3 px, compared with 0–18% at 8, so the fit and merge steps after seeding need to handle these.
  • Validation against ground truth. Transplanted SLAP2 recordings (makeTransplantSLAP2 in the integration-test capsule) keep the real brightness, line timing and photon noise but contain no activity, so every peak SILo finds in them is false. Running SILo on them would test the null directly. The iGluSnFR simulations split into trials would test precision and recall.
  • Few trials. The sign-flip null needs several trials; these recordings had 7–10. Short or single-trial recordings would need a fallback, for example the noise model alone.

A possible interface is params.peakth = 'auto' with params.peakFDR = 0.1, recording the chosen threshold and the FDR curve in the experiment summary.

Data: capsule computations 110c3c0c-25fd-491b-9791-705c4d84ed34 (780125), 9ca1858c-3ad7-4cfc-b5e6-7114b13177de (803121), 0a6e7391-c910-4666-9d4e-826f979146d2 (878030) and 465a15ec-ee55-45a3-b83b-61cddfbc4692 (885233), branch compensated-registration with compensateOnline on, using per_trial_summary.h5 (per_trial_act_im, per_trial_mean_im).

Dominant language
MATLAB
Stars
3
Forks
3
Avg merge
1d 22h
Merged PRs (30d)
31

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AllenNeuralDynamics/GIAnT-MATLAB

All issues in AllenNeuralDynamics/GIAnT-MATLAB

Similar issues

More MATLAB issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.