Skip to main content

Introduction to Custom Nodes

Developing custom Nodes for the Instinct ecosystem allows you to extend its capabilities with specialized EEG signal processing modules. This tutorial introduces you to the Node architecture and provides an overview of how Nodes function within the Instinct streams processing framework.

What are Nodes in Instinct?

Nodes are self-contained processing units that handle data as it flows through the Instinct ecosystem. They form the building blocks of your EEG processing pipelines, with each Node responsible for a specific processing task.

In the context of EEG analysis, Nodes can:

  • Acquire raw EEG signals from hardware
  • Filter signals to remove artifacts and noise
  • Extract features from EEG data
  • Apply transformations (e.g., FFT for spectral analysis)
  • Classify brain states using machine learning
  • Visualize results or export data
  • And much more

Node Architecture

Nodes in the Instinct ecosystem are built on a robust architecture that manages:

  1. Data Flow: Handling input and output between Nodes
  2. Lifecycle Management: Controlling startup, processing, and shutdown
  3. Configuration: Customizing behavior through parameters
  4. Messaging: Communicating with other components using ZeroMQ

The base implementation is provided by the @nexstem/wisdom-js package, which exports a Node class that your custom Nodes will extend.

Node Types

Nodes generally fall into three categories:

Source Nodes

These generate or acquire data, such as:

  • EEG signal acquisition from headsets
  • File readers for offline data
  • Synthetic signal generators for testing

Processing Nodes

These transform data, such as:

  • Filters (bandpass, notch, etc.)
  • Feature extractors (e.g., calculating band power)
  • Signal transformers (FFT, wavelet transforms)
  • Artifact removal (EOG, EMG rejection)

Sink Nodes

These consume data for output, such as:

  • Visualization components
  • File writers for data storage
  • Network transmitters
  • Machine learning model inputs

Node Lifecycle

Nodes follow a specific lifecycle managed by the Instinct stream engine:

  1. Creation: The Node is instantiated with its configuration
  2. Building: Resources are allocated and initialized (onBuild)
  3. Starting: Data processing begins (onStart)
  4. Processing: Data flows through the Node (onData)
  5. Stopping: Data processing halts (onStop)
  6. Shutdown: Resources are released (onShutdown)

Understanding this lifecycle is crucial when developing custom Nodes to ensure proper resource management and data handling.

Why Create Custom Nodes?

For EEG researchers, custom Nodes enable:

  • Implementation of specialized processing algorithms
  • Integration with existing research code
  • Development of novel analysis techniques
  • Processing optimization for specific research needs
  • Real-time feedback and neurofeedback applications

Prerequisites

Before creating custom Nodes, you should have:

  • Basic understanding of TypeScript/JavaScript
  • Familiarity with EEG data processing concepts
  • Node.js installed on your development machine
  • Understanding of asynchronous programming

Next Steps

In the following tutorials, you'll learn how to:

  1. Set up your development environment
  2. Create a basic processing Node
  3. Develop specialized EEG processing Nodes
  4. Create sink Nodes for data output

Let's start by setting up your development environment for creating custom Nodes.