Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
289 commits
Select commit Hold shift + click to select a range
1416e8e
clean up shared analysis folder
sijia66 Jun 27, 2020
9667667
updated the install reqs and fixed some minor bugs
sijia66 Jun 29, 2020
57f3906
add optitrack python files
sijia66 Jun 30, 2020
9422b67
fix relative imports
leoscholl Jul 7, 2020
6acf627
add a few more dependencies, take pyaudio for now
sijia66 Jul 13, 2020
402e548
correct the window size to 2D monitor
sijia66 Jul 14, 2020
c8a6ef4
specify oS and python versions
sijia66 Jul 14, 2020
6e4df9c
the interface bet. mocap NatNet interface and BMI3
sijia66 Jul 14, 2020
d1d581d
test optitrack interface
sijia66 Jul 15, 2020
a821be5
add update_freq and dtype to optitrack client
sijia66 Jul 15, 2020
082522f
added simulation feature to the optitrack client
sijia66 Jul 15, 2020
5e84e1d
inital mocap and BMI3D integration
sijia66 Jul 16, 2020
bac4a97
fixed erray compatibility in saving hdf data
sijia66 Jul 21, 2020
894cacd
new optitrack interface with c# streamer
sijia66 Jul 29, 2020
93c570a
tests on optitrack
sijia66 Aug 11, 2020
dbe2501
Including package for reward system
sijia66 Aug 11, 2020
374049a
Reward system calibration and test file
pavi-rajes Aug 11, 2020
57c89e8
reward system test
pavi-rajes Aug 11, 2020
e7e8622
update mrograph
leoscholl Aug 11, 2020
ec9e04a
init linear decoder
leoscholl Aug 11, 2020
41817af
add windows batch testing script
leoscholl Aug 11, 2020
01253ee
small changes to db and sim bmi test
leoscholl Aug 11, 2020
4c6c549
initial upload for ecube neural streaming lib
pavi-rajes Aug 12, 2020
abd12fb
Merge branch 'unstable_py3' of github.com:aolabNeuro/brain-python-int…
pavi-rajes Aug 12, 2020
d1cc436
update linear decoder
leoscholl Aug 21, 2020
4d9b1a5
linear decoder working pos
leoscholl Aug 24, 2020
9004459
init vel scale decoder
leoscholl Aug 24, 2020
b0dcd20
aolab reward system interface with bmi3D
pavi-rajes Aug 24, 2020
0ccd633
ao lab reward system interface
pavi-rajes Aug 24, 2020
e363d25
update in reward timing variable names
pavi-rajes Aug 24, 2020
2575e2a
mouse and keyboard control
leoscholl Aug 25, 2020
a8a5816
cleanup for code review
leoscholl Sep 5, 2020
9c9f7bb
code review notebook
leoscholl Sep 5, 2020
f76776d
changes following code review
leoscholl Sep 15, 2020
44d96b1
Merge branch 'unstable_py3' into leo
leoscholl Sep 15, 2020
0608374
fix test foder
leoscholl Sep 15, 2020
2d44e59
Merge pull request #6 from aolabNeuro/leo
leoscholl Sep 15, 2020
e8b82a0
add abstract filter class
leoscholl Sep 21, 2020
4a80397
init laser
leoscholl Sep 21, 2020
14c0be8
init mouse/debug bmi
leoscholl Sep 21, 2020
d08c18e
update arduino gpio using pyfirmata
leoscholl Sep 22, 2020
7f65fe8
fix threading
leoscholl Sep 28, 2020
0b25651
Updating import path for built in tasks
sijia66 Sep 29, 2020
08af559
laser experiment and other laser fixes
leoscholl Sep 30, 2020
4510aca
delete unnecessary
leoscholl Sep 30, 2020
955d0f3
Merge branch 'unstable_py3' into dev-carmena
leoscholl Sep 30, 2020
398b275
implement features in setup
leoscholl Sep 30, 2020
0b5eef3
Merge branch 'unstable_py3' into leo
leoscholl Oct 1, 2020
edb3a98
Merge branch 'unstable_py3' of github.com:aolabNeuro/brain-python-int…
sijia66 Oct 2, 2020
ee223f2
Manual reward count in report
sijia66 Oct 6, 2020
78cfabc
opti: check if the send command is supported
sijia66 Oct 16, 2020
e5d099f
update gpio feature
leoscholl Oct 22, 2020
b5868a1
fix feature bugs
leoscholl Oct 22, 2020
b9099c1
training task and windows browser support
leoscholl Oct 22, 2020
88d6bc4
Merge remote-tracking branch 'upstream/develop' into dev-carmena
leoscholl Oct 24, 2020
6be70db
fix webclient bugs
leoscholl Oct 26, 2020
7766e7d
init sync marker
leoscholl Oct 26, 2020
fc093cb
cleanup
leoscholl Oct 26, 2020
2ffe53d
cleanup
leoscholl Oct 29, 2020
a49cfbc
Merge branch 'leo' into dev-carmena
leoscholl Oct 29, 2020
bc133b7
merging
leoscholl Oct 29, 2020
37e3f1f
update start script for virtual environment
leoscholl Nov 20, 2020
fed6cea
Merge pull request #8 from aolabNeuro/leo
leoscholl Nov 20, 2020
602f3f3
Merge branch 'unstable_py3' of github.com:aolabNeuro/brain-python-int…
leoscholl Nov 20, 2020
582f433
fix setup, add controls, init linear decoder on web gui
leoscholl Nov 23, 2020
d3dcc77
Merge branch 'unstable_py3' into leo
leoscholl Nov 23, 2020
3c3dcba
Revert "merging"
leoscholl Dec 1, 2020
b548bae
Merge branch 'leo' into dev-carmena
leoscholl Dec 1, 2020
1e955e4
refresh celery
leoscholl Dec 6, 2020
f0500e1
update manual controls
leoscholl Dec 8, 2020
3b0792b
add optitrack transformation
leoscholl Dec 9, 2020
d9a01c7
update optitrack. hdf still broken
leoscholl Dec 11, 2020
61b8fcd
ui enhancements
leoscholl Dec 14, 2020
6fba1be
ui fixes
leoscholl Dec 14, 2020
79cf6e1
minor ui tweaks
leoscholl Dec 15, 2020
0f93c6b
Merge pull request #12 from aolabNeuro/dev-carmena
leoscholl Dec 15, 2020
6182de2
Merge remote-tracking branch 'upstream/develop' into leo
leoscholl Dec 16, 2020
d990201
merge from upstream/develop
leoscholl Dec 16, 2020
a33a10f
update analysis
leoscholl Dec 17, 2020
02b3acf
fix sequence and generators interface, flip y coordinate in manual task
leoscholl Dec 23, 2020
0920088
minor bugfixes
leoscholl Jan 6, 2021
a4ef649
tracking update for rigid bodies
leoscholl Jan 6, 2021
b9bb84c
trial index
leoscholl Jan 6, 2021
9dfba53
fix manaul input
leoscholl Jan 6, 2021
f40abf0
optitrack hotfixes
leoscholl Jan 6, 2021
6e44794
Merge branch 'leo' of https://github.com/aolabNeuro/brain-python-inte…
leoscholl Jan 6, 2021
3a53cbb
manualcontrol hotfix
leoscholl Jan 6, 2021
984b990
fix get_desc and seqlist
leoscholl Jan 12, 2021
e0533e8
debugging window and tracker issues
leoscholl Jan 14, 2021
8050876
new 2d pipeline
leoscholl Feb 10, 2021
39af148
hack to fix blending issues
leoscholl Feb 12, 2021
9394e8e
update window defaults and add cursor parameters
leoscholl Feb 12, 2021
e6e1db5
add optitrack playback from csv
leoscholl Feb 17, 2021
9a43dba
fix hdf cleanup issue with optitrack feature
leoscholl Feb 26, 2021
7849a17
cleanup mp code
leoscholl Feb 26, 2021
911d9d9
init sync protocol
leoscholl Mar 1, 2021
5736da4
update sync feature
leoscholl Mar 9, 2021
dae7ade
add ecube start/stop
leoscholl Mar 10, 2021
24c1fe3
update sync features
leoscholl Mar 24, 2021
36e1789
hotfixes
leoscholl Mar 25, 2021
65b2d85
add reward sound
leoscholl Mar 26, 2021
bef9cc8
make hdf files self contained
leoscholl Mar 28, 2021
ef2f1bc
add trial info to sinks
leoscholl Mar 30, 2021
601a45e
fix task logged trials
leoscholl Mar 30, 2021
c198e86
update to sync version 1
leoscholl Mar 31, 2021
3bbc197
Merge pull request #42 from aolabNeuro/leo
leoscholl Mar 31, 2021
cd6cc7d
refresh
leoscholl Mar 31, 2021
5933a9c
fix hold sync event
leoscholl Apr 4, 2021
f1394d7
cleanup trial end states in fsm
leoscholl Apr 4, 2021
67f2b1e
refresh
leoscholl Apr 5, 2021
bbcb308
fix compatability on non-rig machines
leoscholl Apr 5, 2021
0d0199d
fix targets not being hidden at beginning of exp
leoscholl Apr 6, 2021
93a6ec5
Merge pull request #48 from aolabNeuro/leo
leoscholl Apr 6, 2021
864b669
Merge branch 'rig' of github.com:aolabNeuro/brain-python-interface in…
leoscholl Apr 6, 2021
b2d8c55
fix conflicting sync
leoscholl Apr 6, 2021
c618a51
fix runserver.sh environment issue
leoscholl Apr 6, 2021
96290ca
bump sync version
leoscholl Apr 6, 2021
821b26e
add target replay task
leoscholl Apr 7, 2021
8f93b7e
add sync latency measurement and delay before stop
leoscholl Apr 13, 2021
0300d11
bump sync version
leoscholl Apr 13, 2021
5f4d7e5
add delay state to target capture task
leoscholl Apr 13, 2021
15ac8aa
fix parameter tooltips
leoscholl Apr 13, 2021
99e0f4a
add reach direction task
leoscholl Apr 13, 2021
f2971c2
add penalty sounds
leoscholl Apr 13, 2021
30cbe94
change ecube feature to allow headstage recording
leoscholl Apr 13, 2021
66ae781
update ecube datasource
leoscholl Apr 14, 2021
9846f1c
make features more robust to errors
leoscholl Apr 14, 2021
bf815c6
fix exp_end and first cycle sync issues
leoscholl Apr 14, 2021
25a0d88
change reach start to reach radius
leoscholl Apr 15, 2021
6adef61
add new penalty sound
leoscholl Apr 15, 2021
acd1558
update save_data for eventual syncing of ecube
leoscholl Apr 15, 2021
6829b4c
remove quack
leoscholl Apr 15, 2021
b6a6db9
fix target visible at beginning of exp
leoscholl Apr 15, 2021
a2f6317
ignore issues with overwriting sync events for now
leoscholl Apr 15, 2021
832e8b5
fix sync exp_start and exp_end, js parameters
leoscholl Apr 15, 2021
149f76b
fix order of init
leoscholl Apr 15, 2021
e3f62cc
Merge pull request #56 from aolabNeuro/leo
leoscholl Apr 16, 2021
f7b58b7
larger string for event names
leoscholl Apr 16, 2021
6682127
refactor manual control for reach angle success
leoscholl Apr 19, 2021
b6e89b6
add discrete target generator
leoscholl Apr 20, 2021
e04c2a6
update report stats
leoscholl Apr 21, 2021
e4d0077
fix description
leoscholl Apr 22, 2021
417300a
update display settings
leoscholl Apr 22, 2021
faae3fc
simplify runserver display selection
leoscholl Apr 22, 2021
b6018a1
move middle target
leoscholl Apr 23, 2021
fca107d
fix missing max attempts
leoscholl Apr 23, 2021
fba44f2
remove unwanted robotframework package
leoscholl Apr 26, 2021
c306314
refresh
leoscholl Apr 26, 2021
80d7136
modify discrete target locations
leoscholl Apr 27, 2021
8aa341b
change task log to always append
leoscholl Apr 28, 2021
4f5b261
add remote database
leoscholl Apr 29, 2021
8e4f6f2
fix ecube datasource
leoscholl Apr 29, 2021
87e5bb8
Merge pull request #52 from aolabNeuro/rig
leoscholl Apr 30, 2021
108ba2f
Merge branch 'leo' of https://github.com/aolabNeuro/brain-python-inte…
leoscholl Apr 30, 2021
de1747f
Merge pull request #60 from aolabNeuro/leo
leoscholl Apr 30, 2021
7460f8d
improve ecube logging
leoscholl May 4, 2021
7c87559
fix ecube/optitrack pre_init errors
leoscholl May 11, 2021
42a2b3e
fix ecube headstage sources
leoscholl May 11, 2021
ff40616
allow sequences to be added separately
leoscholl May 15, 2021
48dd2f2
fix annotations, improve traits
leoscholl May 16, 2021
9ffb8d4
add metadata, move subject to metadata
leoscholl May 17, 2021
5c25130
fix task copying
leoscholl May 17, 2021
933542d
fix some ui sequence, copy bugs
leoscholl May 19, 2021
1e8256a
init ecube file load
leoscholl May 19, 2021
3a2cb0d
fix ecube to cleanup on errors
leoscholl May 20, 2021
2e7c5a4
fix bugs
leoscholl May 20, 2021
2cd81e3
hide templates by default
leoscholl May 20, 2021
820f4cf
small bugs
leoscholl May 24, 2021
28cb15e
cleanup
leoscholl May 28, 2021
6c567d1
allow testing on other hosts
leoscholl May 28, 2021
b4ed1f7
ecube not stopping error
leoscholl May 28, 2021
0b45172
Merge branch 'master' into leo-ui-improvements
leoscholl May 28, 2021
3c871e6
fix ui bugs
leoscholl May 28, 2021
eacba35
change db backend
leoscholl May 29, 2021
076dfa0
rename laser feature
leoscholl May 29, 2021
06887fd
Merge pull request #65 from aolabNeuro/leo-ui-improvements
leoscholl May 29, 2021
1ba4183
Merge pull request #63 from aolabNeuro/master
leoscholl May 29, 2021
222d902
update requirements
leoscholl May 29, 2021
fe6d2de
fix laser task
leoscholl Jun 4, 2021
8c4348f
revert digitalwave to mask only
leoscholl Jun 9, 2021
80ede1f
fix hdf cleanup bug
leoscholl Jun 9, 2021
4a0e6c8
fix fps bug; bump sync version
leoscholl Jun 18, 2021
341f057
Merge pull request #76 from aolabNeuro/master
leoscholl Jun 18, 2021
5d5018b
Merge branch 'rig' of github.com:aolabNeuro/brain-python-interface in…
leoscholl Jun 18, 2021
5abf826
laser fixes
leoscholl Jun 30, 2021
a0c7cdc
Merge pull request #79 from aolabNeuro/master
leoscholl Jun 30, 2021
185775e
switch to multiprocessing
leoscholl Jul 15, 2021
f44a152
fix required fields
leoscholl Jul 23, 2021
dbdde77
make manual input quality rolling average
leoscholl Jul 23, 2021
b9235a7
fix start_wait bug in conditions
leoscholl Jul 23, 2021
d8469e2
Merge branch 'master' into leo-fix-issues
leoscholl Jul 23, 2021
fb0d458
fix notes #80
leoscholl Jul 23, 2021
9748758
fix trial report bug
leoscholl Jul 23, 2021
f942a0b
fix typo
leoscholl Jul 23, 2021
63e887a
fix celery
leoscholl Jul 25, 2021
c76eeef
hacky change to allow multiple hold times
leoscholl Jul 27, 2021
9386d5a
adjust input quality window size
leoscholl Jul 27, 2021
4ca208a
include server logs in runserver_log
leoscholl Jul 27, 2021
dc845fe
Merge branch 'leo-conditions-table' into leo-fix-issues
leoscholl Jul 27, 2021
5e6e8c2
change quality window size
leoscholl Jul 27, 2021
c9e6f12
add list of hold times
leoscholl Jul 29, 2021
7908a6e
revert target_capture_task, add features to gen_feats
leoscholl Jul 30, 2021
0e4ee45
add remote host
leoscholl Jul 30, 2021
7998e51
Merge branch 'leo-fix-issues' of https://github.com/aolabNeuro/brain-…
leoscholl Jul 30, 2021
a56130a
Merge branch 'leo-conditions-table' into leo-fix-issues
leoscholl Jul 30, 2021
9d307ef
add new buzzer
leoscholl Jul 30, 2021
019b2a9
ignore square brackets
leoscholl Jul 31, 2021
33c26a7
Merge pull request #82 from aolabNeuro/leo-fix-issues
leoscholl Aug 1, 2021
c409fcf
Merge pull request #83 from aolabNeuro/master
leoscholl Aug 1, 2021
ee837fa
screen update after model updates
leoscholl Aug 6, 2021
b4a426f
fix #72
leoscholl Aug 6, 2021
ed27306
ecube test actually does something
leoscholl Aug 6, 2021
1b72fc0
fix #70
leoscholl Aug 6, 2021
0c49f38
Merge pull request #85 from aolabNeuro/master
leoscholl Aug 7, 2021
1ce5483
fix tables syntax while saving clda data
sijia66 Aug 10, 2021
6e7c06d
Merge pull request #86 from aolabNeuro/upgrade-tables-syntax-in-savin…
sijia66 Aug 11, 2021
b87cce8
add reward buttons
leoscholl Aug 12, 2021
ce08c55
add transparent delay
leoscholl Aug 12, 2021
079c155
cleanup
leoscholl Aug 12, 2021
a735f3c
fix target replay
leoscholl Aug 20, 2021
04b6a8c
add cursor pause feature
leoscholl Aug 21, 2021
9e4c559
Merge branch 'master' into rig
leoscholl Aug 21, 2021
2125386
add touch/mousepos features
leoscholl Aug 27, 2021
bc8a32a
modify pause
leoscholl Sep 1, 2021
737b586
Merge branch 'master' into rig
leoscholl Sep 1, 2021
1c55b15
Merge branch 'master' of https://github.com/aolabNeuro/brain-python-i…
leoscholl Sep 4, 2021
0e7b273
update touch
leoscholl Sep 6, 2021
bff5e39
change reward to singleton
leoscholl Sep 7, 2021
4f9b0b9
fix alpha blending?
leoscholl Sep 8, 2021
c86e587
Merge branch 'master' into leo-new-features
leoscholl Sep 8, 2021
d9df334
fix controls
leoscholl Sep 8, 2021
a93d026
patch ecube saving bug
leoscholl Sep 10, 2021
1e1b750
add descriptions
leoscholl Sep 13, 2021
dc45b5d
update buzzer sound
leoscholl Sep 13, 2021
8f30799
Merge branch 'master' into rig
leoscholl Sep 13, 2021
620c1ee
add bounding to manual velocity control
sijia66 Sep 23, 2021
a388f84
attempt to fix intermittent reward disconnection
leoscholl Sep 27, 2021
ef7ac33
add servernode terminal
leoscholl Sep 27, 2021
9a56b56
Merge pull request #95 from aolabNeuro/bound-manual-input-velocity-co…
sijia66 Sep 29, 2021
716406a
Merge branch 'rig'
leoscholl Oct 1, 2021
371a571
numeric key shortcut for ui controls
leoscholl Oct 1, 2021
5ef4e4e
Merge branch 'master' of https://github.com/aolabNeuro/brain-python-i…
leoscholl Oct 2, 2021
f9c84a5
manual reward bugs
leoscholl Oct 5, 2021
1a690d7
remove touch, fix mouse input
leoscholl Oct 5, 2021
2ece19c
cleanup
leoscholl Oct 5, 2021
51c4338
fix bug opening a lot of new taskentries
leoscholl Oct 17, 2021
4cf79e1
hotfixes for vr
leoscholl Oct 20, 2021
1159071
Merge branch 'master' of https://github.com/aolabNeuro/brain-python-i…
leoscholl Oct 20, 2021
d71d85f
Enh: change ajax:train_decoder_ajax_handler to read channel names and…
Nov 9, 2021
9e97f04
enable electrode selection in make_bmi
Nov 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ db/*.sql
*.sql.*
*.jpeg
log/*
*.ipynb
*.doctree
tasks/debugging.txt
riglib/plexon/plexfile.py
Expand All @@ -46,5 +45,8 @@ riglib/fsm/fsm.egg-info/*
env/*
tests/*.mat
tests/*.hdf
tests/unit_tests/htmlcov
*.h5
riglib/plexon/Plexfile_utilities.egg-info/*
*.dot
riglib/dio/nidaq/pcidio.py
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Getting started
```bash
sudo xargs apt-get -y install < requirements.system
```
## Linux/OS X
(none at this time)
16.04 64bit

#python version
3.7.8

## Windows
Visual C++ Build tools (for the 'traits' package)
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion analysis/performance_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import tables
from itertools import izip
from riglib.bmi import robot_arms, train


Expand Down
69 changes: 32 additions & 37 deletions analysis/target_capture_task_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
from collections import OrderedDict, defaultdict
import os
import tables
from itertools import izip

from riglib.bmi import robot_arms, train, kfdecoder, ppfdecoder
from db.tracker import models
from db import dbfunctions
from db import dbfunctions as dbfn

Expand Down Expand Up @@ -52,43 +50,40 @@ def __init__(self, *args, **kwargs):
super(ManualControlMultiTaskEntry, self).__init__(*args, **kwargs)

try:
task_msgs = self.hdf.root.task_msgs[:]
# Ignore the last message if it's the "None" transition used to stop the task
if task_msgs[-1]['msg'] == 'None':
task_msgs = task_msgs[:-1]

# ignore "update bmi" messages. These have been removed in later datasets
task_msgs = task_msgs[task_msgs['msg'] != 'update_bmi']

target_index = self.hdf.root.task[:]['target_index'].ravel()
task_msg_dtype = np.dtype([('msg', '|S256'), ('time', '<u4'), ('target_index', 'f8')])
task_msgs_ext = np.zeros(len(task_msgs), dtype=task_msg_dtype)
for k in range(len(task_msgs)):
task_msgs_ext[k]['msg'] = task_msgs[k]['msg']
task_msgs_ext[k]['time'] = task_msgs[k]['time']
try:
task_msgs_ext[k]['target_index'] = target_index[task_msgs[k]['time']]
except:
task_msgs_ext[k]['target_index'] = np.nan

self.task_msgs = task_msgs_ext

## Split the task messages into separate trials
# Split the task messages into separate trials
# A new trial starts in either the 'wait' state or when 'targ_transition' has a target_index of -1
trial_start = np.logical_or(self.task_msgs['msg'] == 'wait', np.logical_and(self.task_msgs['msg'] == 'targ_transition', self.task_msgs['target_index'] == -1))
trial_start = np.logical_or(self.task_msgs['msg'] == b'wait', np.logical_and(self.task_msgs['msg'] == b'targ_transition', self.task_msgs['target_index'] == -1))
trial_start_inds, = np.nonzero(trial_start)
trial_end_inds = np.hstack([trial_start_inds[1:], len(trial_start)])
self.trial_msgs = []
for trial_st, trial_end in izip(trial_start_inds, trial_end_inds):
for trial_st, trial_end in zip(trial_start_inds, trial_end_inds):
self.trial_msgs.append(self.task_msgs[trial_st:trial_end])

# Organize frame data
frame_data = self.hdf.root.task[:]
frame_data_dtype = np.dtype([('cursor', ('f8', 3)), ('manual_input', ('f8', 3))])
if 'sync_square' in frame_data.dtype.names:
frame_data_dtype = np.dtype([('cursor', ('f8', 3)), ('sync', '?')])
frame_data_ext = np.zeros(len(frame_data), dtype=frame_data_dtype)
for k in range(len(frame_data)):
frame_data_ext[k]['cursor'] = frame_data[k]['cursor']
frame_data_ext[k]['manual_input'] = frame_data[k]['manual_input']
if 'sync_square' in frame_data.dtype.names:
frame_data_ext[k]['sync'] = frame_data[k]['sync_square']
self.frame_data = frame_data_ext

except:
print "Couldn't process HDF file. Is it copied?"
print("Couldn't process HDF file. Is it copied?")
import traceback
traceback.print_exc()

if 'target_radius' not in self.params:
if 'target_radius' in self.params:
self.target_radius = self.params['target_radius']
else:
self.target_radius = 2.
if 'cursor_radius' not in self.params:
if 'cursor_radius' in self.params:
self.cursor_radius = self.params['cursor_radius']
else:
self.cursor_radius = 0.4

### Update rate of task
Expand Down Expand Up @@ -781,24 +776,24 @@ def summarize_bmi_performance(date, **kwargs):
'''
for block in dbfn.get_bmi_blocks(date, **kwargs):
te = _get_te(block)
print te
print te.summary()
print(te)
print(te.summary())

def summarize_performance(blocks, **kwargs):
''' For a given date, print out a summary of the BMI performance
'''
for block in blocks:
te = _get_te(block)
print te
print te.summary()
print(te)
print(te.summary())

def compare_perc_correct(te1, te2):
from scipy import stats
end_types1 = te1.get_trial_end_types()
end_types2 = te2.get_trial_end_types()
n_hold_errors = np.sum(end_types['hold_error'][1:]) # No. of hold errors, excluding the first target in the trial target sequence
def fn(end_types): return (end_types['success'], n_hold_errors)
print fn(end_types1)
print(fn(end_types1))
return stats.chi2_contingency(np.array([fn(end_types1), fn(end_types2)]))


Expand All @@ -816,7 +811,7 @@ def dir_change(hdf, step=6):

vel_angle_diff_concat = np.hstack(vel_angle_diff)
mean = circmean(np.abs(vel_angle_diff_concat), high=2*np.pi, low=-2*np.pi)
print mean
print(mean)
return vel_angle_diff, mean

def edge_detect(vec, edge_type='pos'):
Expand Down Expand Up @@ -1011,8 +1006,8 @@ def get_workspace_size(task_entry):
'''
hdf = get_hdf(task_entry)
targets = hdf.root.task[:]['target']
print targets.min(axis=0)
print targets.max(axis=0)
print(targets.min(axis=0))
print(targets.max(axis=0))

def plot_dist_to_targ(task_entry, reach_trajectories=None, targ_dist=10., plot_all=False, ax=None, target=None, update_rate=60., decoder_rate=10., **kwargs):
task_entry = dbfn.lookup_task_entries(task_entry)
Expand Down
58 changes: 28 additions & 30 deletions built_in_tasks/bmimultitasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,10 @@
from riglib.stereo_opengl.window import WindowDispl2D
from riglib.stereo_opengl.primitives import Line


from riglib.bmi.state_space_models import StateSpaceEndptVel2D, StateSpaceNLinkPlanarChain


from .target_capture_task import ScreenTargetCapture

target_colors = {"blue":(0,0,1,0.5),
"yellow": (1,1,0,0.5),
"hibiscus":(0.859,0.439,0.576,0.5),
"magenta": (1,0,1,0.5),
"purple":(0.608,0.188,1,0.5),
"lightsteelblue":(0.690,0.769,0.901,0.5),
"dodgerblue": (0.118,0.565,1,0.5),
"teal":(0,0.502,0.502,0.5),
"aquamarine":(0.498,1,0.831,0.5),
"olive":(0.420,0.557,0.137,0.5),
"chiffonlemon": (0.933,0.914,0.749,0.5),
"juicyorange": (1,0.502,0,0.5),
"salmon":(1,0.549,0.384,0.5),
"wood": (0.259,0.149,0.071,0.5),
"elephant":(0.409,0.409,0.409,0.5)}


np.set_printoptions(suppress=False)

###################
Expand Down Expand Up @@ -161,6 +142,33 @@ def endpoint_assist_simple(cursor_pos, target_pos, decoder_binlen=0.1, speed=0.5
x_assist = np.mat(x_assist.reshape(-1,1))
return x_assist

class SimplePosAssister(SimpleEndpointAssister):

@staticmethod
def endpoint_assist_simple(cursor_pos, target_pos, decoder_binlen=0.1, speed=0.5, target_radius=2., assist_level=0.):
'''
Estimate the next state using a constant velocity estimate moving toward the specified target

Parameters
----------
see SimpleEndtpointAssister for docs

Returns
-------
x_assist : np.ndarray of shape (7, 1)
Control vector to add onto the state vector to assist control.
'''
diff_vec = target_pos - cursor_pos
dist_to_target = np.linalg.norm(diff_vec)
dir_to_target = diff_vec / (np.spacing(1) + dist_to_target)

if dist_to_target > target_radius:
assist_cursor_pos = cursor_pos + speed*dir_to_target
else:
assist_cursor_pos = cursor_pos + speed*diff_vec/2

return assist_cursor_pos.ravel()

class SimpleEndpointAssisterLFC(feedback_controllers.MultiModalLFC):
'''
Docstring
Expand Down Expand Up @@ -212,19 +220,9 @@ class BMIControlMulti(BMILoop, LinearlyDecreasingAssist, ScreenTargetCapture):

is_bmi_seed = False

cursor_color_adjust = traits.OptionsList(*list(target_colors.keys()), bmi3d_input_options=list(target_colors.keys()))

def __init__(self, *args, **kwargs):
super(BMIControlMulti, self).__init__(*args, **kwargs)

def init(self, *args, **kwargs):
sph = self.plant.graphics_models[0]
sph.color = target_colors[self.cursor_color_adjust]
sph.radius = self.cursor_radius
self.plant.cursor_radius = self.cursor_radius
self.plant.cursor.radius = self.cursor_radius
super(BMIControlMulti, self).init(*args, **kwargs)


def create_assister(self):
# Create the appropriate type of assister object
start_level, end_level = self.assist_level
Expand Down
Loading