Skip to content

Add Matlab-parity methods and rewrite paper examples#49

Merged
iahncajigas merged 6 commits intomainfrom
feature/matlab-parity-methods-and-examples
Mar 10, 2026
Merged

Add Matlab-parity methods and rewrite paper examples#49
iahncajigas merged 6 commits intomainfrom
feature/matlab-parity-methods-and-examples

Conversation

@iahncajigas
Copy link
Copy Markdown
Contributor

Summary

  • SignalObj methods (core.py): Port shift, shiftMe, alignTime, power, sqrt, xcov, periodogram, MTMspectrum, spectrogram from Matlab
  • FitResSummary plotting (fit.py): Port plotAllCoeffs, plot3dCoeffSummary, plot2dCoeffSummary, plotKSSummary
  • SSGLM EM algorithm (decoding_algorithms.py): Full PPSS_EMFB implementation (~700 lines) with E-step (Kalman), M-step (Newton), Fisher information, and Monte Carlo CIs
  • UKF (decoding_algorithms.py): Port ukf, ukf_ut, ukf_sigmas
  • nstColl.ssglm/ssglmFB (trial.py): Convenience methods for running SSGLM on spike train collections
  • Paper examples (all 5): Rewritten from thin wrappers to self-contained documented scripts with CLI args and figure export

Test plan

  • All 179 existing tests pass (pytest tests/ -v)
  • Paper example script tests pass (test_paper_example_scripts.py)
  • CI status checks pass on this branch

🤖 Generated with Claude Code

Iahn Cajigas and others added 6 commits March 9, 2026 23:17
Port missing SignalObj methods from Matlab nSTAT toolbox:
- Time manipulation: shift, shiftMe, alignTime
- Arithmetic: power, sqrt
- Cross-covariance: xcov (mean-removed xcorr)
- Spectral: periodogram, MTMspectrum (DPSS multi-taper), spectrogram

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Port missing FitResSummary methods from Matlab nSTAT toolbox:
- plotAllCoeffs: errorbar plot of GLM coefficients across neurons/fits
- plot3dCoeffSummary: 3D bar plot of binned significant coefficients
- plot2dCoeffSummary: stacked ridge-plot of coefficient distributions
- plotKSSummary: subplot grid of KS goodness-of-fit plots per neuron

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Major additions ported from Matlab nSTAT toolbox:

SSGLM (State-Space GLM) EM algorithm in decoding_algorithms.py:
- PPSS_EStep/PPSS_MStep: E-step (Kalman smoothing) and M-step (Newton)
- PPSS_EM/PPSS_EMFB: Full EM with forward-backward smoothing
- estimateInfoMat: Fisher information for coefficient CIs
- prepareEMResults: Package EM output as FitResult objects
- _ComputeStimulusCIs_MC: Monte Carlo stimulus confidence intervals

Unscented Kalman Filter (UKF) in decoding_algorithms.py:
- ukf_sigmas: Sigma point generation via Cholesky decomposition
- ukf_ut: Unscented transformation
- ukf: Full UKF one-step update

SpikeTrainCollection methods in trial.py:
- ssglm(): Run SSGLM EM on spike train collection
- ssglmFB(): Run SSGLM EM with forward-backward smoothing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace thin wrappers (calling main_for) with self-contained scripts
matching the Matlab example structure:

- example01: Full nSTAT class API usage (nspikeTrain, Trial, Analysis)
  for mEPSC Poisson modeling under constant and washout Mg2+
- example02: Whisker stimulus GLM with lag/history selection
- example03: PSTH comparison and SSGLM dynamics (two-part)
- example04: Place-cell receptive fields (Gaussian vs Zernike)
- example05: PPAF and hybrid filter decoding (three-part)

Each script has: detailed docstrings, workflow comments matching Matlab,
CLI args (--repo-root, --export-figures, --export-dir, --output-json),
and proper result merging for multi-section examples.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add overview paragraph describing toolbox capabilities, lab website
links, license note (GPL v2), Figshare dataset DOI, PMID, and
cross-reference to the Matlab repo.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Port findPeaks, findMaxima, findMinima, findGlobalPeak from Matlab
SignalObj. Fixes two Matlab bugs:
- findPeaks 'minima' branch now negates data before peak detection
  (Matlab original calls findpeaks on raw data, finding maxima instead)
- findGlobalPeak minima branch uses correct variable name
  (Matlab has typo 'sOBj' instead of 'sObj')

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@iahncajigas iahncajigas merged commit 7576122 into main Mar 10, 2026
13 checks passed
@iahncajigas iahncajigas deleted the feature/matlab-parity-methods-and-examples branch March 11, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant