Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
0bb688b
refactor and add stop rec
sijia66 Oct 31, 2020
28c2671
set up task code stream eatures
sijia66 Nov 14, 2020
fa8a47c
set up a task code dict
sijia66 Nov 14, 2020
7002846
incor task code stream into the cursor control
sijia66 Nov 14, 2020
94e8e09
add import to nidaq
sijia66 Nov 14, 2020
1288077
initial comedi control push
sijia66 Dec 5, 2020
75a2b13
Merge branch 'sijia' of https://github.com/aolabNeuro/brain-python-in…
sijia66 Dec 5, 2020
7ecd02b
update code streaming features
sijia66 Dec 5, 2020
ef055e5
implemented binary reward
Dec 5, 2020
8b3b8dd
refactor SimKFDecoder and add externally supp enc
sijia66 Dec 18, 2020
a620ed6
SimKFDecoder
sijia66 Dec 19, 2020
0bd9773
replace self.encoder with selected encoder
sijia66 Dec 19, 2020
5a04981
add if to load ssm from func arg
sijia66 Dec 19, 2020
e26cef6
add return to if no self.enc nor suppled enc
sijia66 Dec 19, 2020
6a582c9
fixed typo when assign supp ssm to ssm
sijia66 Dec 19, 2020
669413b
document decoder training params and results
sijia66 Dec 19, 2020
02c589f
add a function to gen encoder sim_c matrix
sijia66 Dec 22, 2020
8fc6954
demo of KF filter
sijia66 Dec 22, 2020
1c4bc71
add a code section on feedback controller
sijia66 Dec 22, 2020
6bb4895
decouple intention est from sim task setup
sijia66 Dec 22, 2020
7669d71
can select the sim param
sijia66 Dec 22, 2020
5ac2419
copy and paste learner
sijia66 Dec 22, 2020
e506bd3
add some comment blocks
sijia66 Dec 22, 2020
395a1c9
set up sim learner
sijia66 Dec 22, 2020
d20097d
set up sim clda smoothbatch feat
sijia66 Dec 23, 2020
3729ba4
add the class to print
sijia66 Dec 23, 2020
db49315
add options to select learner and updater
sijia66 Dec 23, 2020
efa19a8
add a feat to set the debug_flag
sijia66 Dec 23, 2020
964a822
explicitly set up a sim clda system
sijia66 Dec 23, 2020
5b91e98
set up ssm in the sim enc
sijia66 Dec 23, 2020
92ac39f
save filename and print out it after task
sijia66 Dec 29, 2020
c49d625
wait for 5 second before save clda data
sijia66 Dec 29, 2020
0bb5cf0
use py4 tables functions
sijia66 Dec 29, 2020
4c8e2df
minor: print promot
sijia66 Dec 29, 2020
5dbf332
update default batch time and half life
sijia66 Dec 29, 2020
b6f46a9
test scripts to convert digital value to bits
sijia66 Jan 7, 2021
ba1c5c4
add the segment to directly print bits
sijia66 Jan 9, 2021
edda8c0
update control_comedi to assign the ports to zero
sijia66 Jan 14, 2021
2b75f5f
added no windo sim task
sijia66 Jan 19, 2021
4c93753
get enc setup
sijia66 Jan 25, 2021
d2a8250
update task_kf
sijia66 Jan 25, 2021
daae44f
Merge branch 'sijia' of github.com:aolabNeuro/brain-python-interface …
sijia66 Jan 25, 2021
2b63ce7
fix sim_hdf
sijia66 Feb 2, 2021
cd76cda
save multiple kf variables
sijia66 Feb 18, 2021
9b06ea4
incorporate task code into sim_task_KF
sijia66 Mar 13, 2021
c03a07a
build pcidio
sijia66 Mar 13, 2021
9f3a75f
save control_comedi
sijia66 Mar 13, 2021
d2d6f3b
control_comedi swig setup
sijia66 Mar 13, 2021
2c538bb
make the name more reflective
sijia66 Mar 13, 2021
8728e39
Merge branch 'sijia' of https://github.com/aolabNeuro/brain-python-in…
sijia66 Mar 13, 2021
3511399
add sim_neurons poisson profile
sijia66 Apr 1, 2021
13254de
factor out a GenericCosEncWithNoise class
sijia66 Apr 1, 2021
9b7966d
add noise model to the cosine with noise model
sijia66 Apr 1, 2021
37c7253
add noise model as a feature
sijia66 Apr 1, 2021
c008f26
noise model
sijia66 May 11, 2021
febd43c
Merge branch 'sijia' of github.com:aolabNeuro/brain-python-interface …
sijia66 May 11, 2021
5ec8484
add time count down
sijia66 May 25, 2021
74188da
add sync_feature
sijia66 May 25, 2021
d2419dc
Merge branch 'master' into sijia
sijia66 Aug 2, 2021
0843e1d
Update sim clock
sijia66 Aug 7, 2021
01cf917
create HDFSync that only writes to hdf
sijia66 Aug 7, 2021
18181c0
upgrade tables syntax from py2 to py3
sijia66 Aug 10, 2021
7bfa028
turn off screen updates
sijia66 Aug 10, 2021
4ece735
merge after the effects
sijia66 Aug 10, 2021
4840787
add a simple state model
sijia66 Aug 25, 2021
cb9cffa
add hold period
sijia66 Oct 6, 2021
13134e0
update tp lf decoder
sijia66 Apr 19, 2022
4e752c8
update all python files
sijia66 Apr 19, 2022
50b4ffd
change log save position
sijia66 Dec 30, 2022
6f91f47
stop bug fix
sijia66 Jul 26, 2023
a99b93f
draft on decoder change
sijia66 Jul 27, 2023
ec968b2
add full_feature tracking
sijia66 Aug 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
883 changes: 866 additions & 17 deletions built_in_tasks/bmimultitasks.py

