Optimize the surround predictors in fitB's baseline estimate

未关闭
#41 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
12/100
Issue 类型
重构
描述清晰度
需要澄清
活跃度
活跃
领域
data

调研方向

Start in dependencies/extraction/extractTrial.m, where fitB calls getSurround, and read setParamsExtractTrial.m for params.Bfilter and the ±10·mean(Y) bounds. The issue lists several alternative designs and no chosen one, so agree on an approach with the maintainers first. Done means the paired short-trial denoised r and the real-trial RSS drop, coherence and bound-fraction checks all move in the intended direction.

由索引模型根据 Issue 内容生成。

描述

enhancement

Background

fitB (dependencies/extraction/extractTrial.m) fits each pixel's baseline jointly with three surround predictors. They are meant to capture fast background fluctuations shared with neighbouring pixels. getSurround builds them by filtering the high-passed residual (Y − HX, high-passed by splitFreq) with the filters in params.Bfilter (setParamsExtractTrial.m):

  1. a ring, max(0, G(σ = selRadius) − G(σ = selRadius/2)), positive from about 5.7 px out at selRadius = 6;
  2. that ring times a left–right gradient mask;
  3. that ring times an up–down gradient mask.

Each pixel gets its own coefficient for each predictor. The coefficients are bounded at ±10·mean(Y), like the other baseline coefficients.

These notes come from the baseline-model work in #37 and #40. #40 keeps the surround unchanged, because removing it costs a little accuracy. But it looks under-used, and there are clear things to try.

What it contributes now

Short-trial ground truth. These are the 12 simulations, cut into 30 s trials with the real 780125 trial-end gaps imposed (the harness described in #40). Removing the surround predictors changes denoised r by:

  • −0.0019 per source with the sine basis (24 sources better, 74 worse by more than 0.005);
  • −0.0015 with the penalized spline from #40 (26 better, 78 worse).

LS r and event F1 barely change.

Real data. I dumped 65 fitB calls from 780125 trials (T = 5633 at 200 Hz) and refitted each with and without the surround (sine basis):

  • It explains little. The median fractional drop in weighted RSS is 0.0010 (10th–90th percentile 0.0006–0.0017). That is about twice what 3 extra predictors give by chance (3/T = 0.0005).
  • It changes LS traces slightly. The fast part moves by 0.08 noise SD (0.03–0.15), about 1.3% of F0.
  • No activity leaks into it on average. The correlation between the change in LS and the source's activity has a median of 0.00.
  • It is incoherent across pixels. Within a subproblem, the surround contributions of different pixels correlate at a median of 0.02.
    • The exception is one single-source subproblem, where they correlate at 0.54 and rise with bursts of activity.
    • There it explains 15× chance (RSS drop 0.0075) and moves LS by 0.37 noise SD.
    • Its correlation with activity is −0.20, so it lowers LS when the source is active. That may be real neuropil or out-of-focus signal, or it may be removing real signal.

The 10 dumps from the long simulations (T = 78260) look the same: RSS drop 0.0001 against 0.00004 by chance, and coherence 0.06.

Cost. Since #37 the surround is a sparse pixels × pixels product, and cheap. Before #37 it was most of fitB's time on long trials.

Why it is probably under-used

  1. Most of the ring lies outside the subproblem. A subproblem only holds pixels within selRadius of its sources (imdilate(..., strel('disk', selRadius)) & selPix), and getSurround treats everything else as zero. On the real dumps, the median share of the ring's weight that lands on pixels inside the subproblem is:

    • 13% for single-source subproblems;
    • 35% for subproblems with 4 or more sources;
    • 5–40% across all 65.

    So the predictor mostly sees the subproblem's own pixels near the sources, not the surround.

  2. The coefficient bounds are on the wrong scale. A surround coefficient is dimensionless: the pixel's fast fluctuation per unit of filtered residual. Its bound, ±10·mean(Y), is in photons per sample.

    • With the median mean(Y) of 0.57, the bound is about ±6.
    • The ring's weight inside the subproblem sums to only about 0.06 (median over pixels; 0.445 in total).
    • So following a fluctuation shared by the whole neighbourhood would need a coefficient of about 17.

    On the real trials, a median of 27% of surround coefficients sit at a bound (7–50% across subproblems). On the long simulations it is about 10%.

  3. Independent per-pixel coefficients fit noise. Each pixel fits three coefficients on its own, which gives contributions that are incoherent across pixels (r ≈ 0.02). A truly shared background would give coherent contributions.

Things to try

  • Feed the surround from outside the subproblem. Give each subproblem a wider ring of pixels (for example selPix dilated by another selRadius), used only to build the surround.
    • Their residual needs HX for sources that belong to neighbouring subproblems.
    • One option is to high-pass Y directly at pixels outside every footprint. Another is to use the previous iteration's estimates.
  • Normalize the predictors. Divide each surround predictor by its filter weight inside the subproblem, or by its SD. Coefficients then mean the same thing in every pixel, and bounds of a few units make sense, independent of mean(Y). A ridge penalty could replace the bounds.
  • Share the fast background across the subproblem. Fit one or a few fast background time courses per subproblem, with per-pixel loadings, instead of three independent coefficients per pixel. That uses far fewer free parameters and is coherent by construction.
  • Watch for activity leakage. A wider or less constrained surround could take on more of the coherent, activity-correlated component seen in the one subproblem above. Check the correlation between the change in LS and activity.
  • Check what the simulations contain. If they have no fast, spatially shared background, ground truth can only show what the surround costs, not what it gains. It is worth checking before relying on the short-trial harness to judge changes here.

How to evaluate

  • Short-trial ground truth: paired per-source denoised r, overall, near trial ends and in the interior.
  • Real trials: RSS drop against chance, coherence across pixels, the fraction of coefficients at a bound, and the correlation between the change in LS and activity.

The short-trial harness and the dump analysis behind these numbers aren't in the repo yet.

主要语言
MATLAB
星标
3
派生
3
平均合并
1 天 22 小时
30 天内合并 PR
31

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

AllenNeuralDynamics/GIAnT-MATLAB 的其他 Issue

查看 AllenNeuralDynamics/GIAnT-MATLAB 的全部 Issue

相似的 Issue

更多 MATLAB Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。