def bmi_block_reconstruction_error(idx, cls=tasks.BMIReconstruction, n_iter=None): te = performance._get_te(idx) if n_iter == None or n_iter == -1: n_iter = len(te.hdf.root.task) gen = genfns.sim_target_seq_generator_multi(8, 1000) task = cls(te, n_iter, gen) task.init() error = task.calc_recon_error(verbose=False) abs_max_error = np.max(np.abs(error)) return abs_max_error
from tasks import bmi_recon_tasks reload(clda) reload(train) reload(bmi) reload(ppfdecoder) idx = 2306 from optparse import OptionParser parser = OptionParser() parser.add_option("-b", "--block", dest="block", help="Database ID number of block to run on", type=int, metavar="FILE", default=2306) (options, args) = parser.parse_args() idx = options.block te = performance._get_te(idx) print(te) T = len(te.hdf.root.task) n_iter = 100 #T #n_iter = 15782 task_msgs = te.hdf.root.task_msgs[:] update_bmi_msgs = task_msgs[task_msgs['msg'] == 'update_bmi'] state_transitions = task_msgs[~(task_msgs['msg'] == 'update_bmi')] # class CLDAPPFReconstruction(bmi_recon_tasks.BMIReconstruction): # pass # class CLDAPPFReconstruction(bmimultitasks.CLDAControlPPFContAdapt): # def __init__(self, *args, **kwargs): # super(CLDAPPFReconstruction, self).__init__(*args, **kwargs)
import tasks from analysis import performance from tasks import generatorfunctions as genfns import numpy as np from tasks import bmi_recon_tasks from riglib.bmi import clda reload(bmi_recon_tasks) reload(tasks) cls=tasks.KFRMLCGRecon idx = 5275 te = performance._get_te(idx) ### TODO some CLDA blocks have a changing half life... updater = clda.KFRML(None, None, te.batch_time, te.half_life[0]) updater.init(te.seed_decoder) param_hist = te.hdf.root.clda C_error = [] Q_error = [] decoder = te.seed_decoder for k in range(len(param_hist))[5::6]: intended_kin = param_hist[k]['intended_kin'] spike_counts = param_hist[k]['spike_counts_batch'] if not np.any(np.isnan(intended_kin)) and not np.any(np.isnan(spike_counts)):
import argparse parser = argparse.ArgumentParser(description='Analyze perf correlates of KF plant properties') parser.add_argument('--n_iter', help='', type=int, action="store", default=-1) args = parser.parse_args() n_iter = args.n_iter tests = [] # tests.append(TestFixedPPF()) # tests.append(TestFixedKF()) # tests.append(TestPPFCLDA()) # tests.append(TestRML) # tests.append(TestRMLWithAssist()) # tests.append(TestJointRMLWithAssist()) te = performance._get_te(3040) #tests = [TestJointRML(), TestJointRMLWithAssist()] #tests = [TestFixedPPF(), TestPPFCLDA()] #tests = [TestPPFCLDA(), TestRML()] # tests = [TestRMLCGWithAssist()] tests = [TestPPFCLDA()] test_suite = unittest.TestSuite(tests) unittest.TextTestRunner(verbosity=2).run(test_suite)
from riglib import experiment from features.generator_features import Autostart from features.hdf_features import SaveHDF from features.plexon_features import PlexonBMI from tasks import generatorfunctions as genfns from analysis import performance # Tell linux to use Display 0 (the monitor physically attached to the # machine. Otherwise, if you are connected remotely, it will try to run # the graphics through SSH, which doesn't work for some reason. import os os.environ['DISPLAY'] = ':0' task = models.Task.objects.get(name='clda_kf_ofc_tentacle_rml_trial') base_class = task.get() feats = [SaveHDF, PlexonBMI, Autostart] Exp = experiment.make(base_class, feats=feats) #params.trait_norm(Exp.class_traits()) params = dict(session_length=30, arm_visible=True, arm_class='RobotArmGen2D', assist_level=(2., 2.), assist_time=60., rand_start=(0.,0.), max_tries=1) gen = genfns.sim_target_seq_generator_multi(8, 1000) exp = Exp(gen, **params) exp.decoder = performance._get_te(3979).decoder exp.start()
self.assertTrue(abs_max_error < 1e-10) import argparse parser = argparse.ArgumentParser( description='Analyze perf correlates of KF plant properties') parser.add_argument('--n_iter', help='', type=int, action="store", default=-1) args = parser.parse_args() n_iter = args.n_iter tests = [] # tests.append(TestFixedPPF()) # tests.append(TestFixedKF()) # tests.append(TestPPFCLDA()) # tests.append(TestRML) # tests.append(TestRMLWithAssist()) # tests.append(TestJointRMLWithAssist()) te = performance._get_te(3040) #tests = [TestJointRML(), TestJointRMLWithAssist()] #tests = [TestFixedPPF(), TestPPFCLDA()] #tests = [TestPPFCLDA(), TestRML()] # tests = [TestRMLCGWithAssist()] tests = [TestPPFCLDA()] test_suite = unittest.TestSuite(tests) unittest.TextTestRunner(verbosity=2).run(test_suite)
from tasks import generatorfunctions as genfns from analysis import performance # Tell linux to use Display 0 (the monitor physically attached to the # machine. Otherwise, if you are connected remotely, it will try to run # the graphics through SSH, which doesn't work for some reason. import os os.environ['DISPLAY'] = ':0' task = models.Task.objects.get(name='clda_kf_ofc_tentacle_rml_trial') base_class = task.get() feats = [SaveHDF, PlexonBMI, Autostart] Exp = experiment.make(base_class, feats=feats) #params.trait_norm(Exp.class_traits()) params = dict(session_length=30, arm_visible=True, arm_class='RobotArmGen2D', assist_level=(2., 2.), assist_time=60., rand_start=(0., 0.), max_tries=1) gen = genfns.sim_target_seq_generator_multi(8, 1000) exp = Exp(gen, **params) exp.decoder = performance._get_te(3979).decoder exp.start()