This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pylab as plt | |
import numpy as np | |
def gen(x, evolve, project, n=1000, sigma=.1): | |
y = [] | |
for i in xrange(int(n)): | |
y.append(np.dot(project, x)) | |
x = np.dot(evolve, x) | |
x = np.clip(x, -100, 100) | |
x += np.random.randn(*x.shape) * sigma |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Warning: A new session was created in folder 'session_1' | |
> In session.session>session.instance at 79 | |
In abstract_node.get_data_dir at 40 | |
In abstract_node.get_full_dir at 36 | |
In abstract_node.initialize at 35 | |
In abstract_node.run at 88 | |
In meeg at 17 | |
Error using datahash.DataHash>CoreHash (line 319) | |
Java exception occurred: | |
java.lang.OutOfMemoryError: Java heap space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear all; clear path; | |
addpath('/data1/toolbox/fieldtrip_new/'); | |
ft_defaults; | |
fname = '/data1/import/agboekenweek/import2/03/eeg_03.bdf' | |
cfg.dataset = fname | |
hdr = ft_read_header(fname) | |
evt = ft_read_event(fname) | |
dat = ft_read_data(fname) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# License: BSD 3-clause | |
# Author: Boris Reuderink | |
import logging, re, os.path, StringIO, itertools | |
from ConfigParser import SafeConfigParser | |
import numpy as np | |
# TODO: | |
# - add encoding of commas (\1) | |
# - verify units for resolution in UTF8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging, argparse, itertools | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy import signal | |
import eegtools | |
log = logging.getLogger(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It can be convenient to generate a series of related, but different functions. | |
For example, I had to evaluate a statistical model with different parameters. | |
But the results were surprising, as can be seen with this simplified example: | |
>>> funs = [lambda : x for x in range(10)] | |
>>> print [f() for f in funs] | |
[9, 9, 9, 9, 9, 9, 9, 9, 9, 9] | |
I would have expected each of these functions to return a different value. | |
The same problem occurs when we define a regular function: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mindplay.h" | |
#define FPS 30 | |
int main(void) | |
{ | |
mp_api_t mp; | |
mp_response_t *response = NULL; | |
float p; | |
/* To start using MindPlay, we setup an API with with a server address, a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Initialize API: | |
mp = mindplay.init('localhost:5000', 'test_user', '1') | |
for i=0,10000 do | |
print('Frame ' .. i .. '.'); | |
-- Update transfers in progress: | |
if (i % math.floor(FPS/3)) == 0 then | |
-- Perform (non-blocking) request for a detection: | |
print('Requesting prediction...') | |
response = mindplay.request_detection(mp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float mp_detection(mp_response_t *response, const char *detector_name) | |
{ | |
json_t *json; | |
json_error_t error; | |
float p; | |
if (!response->ready) { | |
return NAN; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import numpy as np | |
import requests | |
for i in range(1000): | |
# get some EEG samples | |
r = requests.get('http://localhost:5000/eeg/%d' % i) | |
S = np.fromstring(r.json['samples'].decode('base64'), np.float32) | |
S.shape = r.json['shape'] | |
print 'Received:', r.json.keys(), S.shape |