multigeom.fit.calibrate_sigma#

Calibrate the observation-noise scale σ of the Gaussian observation model

    p(r | x) = N(f_φ(x), σ² I)                       (paper Eq. (eq:obs-model))

from the trial-to-trial variability of the TVSD recordings (paper App.
"Observation model for responses"):

    "each held-out stimulus is presented 30 times, and for each electrode we
     compute the standard deviation of the z-scored per-trial response around
     the trial-averaged mean. The median of this quantity across electrodes is
     0.22 in V1 and 0.25 in V4."

Computation. `test_MUA_reps` in monkeyN_THINGS_normMUA.mat holds the
normalised MUA of every repetition of every test image; h5py returns it as
[n_trials = 30, n_test_images = 100, n_channels = 1024] (the transpose of the
MATLAB array). For channel c with per-trial responses y_{t,i,c}:

    ȳ_{i,c} = (1/T) Σ_t y_{t,i,c}                         trial-averaged mean
    s_c     = sqrt( (1/(T·I)) Σ_{t,i} (y_{t,i,c} − ȳ_{i,c})² )   pooled over
                                                          trials and images
    σ̂_area  = median_c s_c

The responses are used exactly as provided (normMUA, the per-channel
normalisation of Papale et al.); no further z-scoring is applied. `test_MUA`
in the same file is the trial average of `test_MUA_reps`, which the script
checks.

Channel set. The paper text says "for each electrode ... across electrodes"
without naming the set. σ is the noise scale of the response vector r that
the encoders predict and the diffusion model is conditioned on, i.e. the
top-50 channels of each area by oracle reliability; the original measurement
script (measure_sigma.py, `trial_only_noise`) used exactly this set. The
primary number is therefore computed on the same top-n channels that
`multigeom.fit.tvsd.load_tvsd` selects for the encoders. The median over all
channels of the area is reported alongside it for reference.

Output: JSON with per-area medians (primary: top-n channels; reference: all
area channels), per-channel standard deviations, and a provenance record.

Usage:
    python -m multigeom.fit.calibrate_sigma --out runs/analysis/sigma_calibration.json
    python -m multigeom.fit.calibrate_sigma --tvsd-dir /path/to/tvsd --n-neurons 50

Functions

calibrate(tvsd_dir, areas, n_neurons)

Per-area σ̂ (median over channels) on the top-n channels and on all channels.

load_trial_responses(mat_path)

Read the per-trial and trial-averaged test responses.

main([argv])

Measure the observation noise from the TVSD repetitions and write the JSON (command-line entry point).

parse_args([argv])

Command-line arguments of python -m multigeom.fit.calibrate_sigma.

per_channel_trial_std(reps)

s_c = RMS over (trial, image) of y_{t,i,c} − mean_t y_{t,i,c}.