Fix _segment normalization to match Koenig (SmoothLabels.m) reference#274
Open
Frederic-vW wants to merge 7 commits into
Open
Fix _segment normalization to match Koenig (SmoothLabels.m) reference#274Frederic-vW wants to merge 7 commits into
Frederic-vW wants to merge 7 commits into
Conversation
Replace per-time-point data normalization and per-map std normalization with Koenig's row L2-norm (1/sqrt(Ne)) on maps only. This makes lambda directly comparable to the Matlab reference implementation and fixes a latent bug where in-place map normalization corrupted subsequent epoch predictions in a loop. Also verified _smooth_segmentation is structurally equivalent to Koenig. Modified by Frederic von Wegner with Claude assistance (claude-sonnet-4-6). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
for more information, see https://pre-commit.ci
Owner
|
Hello @Frederic-vW, Thanks for spotting the issue and for the fix ! Do you know if the previous implementation give wrong microstate sequences ? Or the change is mainly to have similar lambda values across libraries ? I had a quick look at the library and did not found any other implementation of functions using the |
for more information, see https://pre-commit.ci
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
_segmentwith Koenig's row L2-norm (1/sqrt(Ne)) on maps only, matchingNormDim(M,2)/sqrt(Ns)in the Matlab reference (SmoothLabels.m).states /= std) corrupted subsequent epoch predictions when_segmentwas called in a loop over epochs._smooth_segmentationis structurally equivalent to the Koenig reference once maps are correctly normalised.Motivation
The previous std-normalization made
lambda(the smoothing factor) incomparable to the original Pascual-Marqui/Koenig implementation. With row L2-norm normalization,lambdais directly transferable between implementations.Test plan
lambdavalue🤖 Generated with Claude Code