facebookresearch / labgraph

LabGraph is a Python framework for rapidly prototyping experimental systems for real-time streaming applications. It is particularly well-suited to real-time neuroscience, physiology and psychology experiments.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Data Generation and Parser from OpenGPT

jfResearchEng opened this issue Β· comments

commented

πŸš€ Feature

Generate data set for training using opengpt. And also create a parser to separate the coded from the context.

The starting points would be filtering techniques: e.g. Kalman Filter and IIR filter.

Convert:

An infinite impulse response (IIR) filter is a type of digital filter that can be used to implement a variety of different frequency response characteristics. It is characterized by its recursive structure, which allows it to have an impulse response that extends indefinitely into the past. Here is some sample code that demonstrates how to implement an IIR filter using a direct form II structure:

import numpy as np

class IIRFilter:
    def __init__(self, b, a):
        self.b = b
        self.a = a
        self.z = np.zeros(max(len(b), len(a)))

    def filter(self, x):
        y = np.zeros_like(x)
        for n in range(len(x)):
            y[n] = self.b[0] * x[n]
            for m in range(1, len(self.b)):
                if n-m >= 0:
                    y[n] += self.b[m] * x[n-m]
            for m in range(1, len(self.a)):
                if n-m >= 0:
                    y[n] -= self.a[m] * y[n-m]
            self.z[0] = x[n]
            self.z[1:] = self.z[:-1]
        return y

to
result[0] = "An infinite impulse response (IIR) filter is a type of digital filter that can be used to implement a variety of different frequency response characteristics. It is characterized by its recursive structure, which allows it to have an impulse response that extends indefinitely into the past. Here is some sample code that demonstrates how to implement an IIR filter using a direct form II structure:"

result[1] =

import numpy as np

class IIRFilter:
    def __init__(self, b, a):
        self.b = b
        self.a = a
        self.z = np.zeros(max(len(b), len(a)))

    def filter(self, x):
        y = np.zeros_like(x)
        for n in range(len(x)):
            y[n] = self.b[0] * x[n]
            for m in range(1, len(self.b)):
                if n-m >= 0:
                    y[n] += self.b[m] * x[n-m]
            for m in range(1, len(self.a)):
                if n-m >= 0:
                    y[n] -= self.a[m] * y[n-m]
            self.z[0] = x[n]
            self.z[1:] = self.z[:-1]
        return y

The example above is a transformer node.

For this issue, we would like to prioritize the following nodes (priority high to low):

  1. Transformer Node (e.g. IIRFilter)
  2. Source Node (e.g. Microphone integration)
  3. UI (e.g. Matplotlib-based plotting)

Additional context

  1. The code should be added at folder is https://github.com/facebookresearch/labgraph/tree/main/extensions/lgpilot
  2. Create setup.py and README.md, where example can be found at: https://github.com/facebookresearch/labgraph/tree/main/extensions/labgraph_viz
  3. Add github action support, reference: https://github.com/facebookresearch/labgraph/actions/workflows/main.yml
  4. Add proper license header.