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:
- Data Flow: Handling input and output between Nodes
- Lifecycle Management: Controlling startup, processing, and shutdown
- Configuration: Customizing behavior through parameters
- 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:
- Creation: The Node is instantiated with its configuration
- Building: Resources are allocated and initialized (
onBuild
) - Starting: Data processing begins (
onStart
) - Processing: Data flows through the Node (
onData
) - Stopping: Data processing halts (
onStop
) - 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:
- Set up your development environment
- Create a basic processing Node
- Develop specialized EEG processing Nodes
- Create sink Nodes for data output
Let's start by setting up your development environment for creating custom Nodes.