Ejemplo n.º 1
0
    def __init__(self,filename='InfoClientRT.json'): 
        localPort = 15002  # default
	remotePort = 15003  # default
	if os.environ.has_key('ICLOCALPORT'):
            localPort = int(os.environ['ICLOCALPORT'])
	if os.environ.has_key('ICREMOTEPORT'):
            remotePort = int(os.environ['ICREMOTEPORT'])       	
        self.ic = InfoClient('localhost', localPort, 'localhost', remotePort)
        self.ic.add('roi-weightedave', 'active')
        self.ic.add('roi-weightedave','reference')
        self.ic.start()
        if os.path.exists(filename):
            self._json = load_json(filename)
        else:
            self._json = {}
        self._filename = filename
        print "initialized new RT"
Ejemplo n.º 2
0
from infoclientLib import InfoClient
ic = InfoClient('localhost', 15002, 'localhost', 15003)
ic.add('roi-weightedave', 'active')
ic.start()

Ejemplo n.º 3
0
class RT():
    ic = None
    data = {'active':[],'reference':[]}
    tr = {'active':[],'reference':[]}
    xml = []
    trial_type = {'active':[],'reference':[]}

    def __init__(self,filename='InfoClientRT.json'): 
        localPort = 15002  # default
	remotePort = 15003  # default
	if os.environ.has_key('ICLOCALPORT'):
            localPort = int(os.environ['ICLOCALPORT'])
	if os.environ.has_key('ICREMOTEPORT'):
            remotePort = int(os.environ['ICREMOTEPORT'])       	
        self.ic = InfoClient('localhost', localPort, 'localhost', remotePort)
        self.ic.add('roi-weightedave', 'active')
        self.ic.add('roi-weightedave','reference')
        self.ic.start()
        if os.path.exists(filename):
            self._json = load_json(filename)
        else:
            self._json = {}
        self._filename = filename
        print "initialized new RT"

    def check(self,trial=None):
        self.xml = self.ic.check()
        print self.xml
        data = {'active':[],'reference':[]}
        tr = {'active':[],'reference':[]}

        for s in self.xml:
            a = foo(s)
            a.parse()
            data[a.roi].append(a.data)
            tr[a.roi].append(a.tr)
            
        if trial:
            for key in data.keys():
                for i in range(0,len(data[key])-len(self.trial_type[key])):
                    self.trial_type[key].append(trial)
            #trials.append((trial,tr[-1]))
                
        self.data = data
        self.tr = tr
        self.format_flot()
        return self.data, self.tr
    
    def format_flot(self):
        labels = ["active", "reference"]
        for label in labels:
            data = []
            for i, d in enumerate(self.data[label]):
                data.append([self.tr[label][i],d])
            self._json["data"] = data
            self._json["label"] = label
            save_json(self.format_filename(label),self._json)
        
    def format_filename(self,suffix):
        base = os.path.split(self._filename)
        fname = base[1].split('.')
        return os.path.join(base[0],fname[0]+"_"+suffix+'.%s'%fname[1])

    def save(self,filename='rt_data.npz',FB=None,TA=None,Success=None):
        np.savez(filename,data=self.data, xml = self.xml, 
                 tr = self.tr, trials = self.trial_type, 
                 Feedbacks = FB, Targets = TA, Success=Success)
        return filename
        
    def close(self):
        self.ic.stop()
        #self.ic.remove(('roi-weightedave', 'active'))
        self.trial_type = []
        self.data = []
        self.name = []
        self.roi = []
        self.xml = []
Ejemplo n.º 4
0
from infoclientLib import InfoClient

ic = InfoClient('localhost', 15002, 'localhost', 15003)
ic.add('roi-weightedave', 'active')
ic.start()