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
#!/usr/bin/env python | |
''' | |
Quick and dirty hack to get the SIKS dissertation list in LaTeX. | |
''' | |
import argparse, re, operator, itertools, sys | |
parser = argparse.ArgumentParser( | |
description='Convert SIKS dissertation list to LaTeX.') | |
parser.add_argument('txt') | |
parser.add_argument('tex') |
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
#!/usr/bin/env python | |
import argparse, logging | |
from collections import namedtuple | |
import numpy as np | |
# TODO: | |
# - diff scan_code and key_id? | |
LOG_MOUSE_EVENTS = { | |
512 : 'mouse movement', |
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 |
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
-- 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
#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
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
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
# 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
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) |
OlderNewer