Page 1 of 1

Async Mode: Margin

Posted: 12 May 2026, 08:08
by simboe
Hello everyone,

I'd like to ask a question regarding the current implementation.

I know that when I enable async mode, at each epoch the classifier outputs the margin, i.e. the difference between the highest and the second-highest score.

However, when I monitor this value, I get very large numbers rather than values with a probabilistic meaning (sometimes even 2000 or more). Because of this, I’m unable to properly set the Minimum Evidence parameter.

I was wondering whether someone else has already encountered this issue.

My use case is the P3Speller.

I trained the classifier using SWLDA with the BCI2000 Analysis tool.

I trained the classifier both with larger numbers of sequences and with a single sequence, in order to mirror the async mode case with AccumulatedEvidence.

Am I missing something?

Re: Async Mode: Margin

Posted: 25 May 2026, 13:01
by mellinger
Hi,

thanks for your question, and sorry for the late response.

I will try to reproduce the issue and come back to you.

Best regards
Jürgen

Re: Async Mode: Margin

Posted: 28 May 2026, 15:04
by simboe
Thank you very much for looking into this and for your reply!

Re: Async Mode: Margin

Posted: 29 May 2026, 06:51
by mellinger
Hi,

I've convinced myself that the classifier normalization works as intended in BCI2000Analysis.
Also, using the test data coming with BCI2000, I found no large margins with normalized classifiers.

To help you further, I would need to know some information about how exactly you are using the software so I can reproduce the issue.

You are welcome to send data files to mellinger(at)neurotechcenter.org if you like.

-Jürgen

Re: Async Mode: Margin

Posted: 29 May 2026, 12:41
by simboe
Dear Jürgen,
Thank you for your feedback.
I am currently training the model using BCI2000Analysis and configuring the parameters via Telnet. I am using the standard BCI2000 P3 pipeline:
Spatial Filter → P3TemporalFilter → LinearClassifier
Setup:
* Matrix: 3×3
* Classifier: SWLDA with “normalize variance” enabled
* Number of sequences: 8
* Epoch length: 750 ms
* Minimum evidence: 9
I trained the model using three copy-mode sessions with 5 elements each, and then tested it on the same matrix with feedback enabled.
I have one question regarding the normalization step.
To ensure that the intra-class variance is equal to 1, as described in the documentation, is it necessary to add a Normalizer after the LinearClassifier, or is this already handled internally by the model itself?
I noticed that the .prm file contains the parameters `NormalizerGains` and `NormalizerOffsets`, but since I do not see them loaded in the Operator, I assume they are being ignored.
At the same time, I am also checking whether there may be additional issues elsewhere in the parameters that could contribute to the problem.
As a practical step, I recompiled the source code and added the margin values to the application log.
However, when setting the evidence threshold to around 9, a selection was always triggered because the margin values were significantly higher than expected.
Thank your for your answer.
Best regards,
Simone

Re: Async Mode: Margin

Posted: 29 May 2026, 13:24
by mellinger
I trained the model using three copy-mode sessions with 5 elements each, and then tested it on the same template with feedback enabled.
Did you have a human subject with real EEG, or did you test using SignalGenerator?
What do you mean by "tested it on the same template"?
I have one question regarding the normalization step.
To ensure that the intra-class variance is equal to 1, as described in the documentation, is it necessary to add a Normalizer after the LinearClassifier, or is this already handled internally by the model itself?
No, this is handled by rescaling the weights of the classifier.
I noticed that the .prm file contains the parameters `NormalizerGains` and `NormalizerOffsets`, but since I do not see them loaded in the Operator, I assume they are being ignored.
These are there in case the Normalizer should be present, but they are not used if it is not. In case the Normalizer is present, the gain should be set to 1 and the offset to 0 (or any value, as it will cancel out in the margin).

Re: Async Mode: Margin

Posted: 29 May 2026, 14:25
by simboe
Did you have a human subject with real EEG, or did you test using SignalGenerator?
What do you mean by "tested it on the same template"?
I meant the same matrix configuration used during training.
Regarding your question about the signal source, I used both options, but I would like to run some additional tests before providing more details.
Thank you for your patience and your help.
Simone

Re: Async Mode: Margin

Posted: 30 May 2026, 12:50
by mellinger
When you use SignalSource with the DC offset modulated by StimulusType, you will get large margins depending on the ratio of DC offset to noise amplitude. This is normal and reflects the fact that there is a lot of evidence in this artificial signal.

Re: Async Mode: Margin

Posted: 04 Jun 2026, 10:22
by simboe
Hi,

I managed to retrieve an old application log containing data from a real EEG session. Since after recompiling BCI2000 the application logs the classifier information as the margin, I was able to verify that the same issue occurs with real EEG data as well.
In that case I used 8 sequences and accumulated evidence set to 0, and I obtained margins of around 3000.

As soon as possible, I will run some additional tests using real EEG data to investigate this further.

In the meantime, I would like to point out something I noticed in BCI2000Analysis. When I train using the same .dat files, I obtain exactly the same classifier matrix regardless of whether the "Normalize by Within-Class Variance" option is enabled or disabled. The only parameters that change are the NormalizerGains and NormalizerOffsets values.

Could you let me know whether you observe the same behavior on your side, and whether this is expected?

Thank you very much.
Best regards,
Simone

Re: Async Mode: Margin

Posted: 04 Jun 2026, 14:46
by mellinger
In the meantime, I would like to point out something I noticed in BCI2000Analysis. When I train using the same .dat files, I obtain exactly the same classifier matrix regardless of whether the "Normalize by Within-Class Variance" option is enabled or disabled. The only parameters that change are the NormalizerGains and NormalizerOffsets values.
Thanks a lot for your helpful observation. I could reproduce it on my side.
I will come back to you once it's fixed.

-Jürgen

Re: Async Mode: Margin

Posted: 04 Jun 2026, 16:05
by mellinger
I think I fixed the issue now. Please give it a try.

-Jürgen

Re: Async Mode: Margin

Posted: 09 Jun 2026, 05:28
by simboe
Dear Jürgen,

I have carried out a quick test with real EEG data and everything is now working as expected — the issue has been fully resolved.

Thank you so much for your support.

Best regards,
Simone