From 3fc6ad7cb0658ec1a68bf6bcb430942f1d698f2a Mon Sep 17 00:00:00 2001 From: Javier Gonzalez <3814755+javiergs@users.noreply.github.com> Date: Fri, 30 Oct 2026 21:30:02 -0700 Subject: [PATCH 1/6] docs: add docs/student-quick-start.md --- docs/student-quick-start.md | 70 +++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 docs/student-quick-start.md diff --git a/docs/student-quick-start.md b/docs/student-quick-start.md new file mode 100644 index 0000000..5213df5 --- /dev/null +++ b/docs/student-quick-start.md @@ -0,0 +1,70 @@ +# Student quick start + +This guide uses the published **Cortex4J 0.2.0** Java library. You do not need the library's implementation source. + +## 1. Prepare Java and Maven + +Install JDK 21 and Maven 3.9 or newer. From a terminal, check: + +```bash +java -version +mvn -version +``` + +Both should report Java 21. Clone or download this repository, then open a terminal in its root directory. + +## 2. Prepare EMOTIV + +1. Create an EMOTIV account, install **EMOTIV Launcher**, and sign in. +2. Connect a supported headset, or set up **Virtual Brainwear** if available to your account. +3. Register a Cortex application to obtain its **Client ID** and **Client Secret**. +4. Approve application access in Launcher when prompted. + +Your Cortex application credentials are **not** your EMOTIV account password. Streams and Virtual Brainwear availability depend on your headset, account, and licensing. + +See the [EMOTIV application registration instructions](https://www.emotiv.com/knowledge-base/how-to-register-your-app-id-with-cortex-sdk-for-development). + +## 3. Configure credentials + +For a local experiment, copy `src/main/resources/cortex4j.properties.example` to `src/main/resources/cortex4j.properties` and replace the placeholders with your application credentials. + +The real properties file is ignored by Git **and excluded from Maven build resources**. Do not commit or share it. + +Alternatively, set both `CORTEX_CLIENT_ID` and `CORTEX_CLIENT_SECRET` environment variables. These take precedence over the properties file. Prefer environment variables for independent applications and CI. Never print secrets or paste them into issues. + +## 4. Run the first example + +With Launcher running and a headset or Virtual Brainwear available: + +```bash +mvn clean verify +mvn exec:java -Dexec.mainClass=com.javiergs.examples.DeviceExample +``` + +`DeviceExample` connects, reports the headset ID, listens for device/status samples for about **30 seconds**, and closes the connection. A successful Maven build **does not** prove headset connectivity. + +## 5. Try another stream + +If your account permits performance metrics: + +```bash +mvn exec:java -Dexec.mainClass=com.javiergs.examples.MetricsExample +``` + +Other examples cover EEG, motion, and band power. See the [examples guide](examples.md) for commands and limitations. + +## 6. Create your own project + +In a separate Java 21 Maven project, add: + +```xml + + com.javiergs + cortex4j + 0.2.0 + +``` + +Start with `CortexClient.connect()`, register a `CortexListener` for a stream, subscribe, and close the client when finished. Use the examples here as references, not as a required dependency. + +If something fails, see [README troubleshooting](../README.md#troubleshooting). Never include credentials or identifiable participant data in a bug report. From 1d532c7bbebb824bec65d2628a9f69681b417be6 Mon Sep 17 00:00:00 2001 From: Javier Gonzalez <3814755+javiergs@users.noreply.github.com> Date: Fri, 30 Oct 2026 21:30:05 -0700 Subject: [PATCH 2/6] docs: add docs/examples.md --- docs/examples.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 docs/examples.md diff --git a/docs/examples.md b/docs/examples.md new file mode 100644 index 0000000..066b9fe --- /dev/null +++ b/docs/examples.md @@ -0,0 +1,42 @@ +# Runnable Cortex4J examples + +All examples use **Java 21**, the public Maven Central dependency **com.javiergs:cortex4j:0.2.0**, and EMOTIV Launcher. Run commands from the repository root after following the [student quick start](student-quick-start.md). + +First verify the build: + +```bash +mvn clean verify +``` + +| Example | Stream | What you observe | Important prerequisite | +| --- | --- | --- | --- | +| `DeviceExample` | `dev` | Headset ID, timestamps, device/status samples | Connected headset or available Virtual Brainwear | +| `MetricsExample` | `met` | Named metrics for recognized layouts; otherwise raw values | Performance metrics stream entitlement | +| `EegExample` | `eeg` | Timestamped, ordered raw EEG values | EEG-capable device and any required licensing | +| `MotionExample` | `mot` | Timestamped motion values | Supported motion stream | +| `BandPowerExample` | `pow` | Timestamped band-power values | Supported band-power stream | + +## Run an example + +```bash +mvn exec:java -Dexec.mainClass=com.javiergs.examples.DeviceExample +mvn exec:java -Dexec.mainClass=com.javiergs.examples.MetricsExample +mvn exec:java -Dexec.mainClass=com.javiergs.examples.EegExample +mvn exec:java -Dexec.mainClass=com.javiergs.examples.MotionExample +mvn exec:java -Dexec.mainClass=com.javiergs.examples.BandPowerExample +``` + +Run **one command at a time**. Each example subscribes for about **30 seconds**, prints received samples, and closes the client. Actual samples depend on Launcher, the headset, stream availability, and permissions. Output may be absent if no data arrives. + +## Understanding the output + +- `DeviceExample` is the recommended first connectivity check. +- `MetricsExample` recognizes the documented 13-value Insight/EPOC and 4-value MN8 layouts. Cortex4J 0.2.0 does **not** expose subscription `cols` metadata, so unknown layouts are printed without guessed labels. +- `EegExample`, `MotionExample`, and `BandPowerExample` print **ordered raw values**. Do not assume a fixed array index always corresponds to a specific sensor or band. +- A passing `mvn clean verify` checks the Java project and published dependency; it does **not** test a real headset or account entitlements. + +For stream-specific column definitions, consult the [EMOTIV sample format documentation](https://emotiv.gitbook.io/cortex-api/data-subscription/data-sample-object). + +## Student exercises + +Try displaying only timestamps and sample counts, comparing two permitted streams, or designing a listener that computes a rolling summary. Do not commit secrets, headset identifiers tied to participants, or identifiable recordings. From 0be75352387bb5d5621ebb12584f88eb97c064a4 Mon Sep 17 00:00:00 2001 From: Javier Gonzalez <3814755+javiergs@users.noreply.github.com> Date: Fri, 30 Oct 2026 21:30:11 -0700 Subject: [PATCH 3/6] chore: improve pom.xml --- pom.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pom.xml b/pom.xml index 33abfae..02afbbf 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,17 @@ maven-compiler-plugin 3.16.0 + + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + cortex4j.properties + + + org.codehaus.mojo exec-maven-plugin From 274f84cfe8431291ec53cbd9434fd6d492e786ca Mon Sep 17 00:00:00 2001 From: Javier Gonzalez <3814755+javiergs@users.noreply.github.com> Date: Fri, 30 Oct 2026 21:30:13 -0700 Subject: [PATCH 4/6] chore: improve .github/workflows/verify-central.yml --- .github/workflows/verify-central.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/verify-central.yml b/.github/workflows/verify-central.yml index f12e6ea..c5d684d 100644 --- a/.github/workflows/verify-central.yml +++ b/.github/workflows/verify-central.yml @@ -6,6 +6,9 @@ on: branches: [main] workflow_dispatch: +permissions: + contents: read + jobs: resolve: runs-on: ubuntu-latest From 8e0378bdd1314a0bd555d25f908a2ef3e7ab3e69 Mon Sep 17 00:00:00 2001 From: Javier Gonzalez <3814755+javiergs@users.noreply.github.com> Date: Fri, 30 Oct 2026 21:30:15 -0700 Subject: [PATCH 5/6] chore: improve docs/student-quick-start.md --- docs/student-quick-start.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/student-quick-start.md b/docs/student-quick-start.md index 5213df5..acfa2ef 100644 --- a/docs/student-quick-start.md +++ b/docs/student-quick-start.md @@ -28,7 +28,7 @@ See the [EMOTIV application registration instructions](https://www.emotiv.com/kn For a local experiment, copy `src/main/resources/cortex4j.properties.example` to `src/main/resources/cortex4j.properties` and replace the placeholders with your application credentials. -The real properties file is ignored by Git **and excluded from Maven build resources**. Do not commit or share it. +The real properties file is ignored by Git and **excluded from packaged JARs**. Maven may still copy it into local `target/classes` for running examples; never share your build output. Do not commit or share it. Alternatively, set both `CORTEX_CLIENT_ID` and `CORTEX_CLIENT_SECRET` environment variables. These take precedence over the properties file. Prefer environment variables for independent applications and CI. Never print secrets or paste them into issues. From 27a6d3d6382276829a878663c024d490d2c02e38 Mon Sep 17 00:00:00 2001 From: Javier Gonzalez <3814755+javiergs@users.noreply.github.com> Date: Fri, 30 Oct 2026 21:30:22 -0700 Subject: [PATCH 6/6] docs: link student guides and clarify build and credential safety --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5a43f2b..f06912d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Getting Started with CORTEX4J - ![Java 21+](https://img.shields.io/badge/Java-21%2B-blue) ![Version 0.2.0](https://img.shields.io/badge/version-0.2.0-green) [![Java CI](https://github.com/javiergs/cortex4j-getting-started/actions/workflows/java-ci.yml/badge.svg)](https://github.com/javiergs/cortex4j-getting-started/actions/workflows/java-ci.yml) @@ -11,6 +10,8 @@ Learn to read EMOTIV headset data using **Cortex4J 0.2.0**, Java 21, and Maven. ## Quick start +For a guided first experiment, see the [Student Quick Start](docs/student-quick-start.md). For commands, prerequisites, and expected output for every program, see [Runnable Examples](docs/examples.md). + 1. Install **JDK 21** and **Maven 3.9+**. Check with `java -version` and `mvn -version`; both should use Java 21. 2. Follow [Setup](#setup) to configure EMOTIV Launcher, a headset or Virtual Brainwear, and your Cortex application credentials. 3. In this repository's root folder, run: @@ -52,7 +53,6 @@ This Getting Started repository already includes the dependency in its `pom.xml` **Do not commit your client secret.** Register your own Cortex application, subject to EMOTIV's account and licensing requirements. - Your **Client ID and Client Secret identify your registered Cortex application**. They are **not** your EMOTIV account email address and password. Obtain them by following the application registration instructions in Setup step 3. For these Getting Started examples, store your Cortex application credentials in a local properties file. @@ -67,7 +67,7 @@ cortex.client.secret=YOUR_CLIENT_SECRET 3. Save the file and run an example. `CortexClient.connect()` automatically reads these credentials; no changes to the Java examples are necessary. -The real `cortex4j.properties` is excluded by `.gitignore`. **Never commit credentials or distribute a JAR containing them.** +The real `cortex4j.properties` is excluded by `.gitignore` and excluded from JAR packaging by Maven. Maven can still copy it into local `target/classes` for running examples, so **never commit credentials or share build output containing them**. **Optional:** Instead of a properties file, you can set `CORTEX_CLIENT_ID` and `CORTEX_CLIENT_SECRET` environment variables. If both are set, they take precedence over the properties file. @@ -81,7 +81,6 @@ mvn clean compile This verifies the Java dependency setup but does not test headset access. Start EMOTIV Launcher, sign in, connect your headset or Virtual Brainwear, and approve the application before running an example. - Device-status stream (recommended first test): ```bash @@ -104,11 +103,14 @@ mvn compile exec:java -Dexec.mainClass=com.javiergs.examples.BandPowerExample These examples print raw ordered channel values. Sensor names and band-power channels are headset/stream-dependent; do not assume array indexes represent specific electrodes or frequency bands. The EEG stream may require additional licensing. All three require EMOTIV Launcher and a connected headset or Virtual Brainwear. - The metrics example uses the documented channel ordering for known layouts; Cortex4J does not expose the `subscribe` response's `cols` metadata yet. For unknown layouts, the example prints raw values instead of guessing labels. Verify the reported labels against your headset and Cortex version. See [EMOTIV's sample format documentation](https://emotiv.gitbook.io/cortex-api/data-subscription/data-sample-object). Each program connects using `CortexClient`, registers a `CortexListener`, subscribes to a stream, prints samples for 30 seconds, and closes automatically. The example code is in `src/main/java/com/javiergs/examples/`. +## Build checks + +The public **Java CI** workflow runs `mvn clean verify` with Java 21. The separate **Verify Maven Central dependency** workflow compiles with an isolated empty Maven cache to check that the published Cortex4J dependency resolves independently. Neither workflow requires EMOTIV credentials or tests headset connectivity. + ## Troubleshooting - No headset: connect hardware or enable Virtual Brainwear.