Comparar commits
36 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| d96fbabef8 | |||
| ed260da6ee | |||
| 4cd9a641ce | |||
| 9601ff89a1 | |||
| 2942d8a3d0 | |||
| b3f41b00de | |||
| 8b7e60ca35 | |||
| 7661dad72e | |||
| cc3eaf834b | |||
| 8351474fbc | |||
| 005950b173 | |||
| 847c1ff511 | |||
| 44ed5c8fa5 | |||
| 44f7a035c8 | |||
| ef761dd32b | |||
| c2bad61f92 | |||
| 74c8fb1a68 | |||
| 36986b66a6 | |||
| 98ebbd83fd | |||
| 118b480690 | |||
| e3e9974888 | |||
| 0c237e0116 | |||
| bd534b3216 | |||
| 7393c0603b | |||
| 17ef476a32 | |||
| ef5857e3a2 | |||
| 92f27fb400 | |||
| 1e4401c68b | |||
| 64460c3fe6 | |||
| 4de6d83bf4 | |||
| efe6fe2829 | |||
| 7810048145 | |||
| 77d62d797f | |||
| a0fc9925d9 | |||
| b1fa763845 | |||
| 0329ea5703 |
@@ -0,0 +1,3 @@
|
||||
Language: JavaScript
|
||||
BasedOnStyle: Google
|
||||
ColumnLimit: 100
|
||||
@@ -0,0 +1,14 @@
|
||||
# http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
max_line_length = 0
|
||||
trim_trailing_whitespace = false
|
||||
+28
-3
@@ -1,3 +1,28 @@
|
||||
.idea
|
||||
node_modules
|
||||
npm-debug.log
|
||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# compiled output
|
||||
/dist
|
||||
/tmp
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/bower_components
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
|
||||
# misc
|
||||
/.sass-cache
|
||||
/connect.lock
|
||||
/coverage/*
|
||||
/libpeerconnection.log
|
||||
npm-debug.log
|
||||
testem.log
|
||||
/typings
|
||||
|
||||
# e2e
|
||||
/e2e/*.js
|
||||
/e2e/*.map
|
||||
|
||||
#System Files
|
||||
.DS_Store
|
||||
+16
-4
@@ -2,7 +2,7 @@
|
||||
|
||||

|
||||
|
||||
A fullstack javascript app for capturing and visualizing OpenBCI EEG data
|
||||
A fullstack JavaScript app for reading and visualizing OpenBCI EEG data.
|
||||
|
||||
This project is under development, this is just a first draft.
|
||||
|
||||
@@ -12,18 +12,30 @@ This project is under development, this is just a first draft.
|
||||
* Turn on OpenBCI board
|
||||
|
||||
```bash
|
||||
npm install -g angular-cli concurrently
|
||||
npm install
|
||||
node visualizer
|
||||
npm run visualize
|
||||
```
|
||||
|
||||
* Go to: http://localhost:3060
|
||||
* Go to: http://localhost:4200
|
||||
|
||||
## Simulating data
|
||||
|
||||
```bash
|
||||
node visualizer simulate
|
||||
npm run simulate
|
||||
```
|
||||
|
||||
## Technologies
|
||||
|
||||
* Node.js
|
||||
* Angular 2
|
||||
* Socket.io
|
||||
* Data Visualization
|
||||
- Plotly.js
|
||||
- Chart.js
|
||||
- Smoothie
|
||||
|
||||
|
||||
## Support
|
||||
|
||||
Pull requests are welcomed!
|
||||
|
||||
externo
+24
@@ -0,0 +1,24 @@
|
||||
/* global require, module */
|
||||
|
||||
var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
|
||||
|
||||
module.exports = function(defaults) {
|
||||
return new Angular2App(defaults, {
|
||||
vendorNpmFiles: [
|
||||
'socket.io-client/socket.io.js',
|
||||
'smoothie/smoothie.js',
|
||||
'chart.js/Chart.js',
|
||||
'ng2-charts/bundles/ng2-charts.js',
|
||||
'chroma-js/chroma.js',
|
||||
'plotly.js/dist/plotly.js',
|
||||
'brainbrowser/build/brainbrowser-2.3.0/**/*.js',
|
||||
'systemjs/dist/system-polyfills.js',
|
||||
'systemjs/dist/system.src.js',
|
||||
'zone.js/dist/*.js',
|
||||
'es6-shim/es6-shim.js',
|
||||
'reflect-metadata/*.js',
|
||||
'rxjs/**/*.js',
|
||||
'@angular/**/*.js'
|
||||
]
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"project": {
|
||||
"version": "0.1.0",
|
||||
"name": "clitest"
|
||||
},
|
||||
"apps": [
|
||||
{"main": "src/main.ts", "tsconfig": "src/tsconfig.json"}
|
||||
],
|
||||
"addons": [],
|
||||
"packages": [],
|
||||
"e2e": {
|
||||
"protractor": {
|
||||
"config": "config/protractor.conf.js"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"karma": {
|
||||
"config": "config/karma.conf.js"
|
||||
}
|
||||
},
|
||||
"defaults": {
|
||||
"prefix": "bci",
|
||||
"sourceDir": "src"
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<section ng-class="{ loading: !$ctrl.data }">
|
||||
<h2 class="capitalize">{{ $ctrl.type }}</h2>
|
||||
<canvas id="frequency-band-{{ $ctrl.type }}"
|
||||
class="chart chart-bar"
|
||||
chart-data="$ctrl.data"
|
||||
chart-labels="$ctrl.channels"
|
||||
chart-series="$ctrl.channels"
|
||||
chart-options="$ctrl.options"
|
||||
chart-colours="$ctrl.colors">
|
||||
</canvas>
|
||||
</section>
|
||||
@@ -1,58 +0,0 @@
|
||||
|
||||
(function () {
|
||||
|
||||
var BCIFrequencyBand = {
|
||||
templateUrl: 'components/frequency-band/frequency-band.html',
|
||||
bindings: {
|
||||
type: '@',
|
||||
color: '@',
|
||||
eventName: '@'
|
||||
},
|
||||
controller: function ($timeout) {
|
||||
|
||||
var $ctrl = this;
|
||||
|
||||
var socket = io();
|
||||
|
||||
$ctrl.colors = [
|
||||
{ fillColor: 'rgba(112,185,252,1)' },
|
||||
{ fillColor: 'rgba(116,150,161,1)' },
|
||||
{ fillColor: 'rgba(162,86,178,1)' },
|
||||
{ fillColor: 'rgba(144,132,246,1)' },
|
||||
{ fillColor: 'rgba(138,219,229,1)' },
|
||||
{ fillColor: 'rgba(232,223,133,1)' },
|
||||
{ fillColor: 'rgba(148,159,177,1)' },
|
||||
{ fillColor: 'rgba(182,224,53,1)' }
|
||||
].filter(function (color, index) {
|
||||
return parseInt($ctrl.color) === index;
|
||||
});
|
||||
|
||||
console.log($ctrl.type, $ctrl.colors);
|
||||
|
||||
$ctrl.channels = ['CH1','CH2','CH3','CH4','CH5','CH6','CH7','CH8'];
|
||||
|
||||
$ctrl.options = {
|
||||
responsive: true,
|
||||
animation: true,
|
||||
animationSteps: 15
|
||||
};
|
||||
|
||||
socket.on($ctrl.eventName, function (data) {
|
||||
$timeout(function () {
|
||||
$ctrl.labels = data.labels;
|
||||
$ctrl.data = data[$ctrl.type || 'data'];
|
||||
});
|
||||
});
|
||||
|
||||
$ctrl.$onDestroy = function () {
|
||||
socket.removeListener($ctrl.eventName);
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
angular
|
||||
.module('bciDashboard')
|
||||
.component('bciFrequencyBand', BCIFrequencyBand);
|
||||
|
||||
})();
|
||||
@@ -1,12 +0,0 @@
|
||||
<section ng-class="{ loading: !$ctrl.data }">
|
||||
<h2>Frequency <span class="frequency-type">{{ $ctrl.type }}</span></h2>
|
||||
<canvas id="frequency"
|
||||
class="chart-base"
|
||||
chart-type="$ctrl.type"
|
||||
chart-data="$ctrl.data"
|
||||
chart-labels="$ctrl.labels"
|
||||
chart-series="$ctrl.channels"
|
||||
chart-options="$ctrl.options"
|
||||
chart-colours="$ctrl.colors">
|
||||
</canvas>
|
||||
</section>
|
||||
@@ -1,56 +0,0 @@
|
||||
|
||||
(function () {
|
||||
|
||||
var BCIFrequency = {
|
||||
templateUrl: 'components/frequency/frequency.html',
|
||||
bindings: {
|
||||
type: '@',
|
||||
eventName: '@'
|
||||
},
|
||||
controller: function ($timeout) {
|
||||
|
||||
var $ctrl = this;
|
||||
|
||||
// Default chart type as fallback
|
||||
$ctrl.type = $ctrl.type || 'Line';
|
||||
|
||||
var socket = io();
|
||||
|
||||
$ctrl.colors = [
|
||||
{ strokeColor: 'rgba(112,185,252,1)' },
|
||||
{ strokeColor: 'rgba(116,150,161,1)' },
|
||||
{ strokeColor: 'rgba(162,86,178,1)' },
|
||||
{ strokeColor: 'rgba(144,132,246,1)' },
|
||||
{ strokeColor: 'rgba(138,219,229,1)' },
|
||||
{ strokeColor: 'rgba(232,223,133,1)' },
|
||||
{ strokeColor: 'rgba(148,159,177,1)' },
|
||||
{ strokeColor: 'rgba(182,224,53,1)' }
|
||||
];
|
||||
|
||||
$ctrl.options = {
|
||||
responsive: true,
|
||||
animation: true,
|
||||
animationSteps: 15
|
||||
};
|
||||
|
||||
$ctrl.series = ['CH1','CH2','CH3','CH4','CH5','CH6','CH7','CH8'];
|
||||
|
||||
socket.on($ctrl.eventName, function (data) {
|
||||
$timeout(function () {
|
||||
$ctrl.data = data.data;
|
||||
$ctrl.labels = data.labels;
|
||||
});
|
||||
});
|
||||
|
||||
$ctrl.$onDestroy = function () {
|
||||
socket.removeListener($ctrl.eventName);
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
angular
|
||||
.module('bciDashboard')
|
||||
.component('bciFrequency', BCIFrequency);
|
||||
|
||||
})();
|
||||
@@ -1,88 +0,0 @@
|
||||
|
||||
(function () {
|
||||
|
||||
angular
|
||||
.module('bciDashboard')
|
||||
.directive('bciTimeSeries', bciTimeSeries);
|
||||
|
||||
function bciTimeSeries() {
|
||||
|
||||
var timeSeries = new SmoothieChart({
|
||||
millisPerLine: 3000,
|
||||
grid: {
|
||||
fillStyle: '#333333',
|
||||
strokeStyle: 'rgba(0,0,0,0.1)',
|
||||
sharpLines: false,
|
||||
verticalSections: 8,
|
||||
borderVisible: true
|
||||
},
|
||||
labels: {
|
||||
disabled: true
|
||||
},
|
||||
maxValue: 8 * 2,
|
||||
minValue: 0
|
||||
});
|
||||
|
||||
return {
|
||||
templateUrl: 'components/time-series/time-series.html',
|
||||
scope: {
|
||||
eventName: '@'
|
||||
},
|
||||
bindToController: true,
|
||||
controllerAs: '$ctrl',
|
||||
controller: function ($timeout) {
|
||||
|
||||
var $ctrl = this;
|
||||
|
||||
var socket = io();
|
||||
|
||||
$ctrl.colors = [
|
||||
{ strokeColor: 'rgba(112,185,252,1)' },
|
||||
{ strokeColor: 'rgba(116,150,161,1)' },
|
||||
{ strokeColor: 'rgba(162,86,178,1)' },
|
||||
{ strokeColor: 'rgba(144,132,246,1)' },
|
||||
{ strokeColor: 'rgba(138,219,229,1)' },
|
||||
{ strokeColor: 'rgba(232,223,133,1)' },
|
||||
{ strokeColor: 'rgba(148,159,177,1)' },
|
||||
{ strokeColor: 'rgba(182,224,53,1)' }
|
||||
];
|
||||
|
||||
$ctrl.channels = ['CH1','CH2','CH3','CH4','CH5','CH6','CH7','CH8'];
|
||||
|
||||
// Construct time series array with 8 lines
|
||||
var lines = Array(8).fill().map(function () {
|
||||
return new TimeSeries();
|
||||
});
|
||||
|
||||
lines.forEach(function (line, index) {
|
||||
timeSeries.addTimeSeries(line, { strokeStyle: $ctrl.colors[index].strokeColor });
|
||||
});
|
||||
|
||||
socket.on($ctrl.eventName, function (data) {
|
||||
|
||||
$timeout(function () {
|
||||
$ctrl.amplitudes = data.amplitudes;
|
||||
$ctrl.timeline = data.timeline;
|
||||
});
|
||||
|
||||
lines.forEach(function (line, index) {
|
||||
data.data[index].forEach(function (amplitude) {
|
||||
line.append(new Date().getTime(), amplitude);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$ctrl.$onDestroy = function () {
|
||||
socket.removeListener($ctrl.eventName);
|
||||
};
|
||||
|
||||
},
|
||||
link: function (scope, element) {
|
||||
// 200 = 50 samples * 4 milliseconds (sample rate)
|
||||
timeSeries.streamTo(element[0].querySelector('canvas'), 40);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,19 +0,0 @@
|
||||
<section ng-class="{ loading: !$ctrl.grid }">
|
||||
<h2>Topo</h2>
|
||||
<section class="topoplot-wrapper">
|
||||
|
||||
<article class="topoplot-c1 top left"></article>
|
||||
<article class="topoplot-c2 top right"></article>
|
||||
<article class="topoplot-c3 middle left"></article>
|
||||
<article class="topoplot-c4 middle right"></article>
|
||||
<article class="topoplot-c5 third left"></article>
|
||||
<article class="topoplot-c6 third right"></article>
|
||||
<article class="topoplot-c7 bottom left"></article>
|
||||
<article class="topoplot-c8 bottom right"></article>
|
||||
|
||||
<aside class="topoplot-grid">
|
||||
<div ng-repeat="pixel in $ctrl.grid track by $index" ng-style="$ctrl.getColor($index,pixel,$ctrl.grid)" ng-class="$ctrl.getClass($index)"></div>
|
||||
</aside>
|
||||
|
||||
</section>
|
||||
</section>
|
||||
@@ -1,44 +0,0 @@
|
||||
|
||||
(function () {
|
||||
|
||||
var BCITopo = {
|
||||
templateUrl: 'components/topo/topo.html',
|
||||
bindings: {
|
||||
eventName: '@'
|
||||
},
|
||||
controller: function ($timeout) {
|
||||
|
||||
var $ctrl = this;
|
||||
|
||||
var socket = io();
|
||||
|
||||
$ctrl.getClass = function(index){
|
||||
return 'topoplot-u' + index
|
||||
};
|
||||
|
||||
$ctrl.getColor = function(index,pixel,grid){
|
||||
var min = Math.min.apply(Math,grid);
|
||||
var max = Math.max.apply(Math,grid);
|
||||
var f = chroma.scale('Spectral').domain([min,max]);
|
||||
return {'background-color': f(pixel)}
|
||||
};
|
||||
|
||||
socket.on($ctrl.eventName, function (data) {
|
||||
$timeout(function () {
|
||||
$ctrl.grid = data.data;
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
$ctrl.$onDestroy = function () {
|
||||
socket.removeListener($ctrl.eventName);
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
angular
|
||||
.module('bciDashboard')
|
||||
.component('bciTopo', BCITopo);
|
||||
|
||||
})();
|
||||
@@ -1,71 +0,0 @@
|
||||
<!doctype html>
|
||||
<html ng-app="bciDashboard">
|
||||
<head>
|
||||
<title>BCI Dashboard</title>
|
||||
|
||||
<link rel="stylesheet" href="node_modules/angular-chart.js/dist/angular-chart.css">
|
||||
<link rel="stylesheet" href="visualizer.css">
|
||||
<link rel="stylesheet" href="components/topo/topo.css">
|
||||
|
||||
<script src="node_modules/socket.io-client/socket.io.js"></script>
|
||||
<script src="node_modules/smoothie/smoothie.js"></script>
|
||||
|
||||
<script src="node_modules/angular/angular.js"></script>
|
||||
<script src="node_modules/chart.js/Chart.js"></script>
|
||||
<script src="node_modules/angular-chart.js/dist/angular-chart.js"></script>
|
||||
|
||||
<script src="visualizer.js"></script>
|
||||
|
||||
<script src="lib/chroma.min.js"></script>
|
||||
|
||||
<script src="components/frequency/frequency.js"></script>
|
||||
<script src="components/frequency-band/frequency-band.js"></script>
|
||||
<script src="components/time-series/time-series.js"></script>
|
||||
<script src="components/topo/topo.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<main>
|
||||
|
||||
<h1>BCI Dashboard</h1>
|
||||
|
||||
<nav ng-init="mode = 'timeSeries'">
|
||||
<button ng-click="mode = 'timeSeries'">Time Series</button>
|
||||
<button ng-click="mode = 'frequency'">Frequency</button>
|
||||
<button ng-click="mode = 'frequencyRadar'">Frequency Radar</button>
|
||||
<button ng-click="mode = 'frequencyBands'">Frequency Bands</button>
|
||||
<button ng-click="mode = 'topo'">Topo</button>
|
||||
</nav>
|
||||
|
||||
<section class="row" ng-if="mode == 'timeSeries'">
|
||||
<bci-time-series event-name="bci:time" class="block block-75"></bci-time-series>
|
||||
</section>
|
||||
|
||||
<section class="row" ng-if="mode == 'frequency'">
|
||||
<bci-frequency type="Line" event-name="bci:fft" class="block block-75"></bci-frequency>
|
||||
</section>
|
||||
|
||||
<section class="row" ng-if="mode == 'frequencyRadar'">
|
||||
<bci-frequency type="Radar" event-name="bci:fft" class="block block-75"></bci-frequency>
|
||||
</section>
|
||||
|
||||
<section class="row" ng-if="mode == 'frequencyBands'">
|
||||
<bci-frequency-band event-name="bci:fft" type="delta" color="1" class="block block-33"></bci-frequency-band>
|
||||
<bci-frequency-band event-name="bci:fft" type="theta" color="2" class="block block-33"></bci-frequency-band>
|
||||
</section>
|
||||
|
||||
<section class="row" ng-if="mode == 'frequencyBands'">
|
||||
<bci-frequency-band event-name="bci:fft" type="alpha" color="3" class="block block-33"></bci-frequency-band>
|
||||
<bci-frequency-band event-name="bci:fft" type="beta" color="4" class="block block-33"></bci-frequency-band>
|
||||
<bci-frequency-band event-name="bci:fft" type="gamma" color="5" class="block block-33"></bci-frequency-band>
|
||||
</section>
|
||||
|
||||
<section class="row" ng-if="mode == 'topo'">
|
||||
<bci-topo event-name="bci:topo" class="block block-50"></bci-topo>
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
externo
-33
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
@@ -1,29 +0,0 @@
|
||||
|
||||
(function () {
|
||||
|
||||
angular
|
||||
.module('bciDashboard', ['chart.js'])
|
||||
.config(bciDashboardConfig);
|
||||
|
||||
function bciDashboardConfig (ChartJsProvider) {
|
||||
ChartJsProvider.setOptions({
|
||||
animation: false,
|
||||
responsive: true,
|
||||
datasetStrokeWidth: 1,
|
||||
pointDot: false,
|
||||
pointDotRadius: 1,
|
||||
pointDotStrokeWidth: 0,
|
||||
datasetFill: false,
|
||||
scaleOverride: true,
|
||||
scaleStartValue: -2,
|
||||
scaleStepWidth: 1,
|
||||
scaleSteps: 6,
|
||||
barShowStroke: false,
|
||||
barValueSpacing: 1,
|
||||
barShowStroke: true,
|
||||
barStrokeWidth: 1,
|
||||
strokeColor: 'rgba(116,150,161,1)'
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
Arquivo binário não exibido.
|
Depois Largura: | Altura: | Tamanho: 120 KiB |
Arquivo binário não exibido.
|
Depois Largura: | Altura: | Tamanho: 123 KiB |
Arquivo binário não exibido.
|
Depois Largura: | Altura: | Tamanho: 76 KiB |
@@ -0,0 +1,3 @@
|
||||
export const environment = {
|
||||
production: false
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
/* jshint node: true */
|
||||
|
||||
module.exports = function(environment) {
|
||||
return {
|
||||
environment: environment,
|
||||
baseURL: '/',
|
||||
locationType: 'auto'
|
||||
};
|
||||
};
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export const environment = {
|
||||
production: true
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
/*global jasmine, __karma__, window*/
|
||||
Error.stackTraceLimit = Infinity;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
|
||||
|
||||
__karma__.loaded = function () {
|
||||
};
|
||||
|
||||
var distPath = '/base/dist/';
|
||||
var appPath = distPath + 'app/';
|
||||
|
||||
function isJsFile(path) {
|
||||
return path.slice(-3) == '.js';
|
||||
}
|
||||
|
||||
function isSpecFile(path) {
|
||||
return path.slice(-8) == '.spec.js';
|
||||
}
|
||||
|
||||
function isAppFile(path) {
|
||||
return isJsFile(path) && (path.substr(0, appPath.length) == appPath);
|
||||
}
|
||||
|
||||
var allSpecFiles = Object.keys(window.__karma__.files)
|
||||
.filter(isSpecFile)
|
||||
.filter(isAppFile);
|
||||
|
||||
// Load our SystemJS configuration.
|
||||
System.config({
|
||||
baseURL: distPath
|
||||
});
|
||||
|
||||
System.import('system-config.js').then(function() {
|
||||
// Load and configure the TestComponentBuilder.
|
||||
return Promise.all([
|
||||
System.import('@angular/core/testing'),
|
||||
System.import('@angular/platform-browser-dynamic/testing')
|
||||
]).then(function (providers) {
|
||||
var testing = providers[0];
|
||||
var testingBrowser = providers[1];
|
||||
|
||||
testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
|
||||
testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
|
||||
});
|
||||
}).then(function() {
|
||||
// Finally, load all spec files.
|
||||
// This will run the tests directly.
|
||||
return Promise.all(
|
||||
allSpecFiles.map(function (moduleName) {
|
||||
return System.import(moduleName);
|
||||
}));
|
||||
}).then(__karma__.start, __karma__.error);
|
||||
@@ -0,0 +1,42 @@
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
basePath: '..',
|
||||
frameworks: ['jasmine'],
|
||||
plugins: [
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher')
|
||||
],
|
||||
customLaunchers: {
|
||||
// chrome setup for travis CI using chromium
|
||||
Chrome_travis_ci: {
|
||||
base: 'Chrome',
|
||||
flags: ['--no-sandbox']
|
||||
}
|
||||
},
|
||||
files: [
|
||||
{ pattern: 'dist/vendor/es6-shim/es6-shim.js', included: true, watched: false },
|
||||
{ pattern: 'dist/vendor/zone.js/dist/zone.js', included: true, watched: false },
|
||||
{ pattern: 'dist/vendor/reflect-metadata/Reflect.js', included: true, watched: false },
|
||||
{ pattern: 'dist/vendor/systemjs/dist/system-polyfills.js', included: true, watched: false },
|
||||
{ pattern: 'dist/vendor/systemjs/dist/system.src.js', included: true, watched: false },
|
||||
{ pattern: 'dist/vendor/zone.js/dist/async-test.js', included: true, watched: false },
|
||||
|
||||
{ pattern: 'config/karma-test-shim.js', included: true, watched: true },
|
||||
|
||||
// Distribution folder.
|
||||
{ pattern: 'dist/**/*', included: false, watched: true }
|
||||
],
|
||||
exclude: [
|
||||
// Vendor packages might include spec files. We don't want to use those.
|
||||
'dist/vendor/**/*.spec.js'
|
||||
],
|
||||
preprocessors: {},
|
||||
reporters: ['progress'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: config.LOG_INFO,
|
||||
autoWatch: true,
|
||||
browsers: ['Chrome'],
|
||||
singleRun: false
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
/*global jasmine */
|
||||
var SpecReporter = require('jasmine-spec-reporter');
|
||||
|
||||
exports.config = {
|
||||
allScriptsTimeout: 11000,
|
||||
specs: [
|
||||
'../e2e/**/*.e2e.ts'
|
||||
],
|
||||
capabilities: {
|
||||
'browserName': 'chrome'
|
||||
},
|
||||
directConnect: true,
|
||||
baseUrl: 'http://localhost:4200/',
|
||||
framework: 'jasmine',
|
||||
jasmineNodeOpts: {
|
||||
showColors: true,
|
||||
defaultTimeoutInterval: 30000,
|
||||
print: function() {}
|
||||
},
|
||||
useAllAngular2AppRoots: true,
|
||||
beforeLaunch: function() {
|
||||
require('ts-node').register({
|
||||
project: 'e2e'
|
||||
});
|
||||
},
|
||||
onPrepare: function() {
|
||||
jasmine.getEnv().addReporter(new SpecReporter());
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
import { ClitestPage } from './app.po';
|
||||
|
||||
describe('clitest App', function() {
|
||||
let page: ClitestPage;
|
||||
|
||||
beforeEach(() => {
|
||||
page = new ClitestPage();
|
||||
})
|
||||
|
||||
it('should display message saying app works', () => {
|
||||
page.navigateTo();
|
||||
expect(page.getParagraphText()).toEqual('clitest works!');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
export class ClitestPage {
|
||||
navigateTo() {
|
||||
return browser.get('/');
|
||||
}
|
||||
|
||||
getParagraphText() {
|
||||
return element(by.css('clitest-app h1')).getText();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"mapRoot": "",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"noEmitOnError": true,
|
||||
"noImplicitAny": false,
|
||||
"rootDir": ".",
|
||||
"sourceMap": true,
|
||||
"sourceRoot": "/",
|
||||
"target": "es5"
|
||||
}
|
||||
}
|
||||
externo
+1
@@ -0,0 +1 @@
|
||||
/// <reference path="../typings/main.d.ts" />
|
||||
+62
-12
@@ -1,31 +1,81 @@
|
||||
{
|
||||
"name": "openbci-dashboard",
|
||||
"private": false,
|
||||
"version": "0.0.1",
|
||||
"description": "A fullstack javascript app for capturing and visualizing OpenBCI EEG data",
|
||||
"main": "visualizer.js",
|
||||
"version": "0.1.0",
|
||||
"author": "Alex Castillo <alex@castillo.io>",
|
||||
"license": "MIT",
|
||||
"private": false,
|
||||
"angular-cli": {},
|
||||
"engines": {
|
||||
"node": ">= 6.2.0 < 7"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "ng server",
|
||||
"postinstall": "typings install",
|
||||
"lint": "tslint \"src/**/*.ts\"",
|
||||
"format": "clang-format -i -style=file --glob=src/**/*.ts",
|
||||
"visualize": "concurrently \"ng serve\" \"node src/server/app\" ",
|
||||
"simulate": "concurrently \"ng serve\" \"node src/server/app simulate\" ",
|
||||
"pree2e": "webdriver-manager update",
|
||||
"e2e": "protractor"
|
||||
},
|
||||
"keywords": [
|
||||
"openbci",
|
||||
"fft",
|
||||
"chartjs"
|
||||
"eeg",
|
||||
"neurojs",
|
||||
"dashboard"
|
||||
],
|
||||
"author": "Alex Castillo",
|
||||
"scripts": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:NeuroJS/openbci-dashboard.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/NeuroJS/openbci-dashboard/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"angular": "^1.5.5",
|
||||
"angular-chart.js": "^0.10.2",
|
||||
"chart.js": "^1.1.1",
|
||||
"@angular/common": "2.0.0-rc.1",
|
||||
"@angular/compiler": "2.0.0-rc.1",
|
||||
"@angular/core": "2.0.0-rc.1",
|
||||
"@angular/platform-browser": "2.0.0-rc.1",
|
||||
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
|
||||
"@angular/router": "2.0.0-rc.1",
|
||||
"brainbrowser": "^2.3.0",
|
||||
"chart.js": "^1.0.2",
|
||||
"chroma-js": "^1.1.1",
|
||||
"dsp.js": "neurojs/dsp.js",
|
||||
"es6-shim": "^0.35.0",
|
||||
"express": "^4.13.4",
|
||||
"fili": "^1.2.1",
|
||||
"jstat": "^1.5.2",
|
||||
"ng2-charts": "^1.0.3",
|
||||
"nodemon": "^1.9.1",
|
||||
"openbci-sdk": "^0.3.4",
|
||||
"plotly.js": "^1.10.2",
|
||||
"reflect-metadata": "0.1.3",
|
||||
"rxjs": "5.0.0-beta.6",
|
||||
"smoothie": "^1.27.0",
|
||||
"socket.io": "^1.4.5",
|
||||
"socket.io-client": "^1.4.5",
|
||||
"socket.io": "^1.4.6",
|
||||
"socket.io-client": "^1.4.6",
|
||||
"systemjs": "0.19.26",
|
||||
"topogrid": "^1.0.6",
|
||||
"yargs": "^4.3.2"
|
||||
"yargs": "^4.3.2",
|
||||
"zone.js": "^0.6.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"angular-cli": "0.0.*",
|
||||
"clang-format": "^1.0.35",
|
||||
"codelyzer": "0.0.14",
|
||||
"ember-cli-inject-live-reload": "^1.4.0",
|
||||
"jasmine-core": "^2.4.1",
|
||||
"jasmine-spec-reporter": "^2.4.0",
|
||||
"karma": "^0.13.15",
|
||||
"karma-chrome-launcher": "^0.2.3",
|
||||
"karma-jasmine": "^0.3.8",
|
||||
"protractor": "^3.3.0",
|
||||
"ts-node": "^0.5.5",
|
||||
"tslint": "^3.6.0",
|
||||
"typescript": "^1.8.10",
|
||||
"typings": "^0.8.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,28 @@
|
||||
|
||||
@import url(https://fonts.googleapis.com/css?family=Roboto:400,700,300);
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-weight: 300;
|
||||
color: #ffffff;
|
||||
background-color: #222222;
|
||||
:host {
|
||||
display: block;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
main {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 20px;
|
||||
padding: 20px;
|
||||
font-weight: 300;
|
||||
margin: 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.capitalize {
|
||||
@@ -32,57 +39,6 @@ h1 {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
nav {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
|
||||
button {
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #ffffff;
|
||||
padding: 8px 20px;
|
||||
text-transform: uppercase;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-weight: 300;
|
||||
font-size: 12px;
|
||||
letter-spacing: 1px;
|
||||
margin-right: 2px;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
nav button:nth-child(1) {
|
||||
background-color: rgba(112,185,252,1);
|
||||
}
|
||||
|
||||
nav button:nth-child(2) {
|
||||
background-color: rgba(138,219,229,1);
|
||||
}
|
||||
|
||||
nav button:nth-child(3) {
|
||||
background-color: rgba(162,86,178,1);
|
||||
}
|
||||
|
||||
nav button:nth-child(4) {
|
||||
background-color: rgba(144,132,246,1);
|
||||
}
|
||||
|
||||
nav button:nth-child(5) {
|
||||
background-color: rgba(232,223,133,1);
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
nav button:nth-child(6) {
|
||||
background-color: rgba(148,159,177,1);
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
}
|
||||
@@ -131,64 +87,57 @@ nav button:nth-child(6) {
|
||||
min-height: 580px;
|
||||
}
|
||||
|
||||
.time-series canvas {
|
||||
margin: 40px 80px 40px 40px;
|
||||
|
||||
nav {
|
||||
margin-left: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.time-series-channels,
|
||||
.time-series-amplitudes {
|
||||
position: absolute;
|
||||
top: 60px;
|
||||
height: 450px;
|
||||
color: rgba(102,102,102,1);
|
||||
|
||||
nav a {
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #ffffff;
|
||||
padding: 8px 20px;
|
||||
text-transform: uppercase;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-weight: 300;
|
||||
font-size: 12px;
|
||||
letter-spacing: 1px;
|
||||
margin-right: 2px;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.time-series-channels {
|
||||
width: 40px;
|
||||
left: 20px;
|
||||
text-align: left;
|
||||
nav a:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
nav a:nth-child(1) {
|
||||
background-color: rgba(112,185,252,1);
|
||||
}
|
||||
|
||||
nav a:nth-child(2) {
|
||||
background-color: rgba(138,219,229,1);
|
||||
}
|
||||
|
||||
nav a:nth-child(3) {
|
||||
background-color: rgba(162,86,178,1);
|
||||
}
|
||||
|
||||
nav a:nth-child(4) {
|
||||
background-color: rgba(144,132,246,1);
|
||||
}
|
||||
|
||||
nav a:nth-child(5) {
|
||||
background-color: rgba(232,223,133,1);
|
||||
color: #000000;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.time-series-amplitudes {
|
||||
right: 20px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.time-series-channels ul {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.time-series-channels li {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.time-series-channels ul,
|
||||
.time-series-amplitudes ul {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-around;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.time-series-duration {
|
||||
position: absolute;
|
||||
left: 50px;
|
||||
width: 98%;
|
||||
bottom: 22px;
|
||||
display: flex;
|
||||
color: rgba(102,102,102,1);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.time-series-duration time {
|
||||
width: 20%;
|
||||
nav a:nth-child(6) {
|
||||
background-color: rgba(148,159,177,1);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<main>
|
||||
<bci-filters></bci-filters>
|
||||
<section class="content">
|
||||
<h1>{{ title }}</h1>
|
||||
<nav>
|
||||
<a [routerLink]="['/time-series']">Time Series</a>
|
||||
<a [routerLink]="['/frequency/line', { type: 'Line' }]">Frequency Line</a>
|
||||
<a [routerLink]="['/frequency/radar', { type: 'Radar' }]">Frequency Radar</a>
|
||||
<a [routerLink]="['/frequency/bands']">Frequency Bands</a>
|
||||
<a [routerLink]="['/motion']">Motion</a>
|
||||
<a [routerLink]="['/topo']">Topo</a>
|
||||
</nav>
|
||||
<router-outlet></router-outlet>
|
||||
</section>
|
||||
</main>
|
||||
@@ -0,0 +1,22 @@
|
||||
import {
|
||||
beforeEachProviders,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
inject
|
||||
} from '@angular/core/testing';
|
||||
import { DashboardComponent } from '../app/dashboard.component';
|
||||
|
||||
beforeEachProviders(() => [DashboardComponent]);
|
||||
|
||||
describe('App: DashboardComponent', () => {
|
||||
it('should create the app',
|
||||
inject([DashboardComponent], (app: DashboardComponent) => {
|
||||
expect(app).toBeTruthy();
|
||||
}));
|
||||
|
||||
it('should have as title \'clitest works!\'',
|
||||
inject([DashboardComponent], (app: DashboardComponent) => {
|
||||
expect(app.title).toEqual('clitest works!');
|
||||
}));
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FiltersComponent } from './filters';
|
||||
import { TimeSeriesComponent } from './time-series';
|
||||
import { FrequencyComponent } from './frequency';
|
||||
import { FrequencyBandsComponent } from './frequency-bands';
|
||||
import { TopoComponent } from './topo';
|
||||
import { MotionComponent } from './motion';
|
||||
import { Routes, Router, ROUTER_PROVIDERS, ROUTER_DIRECTIVES } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'bci-dashboard',
|
||||
templateUrl: 'dashboard.component.html',
|
||||
styleUrls: ['dashboard.component.css'],
|
||||
directives: [ROUTER_DIRECTIVES, FiltersComponent],
|
||||
providers: [ROUTER_PROVIDERS]
|
||||
})
|
||||
|
||||
@Routes([
|
||||
{ path: '/', component: TimeSeriesComponent },
|
||||
{ path: '/time-series', component: TimeSeriesComponent },
|
||||
{ path: '/frequency/line', component: FrequencyComponent },
|
||||
{ path: '/frequency/radar', component: FrequencyComponent },
|
||||
{ path: '/frequency/bands', component: FrequencyBandsComponent },
|
||||
{ path: '/motion', component: MotionComponent },
|
||||
{ path: '/topo', component: TopoComponent }
|
||||
])
|
||||
|
||||
export class DashboardComponent implements OnInit {
|
||||
title = 'BCI Dashboard';
|
||||
|
||||
constructor (private router: Router) {
|
||||
}
|
||||
|
||||
ngOnInit () {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// The file for the current environment will overwrite this one during build
|
||||
// Different environments can be found in config/environment.{dev|prod}.ts
|
||||
// The build system defaults to the dev environment
|
||||
|
||||
export const environment = {
|
||||
production: false
|
||||
};
|
||||
@@ -0,0 +1,66 @@
|
||||
:host {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.filters {
|
||||
width: 120px;
|
||||
height: 100vh;
|
||||
padding: 14px;
|
||||
background-color: #333;
|
||||
}
|
||||
|
||||
.filters h3 {
|
||||
font-weight: 500;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.filters article {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.filters nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.filters label {
|
||||
margin-bottom: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.filters .select {
|
||||
position: relative;
|
||||
border: 2px solid rgba(255,255,255, 0.6);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.filters .select:after {
|
||||
content: "▼";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
font-size: 6px;
|
||||
line-height: 27px;
|
||||
padding: 0 8px;
|
||||
color: rgba(255,255,255,0.2);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.filters select {
|
||||
width: 100%;
|
||||
-webkit-appearance: none;
|
||||
color: rgba(255,255,255,0.4);
|
||||
font-weight: 300;
|
||||
letter-spacing: 1px;
|
||||
background: transparent;
|
||||
padding: 6px;
|
||||
outline: none;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.filters .disabled {
|
||||
opacity: 0.2;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<aside class="filters">
|
||||
<h3>Filters</h3>
|
||||
<nav>
|
||||
<article *ngFor="let filter of filters"
|
||||
[ngClass]="{ disabled: !filter.enabled }">
|
||||
<label>{{ filter.label }}</label>
|
||||
<div class="select">
|
||||
<select
|
||||
[multiple]="filter.type === 'multiple'"
|
||||
[disabled]="!filter.enabled"
|
||||
(change)="applyFilter($event.target.value)">
|
||||
<option *ngFor="let option of filter.options"
|
||||
[value]="option.id">
|
||||
{{ option.label }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</article>
|
||||
</nav>
|
||||
</aside>
|
||||
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
inject,
|
||||
} from '@angular/core/testing';
|
||||
import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
|
||||
import { Component } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { FiltersComponent } from './filters.component';
|
||||
|
||||
describe('Component: Filters', () => {
|
||||
let builder: TestComponentBuilder;
|
||||
|
||||
beforeEachProviders(() => [FiltersComponent]);
|
||||
beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder) {
|
||||
builder = tcb;
|
||||
}));
|
||||
|
||||
it('should inject the component', inject([FiltersComponent],
|
||||
(component: FiltersComponent) => {
|
||||
expect(component).toBeTruthy();
|
||||
}));
|
||||
|
||||
it('should create the component', inject([], () => {
|
||||
return builder.createAsync(FiltersComponentTestController)
|
||||
.then((fixture: ComponentFixture<any>) => {
|
||||
let query = fixture.debugElement.query(By.directive(FiltersComponent));
|
||||
expect(query).toBeTruthy();
|
||||
expect(query.componentInstance).toBeTruthy();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
@Component({
|
||||
selector: 'test',
|
||||
template: `
|
||||
<bci-filters></bci-filters>
|
||||
`,
|
||||
directives: [FiltersComponent]
|
||||
})
|
||||
class FiltersComponentTestController {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import * as io from 'socket.io-client';
|
||||
import { Constants } from '../shared/constants';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'bci-filters',
|
||||
templateUrl: 'filters.component.html',
|
||||
styleUrls: ['filters.component.css'],
|
||||
providers: [Constants]
|
||||
})
|
||||
|
||||
export class FiltersComponent {
|
||||
|
||||
socket: any;
|
||||
constructor(private constants: Constants) {
|
||||
this.socket = io(this.constants.socket.url);
|
||||
}
|
||||
|
||||
private filters: Array<any> = this.constants.filters;
|
||||
|
||||
applyFilter (filter) {
|
||||
this.socket.emit(this.constants.socket.events.filter, filter)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { FiltersComponent } from './filters.component';
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
:host {
|
||||
display: inline-block;
|
||||
margin: 0 0 20px 20px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 0 5px rgba(0,0,0,0.3);
|
||||
background-color: #333333;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 47%;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
h2 {
|
||||
position: absolute;
|
||||
margin: 0;
|
||||
top: 10px;
|
||||
right: 20px;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.capitalize {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<section class="frequency-band" [ngClass]="{ 'loading': !data }">
|
||||
<h2 class="capitalize">{{ band }} {{ type }}</h2>
|
||||
<base-chart class="chart"
|
||||
[data]="data"
|
||||
[labels]="channels"
|
||||
[options]="options"
|
||||
[colours]="colors"
|
||||
[series]="channels"
|
||||
[chartType]="type">
|
||||
</base-chart>
|
||||
</section>
|
||||
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
inject,
|
||||
} from '@angular/core/testing';
|
||||
import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
|
||||
import { Component } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { FrequencyBandComponent } from './frequency-band.component';
|
||||
|
||||
describe('Component: FrequencyBand', () => {
|
||||
let builder: TestComponentBuilder;
|
||||
|
||||
beforeEachProviders(() => [FrequencyBandComponent]);
|
||||
beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder) {
|
||||
builder = tcb;
|
||||
}));
|
||||
|
||||
it('should inject the component', inject([FrequencyBandComponent],
|
||||
(component: FrequencyBandComponent) => {
|
||||
expect(component).toBeTruthy();
|
||||
}));
|
||||
|
||||
it('should create the component', inject([], () => {
|
||||
return builder.createAsync(FrequencyBandComponentTestController)
|
||||
.then((fixture: ComponentFixture<any>) => {
|
||||
let query = fixture.debugElement.query(By.directive(FrequencyBandComponent));
|
||||
expect(query).toBeTruthy();
|
||||
expect(query.componentInstance).toBeTruthy();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
@Component({
|
||||
selector: 'test',
|
||||
template: `
|
||||
<bci-frequency-band></bci-frequency-band>
|
||||
`,
|
||||
directives: [FrequencyBandComponent]
|
||||
})
|
||||
class FrequencyBandComponentTestController {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { Component, OnInit, OnDestroy, Input } from '@angular/core';
|
||||
import * as io from 'socket.io-client';
|
||||
import { ChartService } from '../shared';
|
||||
import { CHART_DIRECTIVES } from '../shared/ng2-charts';
|
||||
import { Constants } from '../shared/constants';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'bci-frequency-band',
|
||||
templateUrl: 'frequency-band.component.html',
|
||||
styleUrls: ['frequency-band.component.css'],
|
||||
directives: [CHART_DIRECTIVES],
|
||||
providers: [ChartService, Constants]
|
||||
})
|
||||
|
||||
export class FrequencyBandComponent implements OnInit {
|
||||
|
||||
socket: any;
|
||||
constructor(private chartService: ChartService, private constants: Constants) {
|
||||
this.socket = io(constants.socket.url);
|
||||
}
|
||||
|
||||
@Input() public type:string;
|
||||
@Input() public band:string;
|
||||
@Input() public color:number;
|
||||
|
||||
private data:Array<any> = [[]];
|
||||
private colors:Array<any>;
|
||||
private channels:Array<string> = this.chartService.getChannels();
|
||||
private options:any = this.chartService.getChartJSDefaults({
|
||||
responsive: false
|
||||
});
|
||||
|
||||
ngOnInit() {
|
||||
this.colors = this.chartService.getColorByIndex(this.color);
|
||||
this.socket.on(this.constants.socket.events.fft, (data) => {
|
||||
this.data = data[this.band || 'data'];
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
this.socket.removeListener(this.constants.socket.events.fft);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { FrequencyBandComponent } from './frequency-band.component';
|
||||
@@ -0,0 +1,9 @@
|
||||
<section>
|
||||
<bci-frequency-band [type]="'Bar'" [band]="'delta'" [color]="1"></bci-frequency-band>
|
||||
<bci-frequency-band [type]="'Bar'" [band]="'theta'" [color]="2"></bci-frequency-band>
|
||||
</section>
|
||||
<section>
|
||||
<bci-frequency-band [type]="'Bar'" [band]="'alpha'" [color]="3"></bci-frequency-band>
|
||||
<bci-frequency-band [type]="'Bar'" [band]="'beta'" [color]="4"></bci-frequency-band>
|
||||
<bci-frequency-band [type]="'Bar'" [band]="'gamma'" [color]="5"></bci-frequency-band>
|
||||
</section>
|
||||
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
inject,
|
||||
} from '@angular/core/testing';
|
||||
import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
|
||||
import { Component } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { FrequencyBandsComponent } from './frequency-bands.component';
|
||||
|
||||
describe('Component: FrequencyBands', () => {
|
||||
let builder: TestComponentBuilder;
|
||||
|
||||
beforeEachProviders(() => [FrequencyBandsComponent]);
|
||||
beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder) {
|
||||
builder = tcb;
|
||||
}));
|
||||
|
||||
it('should inject the component', inject([FrequencyBandsComponent],
|
||||
(component: FrequencyBandsComponent) => {
|
||||
expect(component).toBeTruthy();
|
||||
}));
|
||||
|
||||
it('should create the component', inject([], () => {
|
||||
return builder.createAsync(FrequencyBandsComponentTestController)
|
||||
.then((fixture: ComponentFixture<any>) => {
|
||||
let query = fixture.debugElement.query(By.directive(FrequencyBandsComponent));
|
||||
expect(query).toBeTruthy();
|
||||
expect(query.componentInstance).toBeTruthy();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
@Component({
|
||||
selector: 'test',
|
||||
template: `
|
||||
<bci-frequency-bands></bci-frequency-bands>
|
||||
`,
|
||||
directives: [FrequencyBandsComponent]
|
||||
})
|
||||
class FrequencyBandsComponentTestController {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FrequencyBandComponent } from '../frequency-band';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'bci-frequency-bands',
|
||||
templateUrl: 'frequency-bands.component.html',
|
||||
styleUrls: ['frequency-bands.component.css'],
|
||||
directives: [FrequencyBandComponent]
|
||||
})
|
||||
|
||||
export class FrequencyBandsComponent implements OnInit {
|
||||
|
||||
constructor() {}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { FrequencyBandsComponent } from './frequency-bands.component';
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
.chart {
|
||||
display: block;
|
||||
}
|
||||
|
||||
:host {
|
||||
display: block;
|
||||
margin: 20px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 0 5px rgba(0,0,0,0.3);
|
||||
background-color: #333333;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
h2 {
|
||||
position: absolute;
|
||||
margin: 0;
|
||||
top: 10px;
|
||||
right: 20px;
|
||||
font-weight: 300;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<section class="frequency" [ngClass]="{ 'loading': !data }">
|
||||
<h2>Frequency {{ type }}</h2>
|
||||
<base-chart class="chart"
|
||||
[data]="data"
|
||||
[labels]="labels"
|
||||
[options]="options"
|
||||
[colours]="colors"
|
||||
[series]="channels"
|
||||
[chartType]="type">
|
||||
</base-chart>
|
||||
</section>
|
||||
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
inject,
|
||||
} from '@angular/core/testing';
|
||||
import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
|
||||
import { Component } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { FrequencyComponent } from './frequency.component';
|
||||
|
||||
describe('Component: Frequency', () => {
|
||||
let builder: TestComponentBuilder;
|
||||
|
||||
beforeEachProviders(() => [FrequencyComponent]);
|
||||
beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder) {
|
||||
builder = tcb;
|
||||
}));
|
||||
|
||||
it('should inject the component', inject([FrequencyComponent],
|
||||
(component: FrequencyComponent) => {
|
||||
expect(component).toBeTruthy();
|
||||
}));
|
||||
|
||||
it('should create the component', inject([], () => {
|
||||
return builder.createAsync(FrequencyComponentTestController)
|
||||
.then((fixture: ComponentFixture<any>) => {
|
||||
let query = fixture.debugElement.query(By.directive(FrequencyComponent));
|
||||
expect(query).toBeTruthy();
|
||||
expect(query.componentInstance).toBeTruthy();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
@Component({
|
||||
selector: 'test',
|
||||
template: `
|
||||
<bci-frequency></bci-frequency>
|
||||
`,
|
||||
directives: [FrequencyComponent]
|
||||
})
|
||||
class FrequencyComponentTestController {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { Component, ElementRef, OnInit, OnDestroy, Input } from '@angular/core';
|
||||
import { RouteSegment, ROUTER_PROVIDERS } from '@angular/router';
|
||||
import * as io from 'socket.io-client';
|
||||
import { ChartService } from '../shared';
|
||||
import { CHART_DIRECTIVES } from '../shared/ng2-charts';
|
||||
import { Constants } from '../shared/constants';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'bci-frequency',
|
||||
templateUrl: 'frequency.component.html',
|
||||
styleUrls: ['frequency.component.css'],
|
||||
directives: [CHART_DIRECTIVES],
|
||||
providers: [ChartService, Constants, ROUTER_PROVIDERS]
|
||||
})
|
||||
|
||||
export class FrequencyComponent implements OnInit {
|
||||
|
||||
socket: any;
|
||||
constructor(private chartService: ChartService,
|
||||
private segment: RouteSegment,
|
||||
private constants: Constants) {
|
||||
this.socket = io(constants.socket.url);
|
||||
this.type = segment.getParam('type') || 'Line';
|
||||
}
|
||||
|
||||
@Input() type:string;
|
||||
|
||||
private data:Array<any> = [[]];
|
||||
private labels:Array<any> = [];
|
||||
private colors:Array<any> = this.chartService.getColors();
|
||||
private channels:Array<string> = this.chartService.getChannels();
|
||||
private options:any = this.chartService.getChartJSDefaults();
|
||||
|
||||
ngOnInit() {
|
||||
this.socket.on(this.constants.socket.events.fft, (data) => {
|
||||
this.data = data.data;
|
||||
this.labels = data.labels;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
this.socket.removeListener(this.constants.socket.events.fft);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { FrequencyComponent } from './frequency.component';
|
||||
@@ -0,0 +1,2 @@
|
||||
export {environment} from './environment';
|
||||
export {DashboardComponent} from './dashboard.component';
|
||||
@@ -0,0 +1 @@
|
||||
export { MotionComponent } from './motion.component';
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Arquivo binário não exibido.
@@ -0,0 +1,25 @@
|
||||
|
||||
:host {
|
||||
display: block;
|
||||
margin: 20px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 0 5px rgba(0,0,0,0.3);
|
||||
background-color: #333333;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 768px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
h2 {
|
||||
position: absolute;
|
||||
margin: 0;
|
||||
top: 10px;
|
||||
right: 20px;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
#brainbrowser {
|
||||
width: 100%;
|
||||
height: 500px;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<section class="motion" [ngClass]="{ 'loading': !model }">
|
||||
<h2>Motion</h2>
|
||||
<article id="brainbrowser"></article>
|
||||
</section>
|
||||
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
inject,
|
||||
} from '@angular/core/testing';
|
||||
import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
|
||||
import { Component } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { MotionComponent } from './motion.component';
|
||||
|
||||
describe('Component: Motion', () => {
|
||||
let builder: TestComponentBuilder;
|
||||
|
||||
beforeEachProviders(() => [MotionComponent]);
|
||||
beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder) {
|
||||
builder = tcb;
|
||||
}));
|
||||
|
||||
it('should inject the component', inject([MotionComponent],
|
||||
(component: MotionComponent) => {
|
||||
expect(component).toBeTruthy();
|
||||
}));
|
||||
|
||||
it('should create the component', inject([], () => {
|
||||
return builder.createAsync(MotionComponentTestController)
|
||||
.then((fixture: ComponentFixture<any>) => {
|
||||
let query = fixture.debugElement.query(By.directive(MotionComponent));
|
||||
expect(query).toBeTruthy();
|
||||
expect(query.componentInstance).toBeTruthy();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
@Component({
|
||||
selector: 'test',
|
||||
template: `
|
||||
<bci-motion></bci-motion>
|
||||
`,
|
||||
directives: [MotionComponent]
|
||||
})
|
||||
class MotionComponentTestController {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { Component, OnInit, ElementRef } from '@angular/core';
|
||||
import * as io from 'socket.io-client';
|
||||
import { Constants } from '../shared/constants';
|
||||
|
||||
declare var BrainBrowser;
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'bci-motion',
|
||||
templateUrl: 'motion.component.html',
|
||||
styleUrls: ['motion.component.css'],
|
||||
providers: [Constants]
|
||||
})
|
||||
|
||||
export class MotionComponent implements OnInit {
|
||||
|
||||
socket: any;
|
||||
viewer: any;
|
||||
model: any;
|
||||
constructor(private view: ElementRef, private constants: Constants) {
|
||||
this.socket = io(constants.socket.url);
|
||||
}
|
||||
|
||||
private rotation = [];
|
||||
|
||||
ngOnInit() {
|
||||
BrainBrowser.config.set('worker_dir', 'vendor/brainbrowser/build/brainbrowser-2.3.0/workers');
|
||||
|
||||
this.socket.on(this.constants.socket.events.motion, (data) => {
|
||||
this.rotation = data.data;
|
||||
|
||||
if (this.model) {
|
||||
this.viewer.resetView();
|
||||
this.viewer.model.rotation.set(...this.rotation);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit () {
|
||||
this.viewer = BrainBrowser.SurfaceViewer.start('brainbrowser', (viewer) => {
|
||||
this.viewer = viewer;
|
||||
this.viewer.render();
|
||||
this.viewer.setWireframe(true);
|
||||
this.viewer.loadModelFromURL('app/motion/models/brain-surface.obj');
|
||||
this.viewer.setClearColor(0x333333);
|
||||
|
||||
this.viewer.addEventListener('displaymodel', (data) => {
|
||||
this.model = data.model;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import {
|
||||
beforeEachProviders,
|
||||
it,
|
||||
describe,
|
||||
expect,
|
||||
inject
|
||||
} from '@angular/core/testing';
|
||||
import { ChartService } from './chart.service';
|
||||
|
||||
describe('Chart Service', () => {
|
||||
beforeEachProviders(() => [ChartService]);
|
||||
|
||||
it('should ...',
|
||||
inject([ChartService], (service: ChartService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -0,0 +1,106 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class ChartService {
|
||||
|
||||
constructor() {}
|
||||
|
||||
getPlotlyContourLayout (overrides: any = {}): any {
|
||||
return Object.assign({
|
||||
bargap: 0,
|
||||
autosize: true,
|
||||
paper_bgcolor: 'rgba(0,0,0,0)',
|
||||
plot_bgcolor: 'rgba(0,0,0,0)',
|
||||
margin: { l: 0, r: 0, b: 0, t: 0 },
|
||||
xaxis: {
|
||||
autorange: true,
|
||||
showgrid: false,
|
||||
zeroline: false,
|
||||
showline: false,
|
||||
autotick: true,
|
||||
ticks: '',
|
||||
showticklabels: false
|
||||
},
|
||||
yaxis: {
|
||||
autorange: true,
|
||||
showgrid: false,
|
||||
zeroline: false,
|
||||
showline: false,
|
||||
autotick: true,
|
||||
ticks: '',
|
||||
showticklabels: false
|
||||
}
|
||||
}, overrides);
|
||||
}
|
||||
|
||||
getPlotlyContourData (overrides: any = {}): any {
|
||||
return Object.assign({
|
||||
z: [],
|
||||
x: [],
|
||||
y: [],
|
||||
type: 'contour',
|
||||
colorscale: 'Jet',
|
||||
showscale: false
|
||||
}, overrides);
|
||||
}
|
||||
|
||||
getChartJSDefaults (overrides: any = {}): any {
|
||||
return Object.assign({
|
||||
responsive: true,
|
||||
animation: false,
|
||||
animationSteps: 15,
|
||||
datasetStrokeWidth: 1,
|
||||
pointDot: false,
|
||||
pointDotRadius: 1,
|
||||
pointDotStrokeWidth: 0,
|
||||
datasetFill: false,
|
||||
scaleOverride: true,
|
||||
scaleStartValue: -2,
|
||||
scaleStepWidth: 1,
|
||||
scaleSteps: 6,
|
||||
barShowStroke: false,
|
||||
barValueSpacing: 1,
|
||||
barStrokeWidth: 1
|
||||
}, overrides);
|
||||
}
|
||||
|
||||
getChartSmoothieDefaults (overrides: any = {}): any {
|
||||
return Object.assign({
|
||||
millisPerLine: 3000,
|
||||
grid: {
|
||||
fillStyle: '#333333',
|
||||
strokeStyle: 'rgba(0,0,0,0.1)',
|
||||
sharpLines: false,
|
||||
verticalSections: this.getChannels().length,
|
||||
borderVisible: true
|
||||
},
|
||||
labels: {
|
||||
disabled: true
|
||||
},
|
||||
maxValue: this.getChannels().length * 2,
|
||||
minValue: 0
|
||||
}, overrides);
|
||||
}
|
||||
|
||||
getChannels (): Array<string> {
|
||||
return Array(8).fill('CH').map((item, index) => item + (index + 1));
|
||||
}
|
||||
|
||||
getColors (): Array<any> {
|
||||
return [
|
||||
{ strokeColor: 'rgba(112,185,252,1)', fillColor: 'rgba(112,185,252,1)' },
|
||||
{ strokeColor: 'rgba(116,150,161,1)', fillColor: 'rgba(116,150,161,1)' },
|
||||
{ strokeColor: 'rgba(162,86,178,1)', fillColor: 'rgba(162,86,178,1)' },
|
||||
{ strokeColor: 'rgba(144,132,246,1)', fillColor: 'rgba(144,132,246,1)' },
|
||||
{ strokeColor: 'rgba(138,219,229,1)', fillColor: 'rgba(138,219,229,1)' },
|
||||
{ strokeColor: 'rgba(232,223,133,1)', fillColor: 'rgba(232,223,133,1)' },
|
||||
{ strokeColor: 'rgba(148,159,177,1)', fillColor: 'rgba(148,159,177,1)' },
|
||||
{ strokeColor: 'rgba(77,83,96,1)', fillColor: 'rgba(77,83,96,1)' }
|
||||
];
|
||||
}
|
||||
|
||||
getColorByIndex (index:number): Array<any> {
|
||||
return this.getColors().filter((c, i) => index === i);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class Constants {
|
||||
|
||||
socket: any = {
|
||||
url: 'http://localhost:8080',
|
||||
events: {
|
||||
fft: 'bci:fft',
|
||||
time: 'bci:time',
|
||||
topo: 'bci:topo',
|
||||
filter: 'bci:filter',
|
||||
motion: 'bci:motion'
|
||||
}
|
||||
};
|
||||
|
||||
filters: Array<any> = [
|
||||
{
|
||||
id: 'NOTCH',
|
||||
label: 'Notch',
|
||||
type: 'single',
|
||||
enabled: true,
|
||||
options: [
|
||||
{
|
||||
id: 'NOTCH:60',
|
||||
label: '60 Hz'
|
||||
},
|
||||
{
|
||||
id: 'NOTCH:50',
|
||||
label: '50 Hz'
|
||||
},
|
||||
{
|
||||
id: 'NOTCH:NONE',
|
||||
label: 'None'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'BANDPASS',
|
||||
label: 'Band Pass',
|
||||
type: 'single',
|
||||
enabled: false,
|
||||
options: [
|
||||
{
|
||||
id: 'BANDPASS:1-50',
|
||||
label: '1-50 Hz'
|
||||
},
|
||||
{
|
||||
id: 'BANDPASS:7-13',
|
||||
label: '7-13 Hz'
|
||||
},
|
||||
{
|
||||
id: 'BANDPASS:15-50',
|
||||
label: '15-50 Hz'
|
||||
},
|
||||
{
|
||||
id: 'BANDPASS:5-50',
|
||||
label: '5-50 Hz'
|
||||
},
|
||||
{
|
||||
id: 'BANDPASS:NONE',
|
||||
label: 'None'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'VERTSCALE',
|
||||
label: 'Vert Scale',
|
||||
type: 'single',
|
||||
enabled: false,
|
||||
options: [
|
||||
{
|
||||
id: 'VERTSCALE:50',
|
||||
label: '50uV'
|
||||
},
|
||||
{
|
||||
id: 'VERTSCALE:100',
|
||||
label: '100uV'
|
||||
},
|
||||
{
|
||||
id: 'VERTSCALE:200',
|
||||
label: '200uV'
|
||||
},
|
||||
{
|
||||
id: 'VERTSCALE:400',
|
||||
label: '400uV'
|
||||
},
|
||||
{
|
||||
id: 'VERTSCALE:1000',
|
||||
label: '1000uV'
|
||||
},
|
||||
{
|
||||
id: 'VERTSCALE:10000',
|
||||
label: '10,000uV'
|
||||
},
|
||||
{
|
||||
id: 'VERTSCALE:NONE',
|
||||
label: 'None'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'VERTALGO',
|
||||
label: 'Vert Algo',
|
||||
type: 'single',
|
||||
enabled: false,
|
||||
options: [
|
||||
{
|
||||
id: 'VERTALGO:50',
|
||||
label: 'Log'
|
||||
},
|
||||
{
|
||||
id: 'VERTALGO:Linear',
|
||||
label: 'Linear'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'SMOOTH',
|
||||
label: 'Smooth',
|
||||
type: 'single',
|
||||
enabled: false,
|
||||
options: [
|
||||
{
|
||||
id: 'SMOOTH:0-75',
|
||||
label: '0 75'
|
||||
},
|
||||
{
|
||||
id: 'SMOOTH:0-9',
|
||||
label: '0 9'
|
||||
},
|
||||
{
|
||||
id: 'SMOOTH:0-95',
|
||||
label: '0 95'
|
||||
},
|
||||
{
|
||||
id: 'SMOOTH:0-98',
|
||||
label: '0 98'
|
||||
},
|
||||
{
|
||||
id: 'SMOOTH:0-0',
|
||||
label: '0 0'
|
||||
},
|
||||
{
|
||||
id: 'SMOOTH:0-5',
|
||||
label: '0 5'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'POLARITY',
|
||||
label: 'Polarity',
|
||||
type: 'single',
|
||||
enabled: false,
|
||||
options: [
|
||||
{
|
||||
id: 'POLARITY:Yes',
|
||||
label: 'Yes'
|
||||
},
|
||||
{
|
||||
id: 'POLARITY:NO',
|
||||
label: 'No'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'MAXFREQUENCY',
|
||||
label: 'Max Frequency',
|
||||
type: 'single',
|
||||
enabled: false,
|
||||
options: [
|
||||
{
|
||||
id: 'MAXFREQUENCY:60',
|
||||
label: '60 Hz'
|
||||
},
|
||||
{
|
||||
id: 'MAXFREQUENCY:120',
|
||||
label: '120 Hz'
|
||||
},
|
||||
{
|
||||
id: 'MAXFREQUENCY:20',
|
||||
label: '20 Hz'
|
||||
},
|
||||
{
|
||||
id: 'MAXFREQUENCY:40',
|
||||
label: '40 Hz'
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './chart.service';
|
||||
export * from './ng2-charts';
|
||||
@@ -0,0 +1,265 @@
|
||||
import {
|
||||
Component, OnDestroy, OnInit, OnChanges,
|
||||
EventEmitter, ElementRef, Input
|
||||
} from '@angular/core';
|
||||
import {CORE_DIRECTIVES, FORM_DIRECTIVES, NgClass} from '@angular/common';
|
||||
|
||||
declare var Chart:any;
|
||||
|
||||
@Component({
|
||||
selector: 'chart',
|
||||
template: `<canvas></canvas>`,
|
||||
directives: [CORE_DIRECTIVES, NgClass]
|
||||
})
|
||||
export class ChartsComponent {}
|
||||
|
||||
@Component({
|
||||
selector: 'base-chart',
|
||||
properties: [
|
||||
'data',
|
||||
'labels',
|
||||
'series',
|
||||
'colours',
|
||||
'chartType',
|
||||
'legend',
|
||||
'options'
|
||||
],
|
||||
events: ['chartClick', 'chartHover'],
|
||||
template: `
|
||||
<canvas style="width: 100%; height: 100%;" (click)="click($event)" (mousemove)="hover($event)"></canvas>
|
||||
`,
|
||||
directives: [CORE_DIRECTIVES, FORM_DIRECTIVES, NgClass]
|
||||
})
|
||||
export class BaseChartComponent implements OnInit, OnDestroy, OnChanges {
|
||||
@Input() public data:Array<any> = [];
|
||||
@Input() public labels:Array<any> = [];
|
||||
@Input() public options:any = {responsive: true};
|
||||
@Input() public chartType:string;
|
||||
@Input() public series:Array<any> = [];
|
||||
@Input() public colours:Array<any> = [];
|
||||
@Input() public legend:boolean;
|
||||
|
||||
private ctx:any;
|
||||
private cvs:any;
|
||||
private parent:any;
|
||||
private chart:any;
|
||||
private legendTemplate:any;
|
||||
private initFlag:boolean = false;
|
||||
private chartClick:EventEmitter<any> = new EventEmitter();
|
||||
private chartHover:EventEmitter<any> = new EventEmitter();
|
||||
private defaultsColours:Array<any> = [
|
||||
{
|
||||
fillColor: 'rgba(151,187,205,0.2)',
|
||||
strokeColor: 'rgba(151,187,205,1)',
|
||||
pointColor: 'rgba(151,187,205,1)',
|
||||
pointStrokeColor: '#fff',
|
||||
pointHighlightFill: '#fff',
|
||||
pointHighlightStroke: 'rgba(151,187,205,0.8)',
|
||||
color: 'rgba(151,187,205,1)',
|
||||
highlight: 'rgba(151,187,205,0.8)'
|
||||
}, {
|
||||
fillColor: 'rgba(220,220,220,0.2)',
|
||||
strokeColor: 'rgba(220,220,220,1)',
|
||||
pointColor: 'rgba(220,220,220,1)',
|
||||
pointStrokeColor: '#fff',
|
||||
pointHighlightFill: '#fff',
|
||||
pointHighlightStroke: 'rgba(220,220,220,0.8)',
|
||||
color: 'rgba(220,220,220,1)',
|
||||
highlight: 'rgba(220,220,220,0.8)'
|
||||
}, {
|
||||
fillColor: 'rgba(247,70,74,0.2)',
|
||||
strokeColor: 'rgba(247,70,74,1)',
|
||||
pointColor: 'rgba(247,70,74,1)',
|
||||
pointStrokeColor: '#fff',
|
||||
pointHighlightFill: '#fff',
|
||||
pointHighlightStroke: 'rgba(247,70,74,0.8)',
|
||||
color: 'rgba(247,70,74,1)',
|
||||
highlight: 'rgba(247,70,74,0.8)'
|
||||
}, {
|
||||
fillColor: 'rgba(70,191,189,0.2)',
|
||||
strokeColor: 'rgba(70,191,189,1)',
|
||||
pointColor: 'rgba(70,191,189,1)',
|
||||
pointStrokeColor: '#fff',
|
||||
pointHighlightFill: '#fff',
|
||||
pointHighlightStroke: 'rgba(70,191,189,0.8)',
|
||||
color: 'rgba(70,191,189,1)',
|
||||
highlight: 'rgba(70,191,189,0.8)'
|
||||
}, {
|
||||
fillColor: 'rgba(253,180,92,0.2)',
|
||||
strokeColor: 'rgba(253,180,92,1)',
|
||||
pointColor: 'rgba(253,180,92,1)',
|
||||
pointStrokeColor: '#fff',
|
||||
pointHighlightFill: '#fff',
|
||||
pointHighlightStroke: 'rgba(253,180,92,0.8)',
|
||||
color: 'rgba(253,180,92,1)',
|
||||
highlight: 'rgba(253,180,92,0.8)'
|
||||
}, {
|
||||
fillColor: 'rgba(148,159,177,0.2)',
|
||||
strokeColor: 'rgba(148,159,177,1)',
|
||||
pointColor: 'rgba(148,159,177,1)',
|
||||
pointStrokeColor: '#fff',
|
||||
pointHighlightFill: '#fff',
|
||||
pointHighlightStroke: 'rgba(148,159,177,0.8)',
|
||||
color: 'rgba(148,159,177,1)',
|
||||
highlight: 'rgba(148,159,177,0.8)'
|
||||
}, {
|
||||
fillColor: 'rgba(77,83,96,0.2)',
|
||||
strokeColor: 'rgba(77,83,96,1)',
|
||||
pointColor: 'rgba(77,83,96,1)',
|
||||
pointStrokeColor: '#fff',
|
||||
pointHighlightFill: '#fff',
|
||||
pointHighlightStroke: 'rgba(77,83,96,0.8)',
|
||||
color: 'rgba(77,83,96,1)',
|
||||
highlight: 'rgba(77,83,96,0.8)'
|
||||
}];
|
||||
|
||||
private element:ElementRef;
|
||||
public constructor(element:ElementRef) {
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
public ngOnInit():any {
|
||||
this.ctx = this.element.nativeElement.children[0].getContext('2d');
|
||||
this.cvs = this.element.nativeElement.children[0];
|
||||
this.parent = this.element.nativeElement;
|
||||
this.refresh();
|
||||
this.initFlag = true;
|
||||
}
|
||||
|
||||
public ngOnChanges():any {
|
||||
if (this.initFlag) {
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public ngOnDestroy():any {
|
||||
if (this.chart) {
|
||||
this.chart.destroy();
|
||||
this.chart = void 0;
|
||||
}
|
||||
if (this.legendTemplate) {
|
||||
this.legendTemplate.destroy();
|
||||
this.legendTemplate = void 0;
|
||||
}
|
||||
}
|
||||
|
||||
public setLegend():void {
|
||||
let list = this.parent.getElementsByTagName('ul');
|
||||
if (list.length) {
|
||||
list[0].remove();
|
||||
this.parent.insertAdjacentHTML('beforeend', this.chart.generateLegend());
|
||||
} else {
|
||||
this.parent.insertAdjacentHTML('beforeend', this.chart.generateLegend());
|
||||
}
|
||||
}
|
||||
|
||||
public getColour(colour:Array<number>):any {
|
||||
return {
|
||||
fillColor: this.rgba(colour, 0.2),
|
||||
strokeColor: this.rgba(colour, 1),
|
||||
pointColor: this.rgba(colour, 1),
|
||||
pointStrokeColor: '#fff',
|
||||
pointHighlightFill: '#fff',
|
||||
pointHighlightStroke: this.rgba(colour, 0.8),
|
||||
color: this.rgba(colour, 1),
|
||||
highlight: this.rgba(colour, 0.8)
|
||||
};
|
||||
}
|
||||
|
||||
public getRandomInt(min:number, max:number):number {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
|
||||
public rgba(colour:Array<number>, alpha:number):string {
|
||||
return 'rgba(' + colour.concat(alpha).join(',') + ')';
|
||||
}
|
||||
|
||||
public click(evt:any):void {
|
||||
let atEvent = this.chart.getPointsAtEvent || this.chart.getBarsAtEvent || this.chart.getSegmentsAtEvent;
|
||||
let activePoints = atEvent.call(this.chart, evt);
|
||||
if (activePoints.length > 0) {
|
||||
let activeLabel = activePoints[0].label;
|
||||
this.chartClick.emit({activePoints: activePoints, activeLabel: activeLabel});
|
||||
}
|
||||
}
|
||||
|
||||
public hover(evt:any):void {
|
||||
let atEvent = this.chart.getPointsAtEvent || this.chart.getBarsAtEvent || this.chart.getSegmentsAtEvent;
|
||||
let activePoints = atEvent.call(this.chart, evt);
|
||||
if (activePoints.length > 0) {
|
||||
let activeLabel = activePoints[0].label;
|
||||
let activePoint = activePoints[0].value;
|
||||
this.chartHover.emit({activePoints: activePoints, activePoint: activePoint, activeLabel: activeLabel});
|
||||
}
|
||||
}
|
||||
|
||||
public getChartBuilder(ctx:any, data:Array<any>, options:any):any {
|
||||
return new Chart(ctx)[this.chartType](data, options);
|
||||
}
|
||||
|
||||
public getDataObject(label:string, value:any):any {
|
||||
if (this.chartType === 'Line'
|
||||
|| this.chartType === 'Bar'
|
||||
|| this.chartType === 'Radar') {
|
||||
return {
|
||||
label: label,
|
||||
data: value
|
||||
};
|
||||
}
|
||||
|
||||
if (this.chartType === 'Pie'
|
||||
|| this.chartType === 'Doughnut'
|
||||
|| this.chartType === 'PolarArea') {
|
||||
return {
|
||||
label: label,
|
||||
value: value
|
||||
};
|
||||
}
|
||||
|
||||
return void 0;
|
||||
}
|
||||
|
||||
public getChartData(labels:any, dataObject:any):any {
|
||||
if (this.chartType === 'Line'
|
||||
|| this.chartType === 'Bar'
|
||||
|| this.chartType === 'Radar') {
|
||||
return {
|
||||
labels: labels,
|
||||
datasets: dataObject
|
||||
};
|
||||
}
|
||||
if (this.chartType === 'Pie'
|
||||
|| this.chartType === 'Doughnut'
|
||||
|| this.chartType === 'PolarArea') {
|
||||
return dataObject;
|
||||
}
|
||||
}
|
||||
|
||||
private refresh():any {
|
||||
if (this.options.responsive && this.parent.clientHeight === 0) {
|
||||
return setTimeout(() => this.refresh(), 50);
|
||||
}
|
||||
|
||||
this.ngOnDestroy();
|
||||
let dataset:Array<any> = [];
|
||||
|
||||
for (let i = 0; i < this.data.length; i++) {
|
||||
let colourDesc:Array<number> = [this.getRandomInt(0, 255), this.getRandomInt(0, 255), this.getRandomInt(0, 255)];
|
||||
let colour = i < this.colours.length ? this.colours[i] : this.defaultsColours[i] || this.getColour(colourDesc);
|
||||
|
||||
let data:any = Object.assign(colour,
|
||||
this.getDataObject(this.series[i] || this.labels[i], this.data[i]));
|
||||
|
||||
dataset.push(data);
|
||||
}
|
||||
|
||||
let data:any = this.getChartData(this.labels, dataset);
|
||||
this.chart = this.getChartBuilder(this.ctx, data, this.options);
|
||||
|
||||
if (this.legend) {
|
||||
this.setLegend();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const CHART_DIRECTIVES:Array<any> = [ChartsComponent, BaseChartComponent];
|
||||
@@ -0,0 +1 @@
|
||||
export { TimeSeriesComponent } from './time-series.component';
|
||||
@@ -0,0 +1,82 @@
|
||||
|
||||
:host {
|
||||
display: block;
|
||||
margin: 20px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 0 5px rgba(0,0,0,0.3);
|
||||
background-color: #333333;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 1060px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
h2 {
|
||||
position: absolute;
|
||||
margin: 0;
|
||||
top: 10px;
|
||||
right: 20px;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.time-series canvas {
|
||||
margin: 40px 80px 40px 40px;
|
||||
}
|
||||
|
||||
.time-series-channels,
|
||||
.time-series-amplitudes {
|
||||
position: absolute;
|
||||
top: 60px;
|
||||
height: 450px;
|
||||
color: rgba(102,102,102,1);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.time-series-channels {
|
||||
width: 40px;
|
||||
left: 20px;
|
||||
text-align: left;
|
||||
color: #000000;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.time-series-amplitudes {
|
||||
right: 20px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.time-series-channels ul {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.time-series-channels li {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.time-series-channels ul,
|
||||
.time-series-amplitudes ul {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-around;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.time-series-duration {
|
||||
position: absolute;
|
||||
left: 50px;
|
||||
width: 98%;
|
||||
bottom: 22px;
|
||||
display: flex;
|
||||
color: rgba(102,102,102,1);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.time-series-duration time {
|
||||
width: 20%;
|
||||
}
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
<section class="time-series" ng-class="{ loading: !$ctrl.amplitudes }">
|
||||
<section class="time-series" [ngClass]="{ 'loading': !amplitudes }">
|
||||
<h2>Time Series</h2>
|
||||
<aside class="time-series-channels">
|
||||
<ul>
|
||||
<li ng-repeat="channel in $ctrl.channels track by $index"
|
||||
ng-style="{ 'color': $ctrl.colors[$index].strokeColor }">
|
||||
<li *ngFor="let channel of channels, let i = index"
|
||||
[ngStyle]="{ 'color': colors[i].strokeColor }">
|
||||
{{ channel }}
|
||||
</li>
|
||||
</ul>
|
||||
@@ -11,14 +11,14 @@
|
||||
<canvas id="timeSeries" width="950" height="450"></canvas>
|
||||
<aside class="time-series-amplitudes">
|
||||
<ul>
|
||||
<li ng-repeat="amplitude in $ctrl.amplitudes track by $index"
|
||||
ng-style="{ 'color': $ctrl.colors[$index].strokeColor }">
|
||||
<li *ngFor="let amplitude of amplitudes, let i = index"
|
||||
[ngStyle]="{ 'color': colors[i].strokeColor }">
|
||||
{{ amplitude }}
|
||||
</li>
|
||||
</ul>
|
||||
</aside>
|
||||
<footer class="time-series-duration">
|
||||
<time ng-repeat="time in $ctrl.timeline track by $index"
|
||||
<time *ngFor="let time of timeline"
|
||||
datetime="P1M">
|
||||
{{ time }}
|
||||
</time>
|
||||
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
inject,
|
||||
} from '@angular/core/testing';
|
||||
import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
|
||||
import { Component } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TimeSeriesComponent } from './time-series.component';
|
||||
|
||||
describe('Component: TimeSeries', () => {
|
||||
let builder: TestComponentBuilder;
|
||||
|
||||
beforeEachProviders(() => [TimeSeriesComponent]);
|
||||
beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder) {
|
||||
builder = tcb;
|
||||
}));
|
||||
|
||||
it('should inject the component', inject([TimeSeriesComponent],
|
||||
(component: TimeSeriesComponent) => {
|
||||
expect(component).toBeTruthy();
|
||||
}));
|
||||
|
||||
it('should create the component', inject([], () => {
|
||||
return builder.createAsync(TimeSeriesComponentTestController)
|
||||
.then((fixture: ComponentFixture<any>) => {
|
||||
let query = fixture.debugElement.query(By.directive(TimeSeriesComponent));
|
||||
expect(query).toBeTruthy();
|
||||
expect(query.componentInstance).toBeTruthy();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
@Component({
|
||||
selector: 'test',
|
||||
template: `
|
||||
<bci-time-series></bci-time-series>
|
||||
`,
|
||||
directives: [TimeSeriesComponent]
|
||||
})
|
||||
class TimeSeriesComponentTestController {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { Component, ElementRef, OnInit, OnDestroy } from '@angular/core';
|
||||
import { SmoothieChart, TimeSeries } from 'smoothie';
|
||||
import { ChartService } from '../shared';
|
||||
import * as io from 'socket.io-client';
|
||||
import { Constants } from '../shared/constants';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'bci-time-series',
|
||||
templateUrl: 'time-series.component.html',
|
||||
styleUrls: ['time-series.component.css'],
|
||||
providers: [ChartService, Constants]
|
||||
})
|
||||
|
||||
export class TimeSeriesComponent implements OnInit {
|
||||
|
||||
socket: any;
|
||||
constructor(private view: ElementRef,
|
||||
private chartService: ChartService,
|
||||
private constants: Constants) {
|
||||
this.socket = io(constants.socket.url);
|
||||
this.chartService = chartService;
|
||||
}
|
||||
|
||||
private options = this.chartService.getChartSmoothieDefaults();
|
||||
|
||||
private timeSeries = new SmoothieChart(this.options);
|
||||
private amplitudes = [];
|
||||
private timeline = [];
|
||||
private lines = Array(8).fill(0).map(() => new TimeSeries());
|
||||
private channels = this.chartService.getChannels();
|
||||
private colors = this.chartService.getColors();
|
||||
|
||||
ngOnInit() {
|
||||
this.addTimeSeriesLines();
|
||||
|
||||
this.socket.on(this.constants.socket.events.time, (data) => {
|
||||
this.amplitudes = data.amplitudes;
|
||||
this.timeline = data.timeline;
|
||||
this.appendTimeSeriesLines(data.data);
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
this.socket.removeListener(this.constants.socket.events.time);
|
||||
}
|
||||
|
||||
ngAfterViewInit () {
|
||||
this.timeSeries.streamTo(this.view.nativeElement.querySelector('canvas'), 40);
|
||||
}
|
||||
|
||||
addTimeSeriesLines () {
|
||||
this.lines.forEach((line, index) => {
|
||||
this.timeSeries.addTimeSeries(line, {
|
||||
strokeStyle: this.colors[index].strokeColor
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
appendTimeSeriesLines (data) {
|
||||
this.lines.forEach((line, index) => {
|
||||
data[index].forEach((amplitude) => {
|
||||
line.append(new Date().getTime(), amplitude);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { TopoComponent } from './topo.component';
|
||||
@@ -1,14 +1,33 @@
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.topoplot-wrapper {
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
border: 3px solid black;
|
||||
:host {
|
||||
display: block;
|
||||
margin: 20px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 0 5px rgba(0,0,0,0.3);
|
||||
background-color: #333333;
|
||||
position: relative;
|
||||
height: 40vw;
|
||||
width: 40vw;
|
||||
}
|
||||
|
||||
h2 {
|
||||
position: absolute;
|
||||
margin: 0;
|
||||
top: 10px;
|
||||
right: 20px;
|
||||
font-weight: 300;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.topoplot {
|
||||
-webkit-clip-path: circle(50%);
|
||||
border-radius: 50%;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
[class*='topoplot-c'] {
|
||||
@@ -79,4 +98,4 @@
|
||||
width: 9.09%;
|
||||
height: 9.09%;
|
||||
/*background: lightblue;*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<section [ngClass]="{ loading: !data }">
|
||||
<h2>Topo</h2>
|
||||
<section class="topoplot">
|
||||
<div id="topo"></div>
|
||||
</section>
|
||||
</section>
|
||||
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
inject,
|
||||
} from '@angular/core/testing';
|
||||
import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
|
||||
import { Component } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TopoComponent } from './topo.component';
|
||||
|
||||
describe('Component: Topo', () => {
|
||||
let builder: TestComponentBuilder;
|
||||
|
||||
beforeEachProviders(() => [TopoComponent]);
|
||||
beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder) {
|
||||
builder = tcb;
|
||||
}));
|
||||
|
||||
it('should inject the component', inject([TopoComponent],
|
||||
(component: TopoComponent) => {
|
||||
expect(component).toBeTruthy();
|
||||
}));
|
||||
|
||||
it('should create the component', inject([], () => {
|
||||
return builder.createAsync(TopoComponentTestController)
|
||||
.then((fixture: ComponentFixture<any>) => {
|
||||
let query = fixture.debugElement.query(By.directive(TopoComponent));
|
||||
expect(query).toBeTruthy();
|
||||
expect(query.componentInstance).toBeTruthy();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
@Component({
|
||||
selector: 'test',
|
||||
template: `
|
||||
<bci-topo></bci-topo>
|
||||
`,
|
||||
directives: [TopoComponent]
|
||||
})
|
||||
class TopoComponentTestController {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { Component, OnInit, OnDestroy, ElementRef } from '@angular/core';
|
||||
import * as io from 'socket.io-client';
|
||||
import { Constants } from '../shared/constants';
|
||||
import { ChartService } from '../shared';
|
||||
|
||||
declare var chroma: any;
|
||||
declare var Plotly: any;
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'bci-topo',
|
||||
templateUrl: 'topo.component.html',
|
||||
styleUrls: ['topo.component.css'],
|
||||
providers: [Constants, ChartService]
|
||||
})
|
||||
|
||||
export class TopoComponent implements OnInit {
|
||||
|
||||
socket: any;
|
||||
plotElement: any;
|
||||
|
||||
constructor(private view: ElementRef, private chartService: ChartService, private constants: Constants) {
|
||||
this.socket = io(constants.socket.url);
|
||||
}
|
||||
|
||||
private data: any = this.chartService.getPlotlyContourData({
|
||||
x: this.getGrid(11),
|
||||
y: this.getGrid(11)
|
||||
});
|
||||
|
||||
private layout: any = this.chartService.getPlotlyContourLayout();
|
||||
|
||||
private options: any = {
|
||||
staticPlot: true
|
||||
};
|
||||
|
||||
ngOnInit(): void {
|
||||
this.plotElement = this.view.nativeElement.querySelector('#topo');
|
||||
Plotly.newPlot(this.plotElement.id, [this.data], this.layout, this.options);
|
||||
|
||||
this.socket.on(this.constants.socket.events.topo, (data) => {
|
||||
this.data.z = data.data;
|
||||
Plotly.redraw(this.plotElement);
|
||||
Plotly.Plots.resize(this.plotElement);
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy (): void {
|
||||
this.socket.removeListener(this.constants.socket.events.topo);
|
||||
}
|
||||
|
||||
getGrid (n) {
|
||||
return Array(n).fill(0).map((v, i) => i).reverse();
|
||||
}
|
||||
|
||||
}
|
||||
Arquivo binário não exibido.
|
Depois Largura: | Altura: | Tamanho: 5.3 KiB |
@@ -0,0 +1,51 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>BCI Dashboard</title>
|
||||
<base href="/">
|
||||
{{content-for 'head'}}
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style>
|
||||
@import url(https://fonts.googleapis.com/css?family=Roboto:400,700,300);
|
||||
body {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-weight: 300;
|
||||
color: #ffffff;
|
||||
background-color: #222222;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Service worker support is disabled by default.
|
||||
Install the worker script and uncomment to enable.
|
||||
Only enable service workers in production.
|
||||
<script type="text/javascript">
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('/worker.js').catch(function(err) {
|
||||
console.log('Error installing service worker: ', err);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
<bci-dashboard>Loading...</bci-dashboard>
|
||||
|
||||
<script src="vendor/chart.js/Chart.js"></script>
|
||||
<script src="vendor/chroma-js/chroma.js"></script>
|
||||
<script src="vendor/plotly.js/dist/plotly.js"></script>
|
||||
<script src="vendor/brainbrowser/build/brainbrowser-2.3.0/brainbrowser.surface-viewer.min.js"></script>
|
||||
<script src="vendor/es6-shim/es6-shim.js"></script>
|
||||
<script src="vendor/reflect-metadata/Reflect.js"></script>
|
||||
<script src="vendor/systemjs/dist/system.src.js"></script>
|
||||
<script src="vendor/zone.js/dist/zone.js"></script>
|
||||
|
||||
<script>
|
||||
System.import('system-config.js').then(function () {
|
||||
System.import('main');
|
||||
}).catch(console.error.bind(console));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,9 @@
|
||||
import { bootstrap } from '@angular/platform-browser-dynamic';
|
||||
import { enableProdMode } from '@angular/core';
|
||||
import { DashboardComponent, environment } from './app/';
|
||||
|
||||
if (environment.production) {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
bootstrap(DashboardComponent);
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
const constants = require('./constants');
|
||||
const io = require('socket.io')(process.env.app_port || constants.sockets.port);
|
||||
|
||||
const Connectors = require('./connectors');
|
||||
const Providers = require('./providers');
|
||||
const Modules = require('./modules');
|
||||
|
||||
const Connector = new Connectors.Serialport({
|
||||
verbose: true
|
||||
});
|
||||
|
||||
const Signal = new Providers.Signal({ io });
|
||||
const Motion = new Providers.Motion({ io });
|
||||
|
||||
Connector.start().then(() => {
|
||||
const FFT = new Modules.FFT({ Signal });
|
||||
const Topo = new Modules.Topo({ Signal });
|
||||
const TimeSeries = new Modules.TimeSeries({ Signal });
|
||||
});
|
||||
|
||||
Connector.stream((data) => {
|
||||
Signal.buffer(data);
|
||||
Motion.capture(data);
|
||||
});
|
||||
|
||||
process.on(constants.events.terminate, Connector.stop);
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
module.exports = class Bluetooth {
|
||||
/**
|
||||
* The future!
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const Serialport = require('./serialport.connector');
|
||||
const Bluetooth = require('./bluetooth.connector');
|
||||
|
||||
module.exports = {
|
||||
Serialport,
|
||||
Bluetooth
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
const Utils = require('../utils');
|
||||
const OpenBCI = require('openbci-sdk');
|
||||
const OpenBCIBoard = OpenBCI.OpenBCIBoard;
|
||||
const constants = require('../constants');
|
||||
|
||||
module.exports = class Serialport extends OpenBCIBoard {
|
||||
|
||||
constructor (options) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
start () {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
var onConnect = () => {
|
||||
this.on(constants.connector.readyEvent, () => {
|
||||
this.streamStart();
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
this.autoFindOpenBCIBoard()
|
||||
.then((portName) => {
|
||||
if (portName) {
|
||||
this.connect(portName).then(onConnect);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
if (Utils.signal.isSimulated()) {
|
||||
this.connect(OpenBCI.OpenBCIConstants.OBCISimulatorPortName)
|
||||
.then(onConnect);
|
||||
} else {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
stop () {
|
||||
this.streamStop().then(() => {
|
||||
this.disconnect().then(() => {
|
||||
process.exit();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
stream (callback) {
|
||||
this.on(constants.connector.sampleEvent, callback);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
connector: {
|
||||
channels: 8,
|
||||
simulateFlag: 'simulate',
|
||||
readyEvent: 'ready',
|
||||
sampleEvent: 'sample'
|
||||
},
|
||||
signal: {
|
||||
bins: 128,
|
||||
bufferSize: 128,
|
||||
sampleRate: 250,
|
||||
windowRefreshRate: 8 // samples
|
||||
},
|
||||
scale: {
|
||||
global: 1.5,
|
||||
simulated: 4,
|
||||
skipLabels: 8
|
||||
},
|
||||
units: {
|
||||
hertz: 'Hz',
|
||||
microvolts: 'uV',
|
||||
seconds: 's'
|
||||
},
|
||||
bands: { // frequency
|
||||
delta: [1, 3],
|
||||
theta: [4, 8],
|
||||
alpha: [8, 12],
|
||||
beta: [13, 30],
|
||||
gamma: [30, 100]
|
||||
},
|
||||
time: {
|
||||
windowSize: 5, // seconds
|
||||
timeline: 20, // seconds
|
||||
skip: 2 //
|
||||
},
|
||||
events: {
|
||||
fft: 'bci:fft',
|
||||
topo: 'bci:topo',
|
||||
time: 'bci:time',
|
||||
signal: 'bci:signal',
|
||||
filter: 'bci:filter',
|
||||
motion: 'bci:motion',
|
||||
terminate: 'SIGINT'
|
||||
},
|
||||
topo: {
|
||||
params: [0,10,11],
|
||||
x: [3,7,2,8,0,10,3,7],
|
||||
y: [0,0,3,3,8,8,10,10]
|
||||
},
|
||||
sockets: {
|
||||
port: 8080
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,76 @@
|
||||
'use strict';
|
||||
|
||||
const dsp = require('dsp.js');
|
||||
const Utils = require('../utils');
|
||||
const constants = require('../constants');
|
||||
|
||||
module.exports = class FFT {
|
||||
|
||||
constructor ({ Signal }) {
|
||||
this.signal = Signal;
|
||||
this.bins = constants.signal.bins;
|
||||
this.bufferSize = constants.signal.bufferSize;
|
||||
this.sampleRate = constants.signal.sampleRate;
|
||||
this.bands = constants.bands;
|
||||
this.spectrums = [[],[],[],[],[],[],[],[]];
|
||||
this.byBand = [];
|
||||
this.labels = [];
|
||||
this.subscribe();
|
||||
}
|
||||
|
||||
subscribe () {
|
||||
this.signal.emitter.on(constants.events.signal, (signals) => {
|
||||
this.signalsToFFT(signals);
|
||||
this.scaleLabels();
|
||||
this.filterBands();
|
||||
this.filterLabels();
|
||||
this.emit();
|
||||
});
|
||||
}
|
||||
|
||||
signalsToFFT (signals) {
|
||||
signals.forEach((signal, index) => {
|
||||
signal = Utils.filter.process(signal);
|
||||
let fft = new dsp.FFT(this.bufferSize, this.sampleRate);
|
||||
fft.forward(signal);
|
||||
this.spectrums[index] = Utils.data.parseObjectAsArray(fft.spectrum);
|
||||
this.spectrums[index] = Utils.signal.voltsToMicrovolts(this.spectrums[index], true);
|
||||
});
|
||||
}
|
||||
|
||||
scaleLabels () {
|
||||
this.labels = new Array(this.bins / 2).fill()
|
||||
.map((label, index) => {
|
||||
return Math.ceil(index * (this.sampleRate / this.bins));
|
||||
});
|
||||
}
|
||||
|
||||
filterBands () {
|
||||
for (let band in this.bands) {
|
||||
this.byBand[band] = Utils.filter.filterBand(this.spectrums, this.labels, this.bands[band]);
|
||||
}
|
||||
}
|
||||
|
||||
filterLabels () {
|
||||
// Skip every 8, add uni (too many labels issue)
|
||||
this.labels = this.labels.map((label, index, labels) => {
|
||||
let eighth = index % constants.scale.skipLabels === 0;
|
||||
let last = index === (labels.length - 1);
|
||||
return eighth || last ? `${label} ${constants.units.hertz}` : ``;
|
||||
});
|
||||
}
|
||||
|
||||
emit () {
|
||||
this.signal.io.emit(constants.events.fft, {
|
||||
data: this.spectrums,
|
||||
labels: this.labels,
|
||||
theta: this.byBand.theta.spectrums,
|
||||
delta: this.byBand.delta.spectrums,
|
||||
alpha: this.byBand.alpha.spectrums,
|
||||
beta: this.byBand.beta.spectrums,
|
||||
gamma: this.byBand.gamma.spectrums
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
const FFT = require('./fft.module');
|
||||
const TimeSeries = require('./time-series.module');
|
||||
const Topo = require('./topo.module');
|
||||
|
||||
module.exports = {
|
||||
FFT,
|
||||
TimeSeries,
|
||||
Topo
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
'use strict';
|
||||
|
||||
const Utils = require('../utils');
|
||||
const constants = require('../constants');
|
||||
|
||||
module.exports = class TimeSeries {
|
||||
|
||||
constructor ({ Signal }) {
|
||||
this.signal = Signal;
|
||||
this.sampleRate = constants.signal.sampleRate;
|
||||
this.windowSize = constants.time.windowSize;
|
||||
this.timeline = Utils.data.generateTimeline(constants.time.timeline, constants.time.skip, constants.units.seconds);
|
||||
this.timeSeries = this.create(constants.connector.channels);
|
||||
this.amplitudes = [];
|
||||
this.subscribe();
|
||||
}
|
||||
|
||||
subscribe () {
|
||||
this.signal.emitter.on(constants.events.signal, (signal) => {
|
||||
this.offsetForGrid(signal);
|
||||
this.signalToAmplitudes(signal);
|
||||
this.filter();
|
||||
this.emit();
|
||||
});
|
||||
}
|
||||
|
||||
create (channelAmount) {
|
||||
let timeSeries = new Array(channelAmount).fill([]);
|
||||
return timeSeries.map((channel, channelNumber) => {
|
||||
return new Array((this.sampleRate * this.windowSize))
|
||||
.fill(0)
|
||||
.map((amplitude) => {
|
||||
return Utils.signal.offsetForGrid(amplitude, channelNumber, constants.connector.channels, this.signal.scale);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
offsetForGrid (signal) {
|
||||
this.timeSeries.forEach((channel, channelIndex) => {
|
||||
let offset = signal[channelIndex][signal[channelIndex].length - 1];
|
||||
channel.push(Utils.signal.offsetForGrid(offset, channelIndex, constants.connector.channels, this.signal.scale));
|
||||
channel.shift();
|
||||
});
|
||||
}
|
||||
|
||||
filter () {
|
||||
this.timeSeries.forEach((signal) => {
|
||||
signal = Utils.filter.process(signal);
|
||||
});
|
||||
}
|
||||
|
||||
signalToAmplitudes (signal) {
|
||||
this.amplitudes = signal.map((channel) => {
|
||||
let microvolts = Utils.signal.voltsToMicrovolts(channel[channel.length - 1])[0];
|
||||
return `${Math.round(microvolts)} ${constants.units.microvolts}`;
|
||||
});
|
||||
}
|
||||
|
||||
emit () {
|
||||
this.signal.io.emit(constants.events.time, {
|
||||
data: this.timeSeries,
|
||||
amplitudes: this.amplitudes,
|
||||
timeline: this.timeline
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
'use strict';
|
||||
|
||||
const topogrid = require('topogrid');
|
||||
const Utils = require('../utils');
|
||||
const constants = require('../constants');
|
||||
|
||||
module.exports = class Topo {
|
||||
|
||||
constructor ({ Signal }) {
|
||||
this.signal = Signal;
|
||||
this.sampleRate = constants.signal.sampleRate;
|
||||
this.grid = [];
|
||||
this.subscribe();
|
||||
}
|
||||
|
||||
subscribe () {
|
||||
this.signal.emitter.on(constants.events.signal, (signal) => {
|
||||
this.signalToGrid(signal);
|
||||
this.emit();
|
||||
});
|
||||
}
|
||||
|
||||
signalToGrid (signal) {
|
||||
|
||||
let grid = [];
|
||||
|
||||
signal.forEach((channel) => {
|
||||
grid.push(channel[channel.length - 1]);
|
||||
});
|
||||
|
||||
/**
|
||||
* params: Parameters for the grid [x,y,z] where x is the min
|
||||
* of the grid, y is the Max of the grid and z is the number of points
|
||||
* x: coordinates of the data
|
||||
* y: coordinates of the data
|
||||
* grid: data = [10,0,0,0,0,0,-10,30,25]; // the data values
|
||||
*/
|
||||
this.grid = topogrid.create(
|
||||
constants.topo.x,
|
||||
constants.topo.y,
|
||||
grid,
|
||||
constants.topo.params
|
||||
);
|
||||
}
|
||||
|
||||
emit () {
|
||||
this.signal.io.emit(constants.events.topo, {
|
||||
data: this.grid
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const Signal = require('./signal.provider');
|
||||
const Motion = require('./motion.provider');
|
||||
|
||||
module.exports = {
|
||||
Signal,
|
||||
Motion
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
|
||||
const constants = require('../constants');
|
||||
const Utils = require('../utils');
|
||||
|
||||
module.exports = class Motion {
|
||||
|
||||
constructor ({ io }) {
|
||||
this.io = io;
|
||||
this.auxData = [];
|
||||
this.count = 0;
|
||||
}
|
||||
|
||||
capture ({ auxData }) {
|
||||
|
||||
if (Utils.signal.isSimulated()) {
|
||||
this.simulate();
|
||||
} else {
|
||||
if (this.hasMotion(auxData)) {
|
||||
this.auxData = this.amplify(auxData);
|
||||
this.emit();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
hasMotion (auxData) {
|
||||
return auxData.reduce((a, b) => a + b, 0);
|
||||
}
|
||||
|
||||
amplify (auxData) {
|
||||
return auxData.map(axis => Math.round(axis));
|
||||
}
|
||||
|
||||
simulate () {
|
||||
this.count++;
|
||||
|
||||
if (this.count === 10) {
|
||||
this.auxData = [
|
||||
Math.round(Math.random() * 180),
|
||||
Math.round(Math.random() * 180),
|
||||
Math.round(Math.random() * 180)
|
||||
];
|
||||
this.count = 0;
|
||||
|
||||
|
||||
this.emit();
|
||||
}
|
||||
}
|
||||
|
||||
emit () {
|
||||
this.io.emit(constants.events.motion, {
|
||||
data: this.auxData
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
'use strict';
|
||||
|
||||
const EventEmitter = require('events');
|
||||
const Utils = require('../utils');
|
||||
const constants = require('../constants');
|
||||
|
||||
class SignalEmitter extends EventEmitter {}
|
||||
|
||||
module.exports = class Signal {
|
||||
|
||||
constructor ({ io }) {
|
||||
this.io = io;
|
||||
this.emitter = new SignalEmitter();
|
||||
this.bins = constants.signal.bins;
|
||||
this.bufferSize = constants.signal.bufferSize;
|
||||
this.windowRefreshRate = constants.signal.windowRefreshRate;
|
||||
this.windowSize = this.bins / this.windowRefreshRate;
|
||||
this.sampleRate = constants.signal.sampleRate;
|
||||
this.signals = [[],[],[],[],[],[],[],[]];
|
||||
this.sampleNumber = 0;
|
||||
this.init();
|
||||
}
|
||||
|
||||
init () {
|
||||
this.io.on('connection', (socket) => {
|
||||
socket.on(constants.events.filter, (filter) => {
|
||||
Utils.filter.apply(filter);
|
||||
});
|
||||
});
|
||||
|
||||
this.setScale();
|
||||
}
|
||||
|
||||
buffer (sample) {
|
||||
this.sampleNumber++;
|
||||
this.add(sample);
|
||||
|
||||
if (this.sampleNumber === this.bins) {
|
||||
this.emitter.emit(constants.events.signal, [...this.signals]);
|
||||
this.window();
|
||||
}
|
||||
}
|
||||
|
||||
add (sample) {
|
||||
console.log('sample', sample);
|
||||
Object.keys(sample.channelData).forEach((channel, i) => {
|
||||
this.signals[i].push(sample.channelData[channel]);
|
||||
});
|
||||
}
|
||||
|
||||
window () {
|
||||
this.signals = this.signals.map((channel) => {
|
||||
return channel.filter((signal, index) => {
|
||||
return index > (this.windowSize - 1);
|
||||
});
|
||||
});
|
||||
this.sampleNumber = this.bins - this.windowSize;
|
||||
}
|
||||
|
||||
setScale () {
|
||||
if (Utils.signal.isSimulated()) {
|
||||
this.scale = constants.scale.simulated;
|
||||
} else {
|
||||
this.scale = constants.scale.global;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
|
||||
parseObjectAsArray (obj) {
|
||||
var array = [];
|
||||
Object.keys(obj).forEach((key) => {
|
||||
array.push(obj[key]);
|
||||
});
|
||||
return array;
|
||||
},
|
||||
|
||||
/**
|
||||
* generateTimeline
|
||||
* @param size
|
||||
* @param skip
|
||||
* @param suffix
|
||||
* @returns {Array.<T>}
|
||||
*/
|
||||
generateTimeline (size, skip, suffix) {
|
||||
return new Array(size)
|
||||
.fill()
|
||||
.map((value, index) => index)
|
||||
.filter((value, index) => index % skip === 0)
|
||||
.map((value) => (value ? '-' : '') + value + suffix)
|
||||
.reverse();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
'use strict';
|
||||
|
||||
var Fili = require('fili');
|
||||
|
||||
module.exports = {
|
||||
|
||||
state: {
|
||||
BANDPASS: '1-50',
|
||||
NOTCH: '60',
|
||||
VERTSCALE: '50',
|
||||
VERTALGO: 'LOG',
|
||||
SMOOTH: '0-75',
|
||||
POLARITY: 'YES',
|
||||
MAXFREQUENCY: '60'
|
||||
},
|
||||
|
||||
apply (filter) {
|
||||
if (!filter) return;
|
||||
let [id, value] = filter.split(':');
|
||||
this.state[id] = value;
|
||||
},
|
||||
|
||||
process (signal) {
|
||||
Object.keys(this.state).forEach((key) => {
|
||||
let filter = key.toLowerCase();
|
||||
if (filter in this && typeof this[filter] === 'function') {
|
||||
// @TODO: apply all filters dynamically
|
||||
//signal = this[signal](signal);
|
||||
}
|
||||
});
|
||||
signal = this.notch(signal);
|
||||
return signal;
|
||||
},
|
||||
|
||||
notch (signal) {
|
||||
|
||||
if (this.state.NOTCH === 'NONE') return signal;
|
||||
|
||||
var notchValue = parseInt(this.state.NOTCH);
|
||||
var iirCalculator = new Fili.CalcCascades();
|
||||
var notchFilterCoeffs = iirCalculator.bandstop({
|
||||
order: 2, // cascade 3 biquad filters (max: 12)
|
||||
characteristic: 'butterworth',
|
||||
Fs: 250, // sampling frequency
|
||||
Fc: notchValue,
|
||||
F1: notchValue - 1,
|
||||
F2: notchValue + 1,
|
||||
gain: 0, // gain for peak, lowshelf and highshelf
|
||||
preGain: false // adds one constant multiplication for highpass and lowpass
|
||||
// k = (1 + cos(omega)) * 0.5 / k = 1 with preGain == false
|
||||
});
|
||||
|
||||
var notchFilter = new Fili.IirFilter(notchFilterCoeffs);
|
||||
|
||||
return notchFilter.multiStep(signal);
|
||||
},
|
||||
|
||||
bandpass (signal) {
|
||||
|
||||
// @TODO: Finish bandpass filter
|
||||
return filter;
|
||||
|
||||
var iirCalculator = new Fili.CalcCascades();
|
||||
|
||||
var hpFilterCoeffs = iirCalculator.highpass({
|
||||
order: 3, // cascade 3 biquad filters (max: 12)
|
||||
characteristic: 'butterworth',
|
||||
Fs: sampleRate, // sampling frequency
|
||||
Fc: 1,
|
||||
gain: 0, // gain for peak, lowshelf and highshelf
|
||||
preGain: false // adds one constant multiplication for highpass and lowpass
|
||||
// k = (1 + cos(omega)) * 0.5 / k = 1 with preGain == false
|
||||
});
|
||||
|
||||
var hpFilter = new Fili.IirFilter(hpFilterCoeffs);
|
||||
|
||||
var lpFilterCoeffs = iirCalculator.lowpass({
|
||||
order: 3, // cascade 3 biquad filters (max: 12)
|
||||
characteristic: 'butterworth',
|
||||
Fs: sampleRate, // sampling frequency
|
||||
Fc: 50,
|
||||
gain: 0, // gain for peak, lowshelf and highshelf
|
||||
preGain: false // adds one constant multiplication for highpass and lowpass
|
||||
// k = (1 + cos(omega)) * 0.5 / k = 1 with preGain == false
|
||||
});
|
||||
|
||||
var lpFilter = new Fili.IirFilter(lpFilterCoeffs);
|
||||
|
||||
// @TODO: get from state which filter to use, then return it based on state settings
|
||||
},
|
||||
|
||||
filterBand (spectrums, labels, range) {
|
||||
if (!spectrums ) return console.log('Please provide spectrums');
|
||||
spectrums = spectrums.map(function (channel) {
|
||||
return channel.filter(function (spectrum, index) {
|
||||
return labels[index] >= range[0] && labels[index] <= range[1];
|
||||
});
|
||||
});
|
||||
spectrums = [spectrums.map(function (channel) {
|
||||
if (channel.length) {
|
||||
return channel.reduce(function (a, b) {
|
||||
return a + b;
|
||||
}) / channel.length;
|
||||
} else return channel;
|
||||
})];
|
||||
return {
|
||||
spectrums: spectrums,
|
||||
labels: labels
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
const data = require('./data.util');
|
||||
const filter = require('./filter.util');
|
||||
const signal = require('./signal.util');
|
||||
|
||||
module.exports = {
|
||||
data,
|
||||
filter,
|
||||
signal
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
var argv = require('yargs').argv;
|
||||
const constants = require('../constants');
|
||||
|
||||
module.exports = {
|
||||
|
||||
voltsToMicrovolts (volts, log) {
|
||||
if (!Array.isArray(volts)) {
|
||||
volts = [volts];
|
||||
}
|
||||
return volts.map((volt) => {
|
||||
return log ? Math.log10(Math.pow(10, 6) * volt) : Math.pow(10, 6) * volt;
|
||||
});
|
||||
},
|
||||
|
||||
offsetForGrid (amplitude, channelNumber, channelAmount = 8, scale = 1.5) {
|
||||
// @TODO: initial dataset is returning messed up values
|
||||
let scaledAmplitude = amplitude * Math.pow(10, scale);
|
||||
let offset = 2 * (channelAmount - channelNumber) - 1;
|
||||
return parseFloat(scaledAmplitude + offset);
|
||||
},
|
||||
|
||||
isSimulated () {
|
||||
return !!(argv._[0] && argv._[0] === constants.connector.simulateFlag);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/***********************************************************************************************
|
||||
* User Configuration.
|
||||
**********************************************************************************************/
|
||||
/** Map relative paths to URLs. */
|
||||
const map: any = {
|
||||
'smoothie': 'vendor/smoothie/smoothie.js',
|
||||
'ng2-charts': 'vendor/ng2-charts/bundles/ng2-charts.js',
|
||||
'socket.io-client': 'vendor/socket.io-client/socket.io.js',
|
||||
'chroma-js': 'vendor/chroma-js/chroma.js',
|
||||
'plotly': 'vendor/plotly.js/dist/plotly.js',
|
||||
'brainbrowser': 'vendor/brainbrowser/build/brainbrowser-2.3.0/brainbrowser.surface-viewer.min.js'
|
||||
};
|
||||
|
||||
/** User packages configuration. */
|
||||
const packages: any = {
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/***********************************************************************************************
|
||||
* Everything underneath this line is managed by the CLI.
|
||||
**********************************************************************************************/
|
||||
const barrels: string[] = [
|
||||
// Angular specific barrels.
|
||||
'@angular/core',
|
||||
'@angular/common',
|
||||
'@angular/compiler',
|
||||
'@angular/http',
|
||||
'@angular/router',
|
||||
'@angular/platform-browser',
|
||||
'@angular/platform-browser-dynamic',
|
||||
|
||||
// Thirdparty barrels.
|
||||
'rxjs',
|
||||
|
||||
// App specific barrels.
|
||||
'app',
|
||||
'app/shared',
|
||||
'app/frequency',
|
||||
'app/time-series',
|
||||
'app/nav',
|
||||
'app/frequency-bands',
|
||||
'app/frequency-band',
|
||||
'app/topo',
|
||||
'app/filters',
|
||||
'app/motion',
|
||||
/** @cli-barrel */
|
||||
];
|
||||
|
||||
const cliSystemConfigPackages: any = {};
|
||||
barrels.forEach((barrelName: string) => {
|
||||
cliSystemConfigPackages[barrelName] = { main: 'index' };
|
||||
});
|
||||
|
||||
/** Type declaration for ambient System. */
|
||||
declare var System: any;
|
||||
|
||||
// Apply the CLI SystemJS configuration.
|
||||
System.config({
|
||||
map: {
|
||||
'@angular': 'vendor/@angular',
|
||||
'rxjs': 'vendor/rxjs',
|
||||
'main': 'main.js'
|
||||
},
|
||||
packages: cliSystemConfigPackages
|
||||
});
|
||||
|
||||
// Apply the user's configuration.
|
||||
System.config({ map, packages });
|
||||
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário