Skip to content
Source Separation Lab

Step 02Question 2 · estimation

Unmixing the signal, four ways

Knowing the time courses, can we recover where each source lives in the image, and then rebuild its time course from the data? Switch between the estimators, move the penalty, and watch the maps sharpen or fall apart.

Using the 2021 parameters. Results match the report.

Because we generated the data, the regressors are known: D=TCD = \mathrm{TC}. Least squares then retrieves every spatial map in one closed-form step, and the time courses follow by projecting the data back onto those maps:

ALSR=(D⊤D)−1D⊤XDLSR=XALSR⊤\begin{gathered} A_{\mathrm{LSR}} = (D^\top D)^{-1} D^\top X \\ D_{\mathrm{LSR}} = X A_{\mathrm{LSR}}^\top \end{gathered}

The maps come back recognisable but speckled, because every pixel's noise is fitted as faithfully as its signal.

Least squares has no tuning parameter. It is the unbiased baseline every other method is compared with.

Σ cT (time courses)
5.2674
2021 report: 5.2674
Σ cS (spatial maps)
1.1486

Figure 2.1

Retrieved sources: Least squares

  • Ground truth
  • Retrieved (LSR)

time courses shown as z-scores

  1. Source 1

    cS 0.53

    cT 0.886

    Source 1: true and retrieved time courses−202080160240
  2. Source 2

    cS 0.00

    cT 0.877

    Source 2: true and retrieved time courses−202080160240
  3. Source 3

    cS 0.02

    cT 0.892

    Source 3: true and retrieved time courses−202080160240
  4. Source 4

    cS 0.05

    cT 0.867

    Source 4: true and retrieved time courses−202080160240
  5. Source 5

    cS 0.00

    cT 0.879

    Source 5: true and retrieved time courses−202080160240
  6. Source 6

    cS 0.55

    cT 0.865

    Source 6: true and retrieved time courses−202080160240
Each row pairs a true spatial map with the retrieved row of A (in the original orientation, the notebook's reshape(21, 21).T), and the true time course with the retrieved column of D = XAᵀ. cT and cS are the absolute correlations the assignment asks for. The spatial scores depend on the pixel ordering; see the note at the bottom of the page.

Figure 2.2

Correlation vectors for all four estimators

  • LSR
  • RR
  • LR
  • PCR

cT: time courses

Grouped bar chart of temporal correlations per source for each method00.20.40.60.81S1 · LSR: 0.886S1 · RR: 0.886S1 · LR: 0.896S1 · PCR: 0.077S1S2 · LSR: 0.877S2 · RR: 0.877S2 · LR: 0.881S2 · PCR: 0.187S2S3 · LSR: 0.892S3 · RR: 0.892S3 · LR: 0.900S3 · PCR: 0.044S3S4 · LSR: 0.867S4 · RR: 0.868S4 · LR: 0.903S4 · PCR: 0.028S4S5 · LSR: 0.879S5 · RR: 0.881S5 · LR: 0.930S5 · PCR: 0.022S5S6 · LSR: 0.865S6 · RR: 0.867S6 · LR: 0.918S6 · PCR: 0.004S6

cS: spatial maps (as submitted)

Grouped bar chart of spatial correlations per source for each method00.20.40.60.81S1 · LSR: 0.531S1 · RR: 0.531S1 · LR: 0.883S1 · PCR: 0.050S1S2 · LSR: 0.003S2 · RR: 0.003S2 · LR: 0.052S2 · PCR: 0.112S2S3 · LSR: 0.019S3 · RR: 0.019S3 · LR: 0.079S3 · PCR: 0.054S3S4 · LSR: 0.045S4 · RR: 0.045S4 · LR: 0.038S4 · PCR: 0.099S4S5 · LSR: 0.001S5 · RR: 0.001S5 · LR: 0.059S5 · PCR: 0.192S5S6 · LSR: 0.549S6 · RR: 0.549S6 · LR: 0.697S6 · PCR: 0.260S6

Scroll sideways for S1–S6.

Correlation vectors per source and their sums
MethodVectorS1S2S3S4S5S6Sum
LSRcT0.8860.8770.8920.8670.8790.8655.2674
cS0.5310.0030.0190.0450.0010.5491.1486
RRcT0.8860.8770.8920.8680.8810.8675.2713
cS0.5310.0030.0190.0450.0010.5491.1487
LRcT0.8960.8810.9000.9030.9300.9185.4275
cS0.8830.0520.0790.0380.0590.6971.8078
PCRcT0.0770.1870.0440.0280.0220.0040.3624
cS0.0500.1120.0540.0990.1920.2600.7675
Per-source absolute correlation between the truth and each estimate, at the parameters chosen above (λ = 0.5, ρ = 0.625, PCR ρ = 0.0010). The table repeats the values and their sums.

Figure 2.3

Why pixel 30 tracks the third source, not the fourth

Scatter plot of the third retrieved time course against pixel 30, showing a strong linear relation−2−1012−150−100−500501001503rd column of D_LSR30th column of X
Scatter plot of the fourth retrieved time course against pixel 30, showing no relation−2−1012−100−500501004th column of D_LSR30th column of X
Pixel 30 (column-major) sits at row 9, column 2 of the grid, inside the patch of source 3 (rows 8–13, columns 2–6). Its time series is therefore driven by TC3, and the retrieved DLSR column 3 lines up with it. Source 4 lives on the other side of the grid, so its retrieved time course shows no relationship with this pixel.

Fidelity notes

What the port keeps from 2021, quirks included

The aim here is to reproduce what I submitted, not to correct it, so the TypeScript port keeps a few behaviours of the original code. The parity tests check each of them against the notebook's saved outputs.

  • Ridge λ is not scaled by V. The task suggests λ~=λV\tilde\lambda = \lambda V, but the notebook added 0.5 * np.eye(6) directly. The slider uses the same convention.
  • The lasso is a single thresholded gradient step. The original LassoRegression restarts every iteration from a zero vector, so its ten repetitions all return the same update. It also scales survivors by (1 / 1 + thr), which Python reads as 1 + thr. Both are reproduced exactly.
  • Spatial scores and pixel order. X was built from maps flattened column by column, but Q2.4 re-read the maps from a CSV flattened row by row, then correlated them with the retrieved maps. Under the As submitted toggle you get that comparison and the reported sums (ΣcSLR = 1.808, ΣcSRR = 1.149). Under Aligned both use the same order and the spatial scores rise, while the lasso still beats ridge.

Next · Step 03

Tune

Pick the lasso penalty ρ from the mean MSE over noisy realisations, then see how sure that choice is.