Makeshift Neural Interface
https://psylink.me
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
560 lines
16 KiB
560 lines
16 KiB
options: |
|
parameters: |
|
author: '' |
|
category: '[GRC Hier Blocks]' |
|
cmake_opt: '' |
|
comment: '' |
|
copyright: '' |
|
description: '' |
|
gen_cmake: 'On' |
|
gen_linking: dynamic |
|
generate_options: qt_gui |
|
hier_block_src_path: '.:' |
|
id: plot_signals |
|
max_nouts: '0' |
|
output_language: python |
|
placement: (0,0) |
|
qt_qss_theme: '' |
|
realtime_scheduling: '' |
|
run: 'True' |
|
run_command: '{python} -u {filename}' |
|
run_options: prompt |
|
sizing_mode: fixed |
|
thread_safe_setters: '' |
|
title: Not titled yet |
|
window_size: '' |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [8, 8] |
|
rotation: 0 |
|
state: enabled |
|
|
|
blocks: |
|
- name: offset |
|
id: variable |
|
parameters: |
|
comment: '' |
|
value: '-1' |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [390, 16] |
|
rotation: 0 |
|
state: true |
|
- name: points |
|
id: variable |
|
parameters: |
|
comment: '' |
|
value: 2048*1 |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [284, 16] |
|
rotation: 0 |
|
state: true |
|
- name: samp_rate |
|
id: variable |
|
parameters: |
|
comment: '' |
|
value: '500' |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [188, 17] |
|
rotation: 0 |
|
state: enabled |
|
- name: sample_count |
|
id: variable |
|
parameters: |
|
comment: '' |
|
value: '7' |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [496, 16] |
|
rotation: 0 |
|
state: true |
|
- name: block_BLE_source |
|
id: epy_block |
|
parameters: |
|
_source_code: "# WARNING: DO NOT EDIT \"block_BLE_source.py\" DIRECTLY! IT IS\ |
|
\ AUTOGENERATED BY GNURADIO!\n# INSTEAD, OPEN GNURADIO, DOUBLE-CLICK THE BLOCK,\ |
|
\ AND CLICK ON \"Open in Editor\"!\n\nimport importlib\nimport os.path\nimport\ |
|
\ sys\n\nimport numpy as np\nfrom gnuradio import gr\n\ntry:\n import psylink.bluetooth\n\ |
|
\ import psylink.protocol\nexcept ImportError:\n # NOTE: You may need\ |
|
\ to change this path to where you downloaded psyink to:\n libpath = os.path.expanduser('~/repos/psylink/python')\n\ |
|
\ sys.path.insert(0, libpath)\n import psylink.bluetooth\n import psylink.protocol\n\ |
|
\nDEFAULT_BLE_ADDRESS = 'A6:B7:D0:AE:C2:76'\nEMG_CHANNELS = 8\nSIGNAL_COUNT\ |
|
\ = EMG_CHANNELS + psylink.config.IMU_CHANNELS\n\nclass BLESource(gr.basic_block):\n\ |
|
\ def __init__(self, ble_mac=DEFAULT_BLE_ADDRESS):\n gr.basic_block.__init__(self,\ |
|
\ name='BLE Source', in_sig=[], out_sig=[np.float32] * SIGNAL_COUNT)\n \ |
|
\ self.ble_mac = ble_mac\n self.last_sample_count = 2048 # some large\ |
|
\ conservative value\n self.BLE = None\n self.BLE_decoder = psylink.protocol.BLEDecoder(sample_value_offset=0)\n\ |
|
\ self.actual_channels = SIGNAL_COUNT # will be updated with data from\ |
|
\ device\n\n def general_work(self, input_items, output_items):\n \ |
|
\ count = 0\n pipe = self.BLE.pipe\n limit = len(output_items[0])\ |
|
\ - self.last_sample_count\n while not pipe.empty() and count < limit:\n\ |
|
\ packet = pipe.get()\n data = self.BLE_decoder.decode_packet(packet)\n\ |
|
\ samples = data['samples']\n transposed = np.transpose(samples)\n\ |
|
\ for channel_id in range(min(SIGNAL_COUNT, self.actual_channels)):\n\ |
|
\ channel = output_items[channel_id]\n channel[count:count+len(samples)]\ |
|
\ = transposed[channel_id] / 256\n count += len(samples)\n \ |
|
\ self.last_sample_count = len(samples)\n limit = len(output_items[0])\ |
|
\ - self.last_sample_count\n return count\n\n def start(self):\n \ |
|
\ if self.BLE:\n print(\"Error: Bluetooth Thread already running!\"\ |
|
)\n return False\n\n # Reset state\n importlib.reload(psylink.bluetooth)\n\ |
|
\ importlib.reload(psylink.protocol)\n\n BackendClass = list(psylink.bluetooth.BACKENDS.values())[0]\n\ |
|
\ self.BLE = BackendClass(self.ble_mac)\n self.BLE.connect()\n\ |
|
\ self.actual_channels = self.BLE_decoder.decode_channel_count(self.BLE.read_channels())\n\ |
|
\ self.BLE.thread_start()\n\n return True\n\n def stop(self):\n\ |
|
\ if self.BLE:\n self.BLE.disconnect()\n self.BLE.thread_stop()\n\ |
|
\ self.BLE = None\n return True\n" |
|
affinity: '' |
|
alias: '' |
|
ble_mac: '"2E:A9:71:D7:65:95"' |
|
comment: '' |
|
maxoutbuf: '0' |
|
minoutbuf: '0' |
|
states: |
|
_io_cache: ('BLE Source', 'BLESource', [('ble_mac', "'A6:B7:D0:AE:C2:76'")], [], |
|
[('0', 'float', 1), ('1', 'float', 1), ('2', 'float', 1), ('3', 'float', 1), |
|
('4', 'float', 1), ('5', 'float', 1), ('6', 'float', 1), ('7', 'float', 1), |
|
('8', 'float', 1), ('9', 'float', 1), ('10', 'float', 1), ('11', 'float', 1), |
|
('12', 'float', 1), ('13', 'float', 1)], '', ['ble_mac']) |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [28, 136] |
|
rotation: 0 |
|
state: enabled |
|
- name: block_shift |
|
id: epy_block |
|
parameters: |
|
_source_code: "# WARNING: DO NOT EDIT \"block_shift.py\" DIRECTLY! IT IS AUTOGENERATED\ |
|
\ BY GNURADIO!\n# INSTEAD, OPEN GNURADIO, DOUBLE-CLICK THE BLOCK, AND CLICK\ |
|
\ ON \"Open in Editor\"!\n\n\"\"\"\nKeeps a copy of the last N signals and outputs\ |
|
\ them at a constant rate,\nso that you can use QT GUI sinks in a \"rolling\"\ |
|
\ mode.\n\"\"\"\n\nimport numpy as np\nfrom gnuradio import gr\n\n\nCHANNELS\ |
|
\ = 14\n\n\nclass ShiftBlock(gr.interp_block):\n def __init__(self, number_of_points=1024):\n\ |
|
\ gr.interp_block.__init__(\n self,\n name='Shifting\ |
|
\ Block',\n interp=10 * number_of_points, # a large number to ensure\ |
|
\ that output_items is large enough\n in_sig=[np.float32] * CHANNELS,\n\ |
|
\ out_sig=[np.float32] * CHANNELS,\n )\n self.number_of_points\ |
|
\ = number_of_points\n self.buffer = np.zeros((CHANNELS, self.number_of_points),\ |
|
\ dtype=np.float64)\n\n def work(self, input_items, output_items):\n \ |
|
\ n_inputs = min(self.number_of_points, len(input_items[0]))\n self.buffer\ |
|
\ = np.roll(self.buffer, shift=-n_inputs, axis=1)\n for channel in range(CHANNELS):\n\ |
|
\ self.buffer[channel][-n_inputs:] = input_items[channel][:n_inputs]\n\ |
|
\ output_items[channel][:self.number_of_points] = self.buffer[channel]\n\ |
|
\ self.consume(channel, n_inputs)\n return self.number_of_points\n" |
|
affinity: '' |
|
alias: '' |
|
comment: '' |
|
maxoutbuf: '0' |
|
minoutbuf: '0' |
|
number_of_points: points |
|
states: |
|
_io_cache: ('Shifting Block', 'ShiftBlock', [('number_of_points', '1024')], [('0', |
|
'float', 1), ('1', 'float', 1), ('2', 'float', 1), ('3', 'float', 1), ('4', |
|
'float', 1), ('5', 'float', 1), ('6', 'float', 1), ('7', 'float', 1), ('8', |
|
'float', 1), ('9', 'float', 1), ('10', 'float', 1), ('11', 'float', 1), ('12', |
|
'float', 1), ('13', 'float', 1)], [('0', 'float', 1), ('1', 'float', 1), ('2', |
|
'float', 1), ('3', 'float', 1), ('4', 'float', 1), ('5', 'float', 1), ('6', |
|
'float', 1), ('7', 'float', 1), ('8', 'float', 1), ('9', 'float', 1), ('10', |
|
'float', 1), ('11', 'float', 1), ('12', 'float', 1), ('13', 'float', 1)], '', |
|
['number_of_points']) |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [264, 136] |
|
rotation: 0 |
|
state: enabled |
|
- name: blocks_add_const_vxx_0 |
|
id: blocks_add_const_vxx |
|
parameters: |
|
affinity: '' |
|
alias: '' |
|
comment: '' |
|
const: offset |
|
maxoutbuf: '0' |
|
minoutbuf: '0' |
|
type: float |
|
vlen: '1' |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [537, 119] |
|
rotation: 0 |
|
state: enabled |
|
- name: blocks_add_const_vxx_0_0 |
|
id: blocks_add_const_vxx |
|
parameters: |
|
affinity: '' |
|
alias: '' |
|
comment: '' |
|
const: 2*offset |
|
maxoutbuf: '0' |
|
minoutbuf: '0' |
|
type: float |
|
vlen: '1' |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [537, 169] |
|
rotation: 0 |
|
state: enabled |
|
- name: blocks_add_const_vxx_0_0_0 |
|
id: blocks_add_const_vxx |
|
parameters: |
|
affinity: '' |
|
alias: '' |
|
comment: '' |
|
const: 3*offset |
|
maxoutbuf: '0' |
|
minoutbuf: '0' |
|
type: float |
|
vlen: '1' |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [536, 219] |
|
rotation: 0 |
|
state: enabled |
|
- name: blocks_add_const_vxx_0_0_0_0 |
|
id: blocks_add_const_vxx |
|
parameters: |
|
affinity: '' |
|
alias: '' |
|
comment: '' |
|
const: 4*offset |
|
maxoutbuf: '0' |
|
minoutbuf: '0' |
|
type: float |
|
vlen: '1' |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [536, 270] |
|
rotation: 0 |
|
state: enabled |
|
- name: blocks_add_const_vxx_0_0_0_0_0 |
|
id: blocks_add_const_vxx |
|
parameters: |
|
affinity: '' |
|
alias: '' |
|
comment: '' |
|
const: 5*offset |
|
maxoutbuf: '0' |
|
minoutbuf: '0' |
|
type: float |
|
vlen: '1' |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [536, 320] |
|
rotation: 0 |
|
state: enabled |
|
- name: blocks_add_const_vxx_0_0_0_0_0_0 |
|
id: blocks_add_const_vxx |
|
parameters: |
|
affinity: '' |
|
alias: '' |
|
comment: '' |
|
const: 6*offset |
|
maxoutbuf: '0' |
|
minoutbuf: '0' |
|
type: float |
|
vlen: '1' |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [536, 372] |
|
rotation: 0 |
|
state: enabled |
|
- name: blocks_add_const_vxx_0_0_0_0_0_0_0 |
|
id: blocks_add_const_vxx |
|
parameters: |
|
affinity: '' |
|
alias: '' |
|
comment: '' |
|
const: 7*offset |
|
maxoutbuf: '0' |
|
minoutbuf: '0' |
|
type: float |
|
vlen: '1' |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [534, 424] |
|
rotation: 0 |
|
state: enabled |
|
- name: blocks_null_sink_0 |
|
id: blocks_null_sink |
|
parameters: |
|
affinity: '' |
|
alias: '' |
|
bus_structure_sink: '[[0,],]' |
|
comment: '' |
|
num_inputs: '6' |
|
type: float |
|
vlen: '1' |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [596, 515] |
|
rotation: 0 |
|
state: true |
|
- name: qtgui_time_sink_x_0_0 |
|
id: qtgui_time_sink_x |
|
parameters: |
|
affinity: '' |
|
alias: '' |
|
alpha1: '1.0' |
|
alpha10: '1.0' |
|
alpha2: '1.0' |
|
alpha3: '1.0' |
|
alpha4: '1.0' |
|
alpha5: '1.0' |
|
alpha6: '1.0' |
|
alpha7: '1.0' |
|
alpha8: '1.0' |
|
alpha9: '1.0' |
|
autoscale: 'False' |
|
axislabels: 'True' |
|
color1: blue |
|
color10: dark blue |
|
color2: red |
|
color3: green |
|
color4: black |
|
color5: dark red |
|
color6: dark green |
|
color7: dark blue |
|
color8: dark red |
|
color9: dark green |
|
comment: '' |
|
ctrlpanel: 'False' |
|
entags: 'False' |
|
grid: 'True' |
|
gui_hint: '' |
|
label1: Electrode 1 |
|
label10: Signal 10 |
|
label2: Electrode 2 |
|
label3: Electrode 3 |
|
label4: Electrode 4 |
|
label5: Electrode 5 |
|
label6: Electrode 6 |
|
label7: Electrode 7 |
|
label8: Electrode 8 |
|
label9: Signal 9 |
|
legend: 'True' |
|
marker1: '-1' |
|
marker10: '-1' |
|
marker2: '-1' |
|
marker3: '-1' |
|
marker4: '-1' |
|
marker5: '-1' |
|
marker6: '-1' |
|
marker7: '-1' |
|
marker8: '-1' |
|
marker9: '-1' |
|
name: '""' |
|
nconnections: '8' |
|
size: points |
|
srate: samp_rate |
|
stemplot: 'False' |
|
style1: '1' |
|
style10: '1' |
|
style2: '1' |
|
style3: '1' |
|
style4: '1' |
|
style5: '1' |
|
style6: '1' |
|
style7: '1' |
|
style8: '1' |
|
style9: '1' |
|
tr_chan: '0' |
|
tr_delay: '0' |
|
tr_level: '0.0' |
|
tr_mode: qtgui.TRIG_MODE_FREE |
|
tr_slope: qtgui.TRIG_SLOPE_POS |
|
tr_tag: '""' |
|
type: float |
|
update_time: '0.05' |
|
width1: '1' |
|
width10: '1' |
|
width2: '1' |
|
width3: '1' |
|
width4: '1' |
|
width5: '1' |
|
width6: '1' |
|
width7: '1' |
|
width8: '1' |
|
width9: '1' |
|
ylabel: Amplitude |
|
ymax: '1' |
|
ymin: '-8' |
|
yunit: '""' |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [808, 102] |
|
rotation: 0 |
|
state: enabled |
|
- name: qtgui_time_sink_x_0_0_0 |
|
id: qtgui_time_sink_x |
|
parameters: |
|
affinity: '' |
|
alias: '' |
|
alpha1: '1.0' |
|
alpha10: '1.0' |
|
alpha2: '1.0' |
|
alpha3: '1.0' |
|
alpha4: '1.0' |
|
alpha5: '1.0' |
|
alpha6: '1.0' |
|
alpha7: '1.0' |
|
alpha8: '1.0' |
|
alpha9: '1.0' |
|
autoscale: 'False' |
|
axislabels: 'True' |
|
color1: blue |
|
color10: dark blue |
|
color2: red |
|
color3: green |
|
color4: black |
|
color5: dark red |
|
color6: dark green |
|
color7: dark blue |
|
color8: dark red |
|
color9: dark green |
|
comment: '' |
|
ctrlpanel: 'False' |
|
entags: 'False' |
|
grid: 'True' |
|
gui_hint: '' |
|
label1: Gyroscope X |
|
label10: Signal 10 |
|
label2: Gyroscope Y |
|
label3: Gyroscope Z |
|
label4: Accelerometer X |
|
label5: Accelerometer Y |
|
label6: Accelerometer Z |
|
label7: Ring Finger |
|
label8: Signal 8 |
|
label9: Signal 9 |
|
legend: 'True' |
|
marker1: '-1' |
|
marker10: '-1' |
|
marker2: '-1' |
|
marker3: '-1' |
|
marker4: '-1' |
|
marker5: '-1' |
|
marker6: '-1' |
|
marker7: '-1' |
|
marker8: '-1' |
|
marker9: '-1' |
|
name: '""' |
|
nconnections: '6' |
|
size: points |
|
srate: samp_rate |
|
stemplot: 'False' |
|
style1: '1' |
|
style10: '1' |
|
style2: '1' |
|
style3: '1' |
|
style4: '1' |
|
style5: '1' |
|
style6: '1' |
|
style7: '1' |
|
style8: '1' |
|
style9: '1' |
|
tr_chan: '0' |
|
tr_delay: '0' |
|
tr_level: '0.0' |
|
tr_mode: qtgui.TRIG_MODE_FREE |
|
tr_slope: qtgui.TRIG_SLOPE_POS |
|
tr_tag: '""' |
|
type: float |
|
update_time: '0.05' |
|
width1: '1' |
|
width10: '1' |
|
width2: '1' |
|
width3: '1' |
|
width4: '1' |
|
width5: '1' |
|
width6: '1' |
|
width7: '1' |
|
width8: '1' |
|
width9: '1' |
|
ylabel: Amplitude |
|
ymax: '1.2' |
|
ymin: '-0.2' |
|
yunit: '""' |
|
states: |
|
bus_sink: false |
|
bus_source: false |
|
bus_structure: null |
|
coordinate: [843, 455] |
|
rotation: 0 |
|
state: disabled |
|
|
|
connections: |
|
- [block_BLE_source, '0', block_shift, '0'] |
|
- [block_BLE_source, '1', block_shift, '1'] |
|
- [block_BLE_source, '10', block_shift, '10'] |
|
- [block_BLE_source, '11', block_shift, '11'] |
|
- [block_BLE_source, '12', block_shift, '12'] |
|
- [block_BLE_source, '13', block_shift, '13'] |
|
- [block_BLE_source, '2', block_shift, '2'] |
|
- [block_BLE_source, '3', block_shift, '3'] |
|
- [block_BLE_source, '4', block_shift, '4'] |
|
- [block_BLE_source, '5', block_shift, '5'] |
|
- [block_BLE_source, '6', block_shift, '6'] |
|
- [block_BLE_source, '7', block_shift, '7'] |
|
- [block_BLE_source, '8', block_shift, '8'] |
|
- [block_BLE_source, '9', block_shift, '9'] |
|
- [block_shift, '0', qtgui_time_sink_x_0_0, '0'] |
|
- [block_shift, '1', blocks_add_const_vxx_0, '0'] |
|
- [block_shift, '10', blocks_null_sink_0, '2'] |
|
- [block_shift, '10', qtgui_time_sink_x_0_0_0, '2'] |
|
- [block_shift, '11', blocks_null_sink_0, '3'] |
|
- [block_shift, '11', qtgui_time_sink_x_0_0_0, '3'] |
|
- [block_shift, '12', blocks_null_sink_0, '4'] |
|
- [block_shift, '12', qtgui_time_sink_x_0_0_0, '4'] |
|
- [block_shift, '13', blocks_null_sink_0, '5'] |
|
- [block_shift, '13', qtgui_time_sink_x_0_0_0, '5'] |
|
- [block_shift, '2', blocks_add_const_vxx_0_0, '0'] |
|
- [block_shift, '3', blocks_add_const_vxx_0_0_0, '0'] |
|
- [block_shift, '4', blocks_add_const_vxx_0_0_0_0, '0'] |
|
- [block_shift, '5', blocks_add_const_vxx_0_0_0_0_0, '0'] |
|
- [block_shift, '6', blocks_add_const_vxx_0_0_0_0_0_0, '0'] |
|
- [block_shift, '7', blocks_add_const_vxx_0_0_0_0_0_0_0, '0'] |
|
- [block_shift, '8', blocks_null_sink_0, '0'] |
|
- [block_shift, '8', qtgui_time_sink_x_0_0_0, '0'] |
|
- [block_shift, '9', blocks_null_sink_0, '1'] |
|
- [block_shift, '9', qtgui_time_sink_x_0_0_0, '1'] |
|
- [blocks_add_const_vxx_0, '0', qtgui_time_sink_x_0_0, '1'] |
|
- [blocks_add_const_vxx_0_0, '0', qtgui_time_sink_x_0_0, '2'] |
|
- [blocks_add_const_vxx_0_0_0, '0', qtgui_time_sink_x_0_0, '3'] |
|
- [blocks_add_const_vxx_0_0_0_0, '0', qtgui_time_sink_x_0_0, '4'] |
|
- [blocks_add_const_vxx_0_0_0_0_0, '0', qtgui_time_sink_x_0_0, '5'] |
|
- [blocks_add_const_vxx_0_0_0_0_0_0, '0', qtgui_time_sink_x_0_0, '6'] |
|
- [blocks_add_const_vxx_0_0_0_0_0_0_0, '0', qtgui_time_sink_x_0_0, '7'] |
|
|
|
metadata: |
|
file_format: 1
|
|
|