Large diffs are not rendered by default.

128 changes: 128 additions & 0 deletions built_in_tasks/cursorControlTasks_saveHDF.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@

from manualcontrolmultitasks import ManualControlMulti
from riglib.stereo_opengl.window import WindowDispl2D
#from bmimultitasks import BMIControlMulti
import pygame
import numpy as np
import copy

#from riglib.bmi.extractor import DummyExtractor
#from riglib.bmi.state_space_models import StateSpaceEndptVel2D
#from riglib.bmi.bmi import Decoder, BMISystem, GaussianStateHMM, BMILoop, GaussianState, MachineOnlyFilter
from riglib import experiment
from features.hdf_features import SaveHDF
from features.task_code_features import TaskCodeStreamer

class CursorControl(ManualControlMulti, WindowDispl2D):
'''
this class implements a python cursor control task for human
'''

def __init__(self, *args, **kwargs):
# just run the parent ManualControlMulti's initialization
self.move_step = 1

# Initialize target location variable
#target location and index have been initializd

super(CursorControl, self).__init__(*args, **kwargs)

def init(self):
pygame.init()



self.assist_level = (0, 0)
super(CursorControl, self).init()

# override the _cycle function
def _cycle(self):
#print(self.state)

#target and plant data have been saved in
#the parent manualcontrolmultitasks

self.move_effector_cursor()
super(CursorControl, self)._cycle()

# do nothing
def move_effector(self):
pass

def move_plant(self, **kwargs):
pass

# use keyboard to control the task
def move_effector_cursor(self):
np.array([0., 0., 0.])
curr_pos = copy.deepcopy(self.plant.get_endpoint_pos())

for event in pygame.event.get():
if event.type == pygame.KEYUP:
if event.type == pygame.K_q:
pygame.quit()
quit()
if event.key == pygame.K_LEFT:
curr_pos[0] -= self.move_step
if event.key == pygame.K_RIGHT:
curr_pos[0] += self.move_step
if event.key == pygame.K_UP:
curr_pos[2] += self.move_step
if event.key == pygame.K_DOWN:
curr_pos[2] -= self.move_step
#print('Current position: ')
#print(curr_pos)

# set the current position
self.plant.set_endpoint_pos(curr_pos)

def _start_wait(self):
self.wait_time = 0.
super(CursorControl, self)._start_wait()

def _test_start_trial(self, ts):
return ts > self.wait_time and not self.pause

#this task can be run on its
#we will not involve database at this time
target_pos_radius = 10

def target_seq_generator(n_targs, n_trials):
#generate targets
angles = np.transpose(np.arange(0,2*np.pi,2*np.pi / n_targs))
unit_targets = targets = np.stack((np.cos(angles), np.sin(angles)),1)
targets = unit_targets * target_pos_radius

center = np.array((0,0))

target_inds = np.random.randint(0, n_targs, n_trials)
target_inds[0:n_targs] = np.arange(min(n_targs, n_trials))

k = 0
while k < n_trials:
targ = targets[target_inds[k], :]
yield np.array([[center[0], 0, center[1]],
[targ[0], 0, targ[1]]])
k += 1


if __name__ == "__main__":
print('Remember to set window size in stereoOpenGL class')
gen = target_seq_generator(8, 1000)

#incorporate the saveHDF feature by blending code
#see tests\start_From_cmd_line_sim

base_class = CursorControl

feats = [SaveHDF, TaskCodeStreamer]
Exp = experiment.make(base_class, feats=feats)
print(Exp)

exp = Exp(gen)
exp.init()
exp.run() #start the task




Loading