1.1.1 • Published 8 months ago
@maidenlabs/finalspark-ts v1.1.1
FinalSpark TS
This is a minimal TypeScript library that provides an interface to handle live MEA data.
Installation
You can install the library using npm:
npm install @maidenlabs/finalspark-tsUsage
To use the library, import the LiveMEA class from the library:
import { LiveMEA } from '@maidenlabs/finalspark-ts';
// Create instance
const liveMEA = new LiveMEA();
// Record a single sample of MEA 1
liveMEA.recordSample(1)
.then((data) => {
console.log(data); // Contains timestamp and 32x4096 electrode data array
});
// Record multiple samples of MEA 1
liveMEA.recordNSamples(1, 10)
.then((samples) => {
console.log(samples); // Array of samples, each with timestamp and electrode data
});API
LiveMEA
The main class for interacting with live MEA data from the FinalSpark service.
Methods
recordSample(meaId?: number): Promise<LiveData>
Records a single sample of live MEA data.
meaId(optional): The MEA ID to use (1-4). Defaults to 1.- Returns: Promise resolving to
LiveDatacontaining:timestamp: Date object when the sample was recordeddata: 32x4096 array where each row represents one electrode's samples
recordNSamples(meaId?: number, n?: number): Promise<LiveData[]>
Records multiple samples of live MEA data.
meaId(optional): The MEA ID to use (1-4). Defaults to 1.n(optional): Number of samples to record. Defaults to 10.- Returns: Promise resolving to array of
LiveDataobjects
Types
interface LiveData {
timestamp: Date;
data: number[][]; // 32x4096 array
}Error Handling
The methods will throw errors in these cases:
- Invalid MEA ID (must be 1-4)
- Connection failures
- Server timeout
License
This project is licensed under the MIT License.