Grid Cell Demo 03: From Grid Cells to fMRI Hexadirectional Signal
May 14, 2026·
·
2 min read
Shaoyang Cui
This demo now focuses only on voxel-level fMRI outputs and decoding.
Core intuition:
- Within one voxel, many cells with different spatial phases can reduce position-locked map contrast after averaging.
- But if local cells share a similar grid orientation $\phi$, the six-fold directional term can survive at population level.
- After HRF convolution, we can still decode hexadirectional structure from BOLD.
Decoding protocol in this page:
- Use first half of time points as training data.
- Fit $\cos(6\theta)$ and $\sin(6\theta)$ GLM terms to estimate population $\hat\phi$.
- Use second half as test data.
- Build test regressor $\cos(6(\theta-\hat\phi))$ and estimate test $\beta_{\text{hex}}$.
- Compare recovered $\hat\phi$ against ground-truth $\phi$ (modulo 60 degrees).
- Visualize aligned vs misaligned bins and directional preference on a 360-degree polar plot.
You can customize:
- voxel cell count
- initial phase distribution
- HRF kernel
- signal/noise settings
- trajectory length
and inspect how recovery quality changes.
Voxel-level fMRI simulation + decoding. We generate synthetic Right EC BOLD with a forward HRF, then decode hexadirectional structure with a GLM that uses a potentially different decode HRF on regressors.
Forward HRF Kernel
Decode HRF Kernel
phi true / phi estimated0.0 deg / 0.0 deg
phi error (mod 60)0.00 deg
beta_hex train0.000
beta_hex test0.000
aligned - misaligned (test)0.000
cv setupleave-one-run-out