Repository navigation
Cor 6539: update training and set get mental command info example - #248
Open
tungntEmotiv wants to merge 4 commits into
Open
tungntEmotiv wants to merge 4 commits into
tungntEmotiv wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Training waits can falsely report completion by consuming stale or wrong-detection events, and reading trained-profile configuration can fail in MATLAB because it transposes a struct array.
6 open issues
Convert the decoded struct array before transposing · New Exclude stale training outcomes from waited starts · New Match the requested detection when waiting for events · New Treat neutral as active independently of the action list · New Retry detection-info initialization for loaded profiles · New Train and accept neutral before starting push training · New
What changed in this PR
Adds mental-command training and configuration to the Octave SDK, with a keyboard-driven example for training actions and displaying live commands.
Changes:
- Adds public APIs for profile management, training, and mental-command settings.
- Supports
systraining events andcomsamples with action names and power values. - Adds an interactive training example and documents the public API workflow.
| File | Description |
|---|---|
octave/README.md |
Documents training, profiles, and live command data. |
octave/internal/CortexTraining.m |
Sends training requests, waits for outcomes, and saves accepted training. |
octave/internal/CortexStreamParser.m |
Distinguishes shared-session streams and extracts action names. |
octave/internal/CortexProfile.m |
Manages profiles and loads detection metadata. |
octave/internal/CortexMentalCommandConfiguration.m |
Reads and updates active actions and sensitivities. |
octave/internal/CortexManager.m |
Manages the new internal service instances. |
octave/internal/CortexHeadset.m |
Collects training events and buffers command samples. |
octave/internal/CortexDataBuffer.m |
Stores action names alongside numeric samples. |
octave/internal/CortexContext.m |
Tracks profile state, detection metadata, and training events. |
octave/functions/cortexTraining.m |
Exposes training operations and optional waiting. |
octave/functions/cortexSubscribe.m |
Allows com and sys subscriptions. |
octave/functions/cortexProfile.m |
Exposes profile load, save, and unload operations. |
octave/functions/cortexMentalCommandInfo.m |
Exposes configuration reads and saved updates. |
octave/functions/cortexGetData.m |
Returns mental-command action names as a fourth output. |
octave/functions/cortexDisconnect.m |
Attempts profile unloading and clears profile state. |
octave/functions/cortexConnect.m |
Initializes public profile-state fields. |
octave/examples/mentalCommandTraining.m |
Demonstrates keyboard training, sensitivity settings, and live display. |
Review effort: Balanced
| if iscell(value) | ||
| items = value(:)'; | ||
| elseif isstruct(value) | ||
| items = num2cell(value(:)'); |
| error('CortexTraining:noSysStream', 'Subscribe to the sys stream to wait for training events.'); | ||
| end | ||
|
|
||
| obj.context.trainingEvents = {}; |
| obj.headset.update(0.25); | ||
| events = obj.context.trainingEvents; | ||
| for index = seen + 1:numel(events) | ||
| if ~isempty(regexp(events{index}.event, pattern, 'once')) |
| value = sensitivity(position); | ||
| end | ||
| trainedActions{index} = struct('action', name, ... | ||
| 'active', any(strcmp(active, name)), ... |
Comment on lines
+39
to
+40
| result = CortexProfile.makeResult(profileName, '', true, false, true); | ||
| return; |
| cortex = cortexSession(cortex, 'INSIGHT-A1B2C3D4'); | ||
| [cortex, profile] = cortexProfile(cortex, 'load', 'my-profile'); % creates it when missing | ||
| cortex = cortexSubscribe(cortex, {'sys', 'com'}); | ||
| started = cortexTraining(cortex, 'mentalCommand', 'push', 'start', 'wait', 30); |
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.



The PR include:
Please help to review. Thanks

Please see the image for proof