Setting Up Your Development Environment
Before you start creating custom Nodes for the Instinct ecosystem, you need to set up your development environment. This tutorial will guide you through the process of setting up the necessary tools and dependencies.
Prerequisites
- Node.js (version 14 or later)
- npm or yarn package manager
- Basic knowledge of TypeScript
- Code editor (VS Code recommended)
Project Initialization
Let's start by creating a new project for your custom Node:
# Create a directory for your project
mkdir my-instinct-node
cd my-instinct-node
# Initialize a new npm project
npm init -y
# Install TypeScript and other dependencies
npm install --save-dev typescript @types/node ts-node
Installing the Wisdom JS Package
The core functionality for creating Nodes is provided by the @nexstem/wisdom-js
package. Install it with:
npm install --save @nexstem/wisdom-js
TypeScript Configuration
Create a tsconfig.json
file in your project root with the following configuration:
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"declaration": true,
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.test.ts"]
}
Project Structure
Create a basic project structure as follows:
my-instinct-node/
├── package.json
├── tsconfig.json
├── src/
│ ├── index.ts
│ └── my-node.ts
└── README.md
Example index.ts
Create an index.ts
file in the src
directory to export your Node:
// src/index.ts
export * from './my-node';
Adding Scripts to package.json
Update your package.json
to include build scripts:
{
"scripts": {
"build": "tsc",
"start": "ts-node src/index.ts",
"dev": "ts-node-dev --respawn src/index.ts"
}
}
Testing Your Setup
To verify your setup, create a simple test Node:
// src/my-node.ts
import { Node } from '@nexstem/wisdom-js';
class TestNode extends Node {
async onBuild(): Promise<void> {
console.log('TestNode built successfully!');
}
onData(inletNumber: number, packet: any[]): void {
console.log(`Received data on inlet ${inletNumber}:`, packet);
}
async onStart(): Promise<void> {
console.log('TestNode started!');
}
async onStop(): Promise<void> {
console.log('TestNode stopped!');
}
async onShutdown(): Promise<void> {
console.log('TestNode shut down!');
}
onSignal(signal: string, packet: any[]): void {
console.log(`Received signal: ${signal}`, packet);
}
}
// This will be instantiated when the file is executed
// Don't include this when writing a library
if (require.main === module) {
new TestNode({
inputs: { min: 1 },
outputs: { min: 1 },
});
}
export default TestNode;
Integration with Instinct
When developing Nodes for the Instinct ecosystem, your Node will be:
- Packaged as a npm module
- Registered with the Instinct Streams Engine
- Made available in the Instinct UI for pipeline construction
The Streams Engine will handle:
- Dynamically loading your Node
- Providing the necessary socket configurations
- Managing the Node's lifecycle
- Routing data between Nodes
Development Workflow for EEG Researchers
As an EEG researcher developing custom Nodes:
- Design: Plan your Node's processing algorithm based on EEG research needs
- Implement: Create the Node using the
@nexstem/wisdom-js
framework - Test: Validate the Node with sample EEG data
- Deploy: Package the Node for use in the Instinct ecosystem
- Use: Incorporate the Node in your EEG processing pipelines
Next Steps
Now that your environment is set up, proceed to the next tutorial to create a basic processing Node for EEG data.