Open
Conversation
add PPSEQ GLM file and IBL notebook
add basis fxn + empirical GLM, test both
xanderladd
approved these changes
Oct 21, 2025
xanderladd
left a comment
There was a problem hiding this comment.
this looks good.
a few things to consider going forward:
- are we clipping
eta(line 129) anddelta(line 270) to agressively? to leinent? we can set these thresholds empirically - same as above for
scales = torch.relu(scales - self.l1) - if we add inference mode T_for_RBF will be annoying - RBF basis wont have correct time axis
- do we ever want to add RBF basis with different lengthscale / width
| print("Warning: NaN or Inf detected in GLM update, stopping iteration") | ||
| break | ||
|
|
||
| self.beta = self.beta + 0.1 * delta |
There was a problem hiding this comment.
we should allow this 0.1 to configured - sets the learning rate for newton updates
| N = self.num_neurons | ||
|
|
||
| # Store T for RBF basis functions | ||
| self.T_for_rbf = T |
There was a problem hiding this comment.
If there is a better way to do T for RBF, it would be nice - if you want to do inference, it needs to be set again and can cause some issues... though model isn't currently set for inference. but we can maybe implement this in a cleaner way next time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces
GLMPPSeq, a generalized version ofPPSeqthat incorporates a Generalized Linear Model (GLM) for modeling time-varying background firing rates. This extends the original PPSeq framework to handle non-stationary neural data where background activity varies over time.Key Features
GLMPPSeq Model:
l1_amp) and template neuron participation (l1)rbf_widthparameter controls temporal smoothness of background (scale factor relative to basis spacing, default=0.2)Implementation Details
EM algorithm with three update steps:
Proper GLM initialization in
initialize_random()andinitialize_default()Consistent use of
phifor covariates throughout the classDevice-aware tensor operations for GPU acceleration
Backward Compatibility
PPSeqandCAVIclasses remain unchangedGLMPPSeqclass to avoid breaking existing codeTesting Recommendations
After merge, users should verify:
fit()runs successfully on both CPU and GPU