Esempio n. 1
0
 def _send_csp_info(self, cfg):
     desc = dict(cfg)
     t = time.time()
     tags_helper.send_tag(
         self.conn, t, t, 
         "cspInfo",
         desc)
Esempio n. 2
0
 def send_tag(self, name):
     t = time.time()
     tags_helper.send_tag(self.conn,
                          t,
                          t,
                          str(name),
                          p_tag_desc={},
                          p_tag_channels="")
Esempio n. 3
0
 def handle_message(self, mxmsg):
     if mxmsg.type == types.DIODE_MESSAGE:
         msg = variables_pb2.Diode()
         msg.ParseFromString(mxmsg.message)
         self.logger.debug("GOT DIODE: "+repr(msg.timestamp)+" / "+str(msg.value))
         tags_helper.send_tag(self.conn, msg.timestamp, msg.timestamp, "diode",
                              {"freqs" : msg.value})
     self.no_response()
Esempio n. 4
0
 def send_tag(self,
              p_start_timestamp,
              p_end_timestamp,
              p_tag_name,
              p_tag_desc={},
              p_tag_channels=""):
     tags_helper.send_tag(self.conn, p_start_timestamp, p_end_timestamp,
                          p_tag_name, p_tag_desc, p_tag_channels)
Esempio n. 5
0
 def send_tag(self, tag):
     tag = eval(str(tag))
     tags_helper.send_tag(self.conn,
                          float(tag['timestamp']),
                          float(tag['timestamp']),
                          tag['name'],
                          p_tag_desc={},
                          p_tag_channels="")
Esempio n. 6
0
 def _send_breaks(self):
     t = time.time()
     tags_helper.send_tag(self.conn, t, t, "break",{'duration':sum(self.break_times)})
     appliance_helper.send_stop(self.conn)        
     for i, t in enumerate(self.break_times):
         #ugm_helper.send_text(self.conn, self.break_texts[i])
         ugm_helper.send_config_for(self.conn, self.text_id, 'message', self.break_texts[i]+str(self.sequence.qsize()))
         time.sleep(t)
 def _send_breaks(self):
     t = time.time()
     tags_helper.send_tag(self.conn, t, t, "break",{'duration':sum(self.break_times)})
     appliance_helper.send_stop(self.conn)        
     for i, t in enumerate(self.break_times):
         #ugm_helper.send_text(self.conn, self.break_texts[i])
         ugm_helper.send_config_for(self.conn, self.text_id, 'message', self.break_texts[i]+str(self.sequence.qsize()))
         time.sleep(t)
Esempio n. 8
0
 def handle_message(self, mxmsg):
     if mxmsg.type == types.DIODE_MESSAGE:
         msg = variables_pb2.Diode()
         msg.ParseFromString(mxmsg.message)
         self.logger.debug("GOT DIODE: " + repr(msg.timestamp) + " / " +
                           str(msg.value))
         tags_helper.send_tag(self.conn, msg.timestamp, msg.timestamp,
                              "diode", {"freqs": msg.value})
     self.no_response()
 def _handle_blink(self, msg):
     b = variables_pb2.Blink()
     b.ParseFromString(msg)
     LOGGER.debug("GOT BLINK: " + str(b.timestamp) + " / " + str(b.index))
     tags_helper.send_tag(self.conn, b.timestamp,
                          b.timestamp + self.blink_duration, "blink", {
                              "index": b.index,
                              "target": self.current_target
                          })
    def _send_exp_info(self):
        desc = dict(self.config.param_values())
        desc['all_freqs'] = ';'.join(self.all_freqs)

        t = time.time()
        tags_helper.send_tag(
            self.conn, t, t, 
            "experimentInfo",
            desc)
Esempio n. 11
0
 def handle_message(self, mxmsg):
     if mxmsg.type == types.BLINK_MESSAGE:
         b = variables_pb2.Blink()
         b.ParseFromString(mxmsg.message)
         self.logger.debug("GOT BLINK: "+str(b.timestamp)+" / "+str(b.index))
         tags_helper.send_tag(self.conn, 
                              b.timestamp, b.timestamp+self.blink_duration, "blink",
                              {"index" : b.index})
     self.no_response()
 def _handle_blink(self, msg):
     b = variables_pb2.Blink()
     b.ParseFromString(msg)
     self.logger.debug("GOT BLINK: "+str(b.timestamp)+" / "+str(b.index))
     tags_helper.send_tag(self.conn, 
                          b.timestamp, b.timestamp+self.blink_duration, "blink",
                          {"index" : b.index,
                           "target":self.current_target
                           })
Esempio n. 13
0
    def _send_exp_info(self):
        desc = dict(self.config.param_values())
        desc['all_freqs'] = ';'.join(self.all_freqs)

        t = time.time()
        tags_helper.send_tag(
            self.conn, t, t, 
            "experimentInfo",
            desc)
Esempio n. 14
0
 def handle_message(self, mxmsg):
     if mxmsg.type == types.BLINK_MESSAGE:
         b = variables_pb2.Blink()
         b.ParseFromString(mxmsg.message)
         self.logger.debug("GOT BLINK: "+str(b.timestamp)+" / "+str(b.index))
         tags_helper.send_tag(self.conn, 
                              b.timestamp, b.timestamp+self.blink_duration, "blink",
                              {"index" : b.index})
     self.no_response()
Esempio n. 15
0
 def _send_freqs(self, freqs, target_ind):
     appliance_helper.send_freqs(self.conn, freqs)
     t = time.time()
     tags_helper.send_tag(self.conn, t, t, "diodes",
                          {'freq':freqs[target_ind],
                           'freqs':freqs,
                           'field':target_ind,
                           'duration':self.target_time
                           })
     time.sleep(self.target_time)
Esempio n. 16
0
 def _send_freqs(self, freqs, target_ind):
     appliance_helper.send_freqs(self.conn, freqs)
     t = time.time()
     tags_helper.send_tag(
         self.conn, t, t, "diodes", {
             'freq': freqs[target_ind],
             'freqs': freqs,
             'field': target_ind,
             'duration': self.target_time
         })
     time.sleep(self.target_time)
 def _send_freqs(self, freqs, target_ind):
     appliance_helper.send_freqs(self.conn, freqs)
     t = time.time()
     tags_helper.send_tag(
         self.conn,
         t,
         t,
         "diodes",
         {"freq": freqs[target_ind], "freqs": freqs, "field": target_ind, "duration": self.target_time},
     )
     time.sleep(self.target_time)
 def _send_breaks(self):
     t = time.time()
     tags_helper.send_tag(self.conn, t, t, "break", {"duration": sum(self.break_times)})
     appliance_helper.send_stop(self.conn)
     for i, t in enumerate(self.break_times):
         ugm_helper.send_text(self.conn, self.break_texts[i])
         # ugm_helper.send_config_for(self.conn, self.text_id, 'message', self.break_texts[i])#+str(self.sequence.qsize()))
         time.sleep(t)
         if i <= 1:
             pygame.mixer.Sound("f1.wav").play()
             print("BEEEEEEEEEEEEP")
Esempio n. 19
0
    def send_decision(self, dec):
        """Send dec message to the system (probably to LOGIC peer).
        dec is of integer type."""
        self.logger.info("Sending dec message: " + str(dec))
        self._last_dec_time = time.time()

        # self.buffer.clear() dont do it in p300 - just ignore some blinks sometimes ...
        self.buffer.clear_blinks()
        ugm_helper.send_stop_blinking(self.conn)
        t = time.time()
        tags_helper.send_tag(self.conn, t, t, "decision", {"decision": str(dec)})
        self.conn.send_message(message=str(self.blink_field_ids[dec]), type=types.DECISION_MESSAGE, flush=True)
Esempio n. 20
0
 def _send_breaks(self):
     t = time.time()
     tags_helper.send_tag(self.conn, t, t, "break",
                          {'duration': sum(self.break_times)})
     appliance_helper.send_stop(self.conn)
     for i, t in enumerate(self.break_times):
         ugm_helper.send_text(self.conn, self.break_texts[i])
         #ugm_helper.send_config_for(self.conn, self.text_id, 'message', self.break_texts[i])#+str(self.sequence.qsize()))
         time.sleep(t)
         if i <= 1:
             pygame.mixer.Sound('f1.wav').play()
             print("BEEEEEEEEEEEEP")
 def send_decision(self, dec):
     """Send dec message to the system (probably to LOGIC peer).
     dec is of integer type."""
     self.logger.info("Sending dec message: "+str(dec))
     self._last_dec_time = time.time()
     self.buffer.clear()
     self.conn.send_message(message = str(dec), type = types.DECISION_MESSAGE, flush=True)
     t = time.time()
     tags_helper.send_tag(
         self.conn, t, t, 
         "decision",
         {'decision':str(dec)})
Esempio n. 22
0
 def send_decision(self, dec):
     """Send dec message to the system (probably to LOGIC peer).
     dec is of integer type."""
     self.logger.info("Sending dec message: " + str(dec))
     self._last_dec_time = time.time()
     self.buffer.clear()
     self.conn.send_message(message=str(dec),
                            type=types.DECISION_MESSAGE,
                            flush=True)
     t = time.time()
     tags_helper.send_tag(self.conn, t, t, "decision",
                          {'decision': str(dec)})
Esempio n. 23
0
    def send_decision(self, dec):
        """Send dec message to the system (probably to LOGIC peer).
        dec is of integer type."""
        self.logger.info("Sending dec message: " + str(dec))
        self._last_dec_time = time.time()

        #self.buffer.clear() dont do it in p300 - just ignore some blinks sometimes ...
        self.buffer.clear_blinks()
        ugm_helper.send_stop_blinking(self.conn)

        t = time.time()
        tags_helper.send_tag(self.conn, t, t, "decision",
                             {'decision': str(dec)})
        self.conn.send_message(message=str(self.blink_field_ids[dec]),
                               type=types.DECISION_MESSAGE,
                               flush=True)
    def _send_feed(self, target_ind):
        if self.feed_time <= 0:
            return
        # prepare and send feed text
        l_config = [{"id": self.text_ids[target_ind], "message": self.feed_text}]
        l_str_config = str(l_config)
        ugm_helper.send_config(self.conn, l_str_config, 1)
        t = time.time()
        tags_helper.send_tag(self.conn, t, t, "feedback", {"field": target_ind, "duration": self.feed_time})
        # wait
        time.sleep(self.feed_time)

        # remove feed
        l_config[0]["message"] = ""
        l_str_config = str(l_config)
        ugm_helper.send_config(self.conn, l_str_config, 1)
Esempio n. 25
0
    def _send_feed(self, target_ind):
        if self.feed_time <= 0:
            return
        #prepare and send feed text
        l_config = [{'id':self.text_ids[target_ind],
                  'message':self.feed_text}]
        l_str_config = str(l_config)
        ugm_helper.send_config(self.conn, l_str_config, 1)
        t = time.time()
        tags_helper.send_tag(self.conn, t, t, "feedback",
                             {'field':target_ind,
                              'duration':self.feed_time
                              })
        #wait
        time.sleep(self.feed_time)

        #remove feed
        l_config[0]['message'] = ""
        l_str_config = str(l_config)
        ugm_helper.send_config(self.conn, l_str_config, 1)
Esempio n. 26
0
            resp.corr = 1  # correct non-response
        else:
            resp.corr = 0  # failed to respond (incorrectly)
    # store data for trials (TrialHandler)
    trials.addData("resp.keys", resp.keys)
    trials.addData("resp.corr", resp.corr)
    if resp.keys != None:  # we had a response
        trials.addData("resp.rt", resp.rt)
    t = t_start + word.tStart
    tags_helper.send_tag(
        TAGGER.conn,
        t,
        t,
        "trial",
        {
            "keys": str(resp.keys),
            "corr": str(resp.corr),
            "rt": str(resp.rt),
            "text": str(text),
            "color": str(letterColor),
        },
    )


# completed 5.0 repeats of 'trials'

acquisition_helper.send_finish_saving(TAGGER.conn)
trials.saveAsPickle(filename + "trials")
trials.saveAsExcel(
    filename + ".xlsx",
    sheetName="trials",
Esempio n. 27
0
 def _send_ugm(self):
     ugm_helper.send_config(self.conn, self.ugm)        
     t = time.time()
     tags_helper.send_tag(self.conn, t, t, "trial",{'duration':self.feed_time+self.target_time})
 def _send_ugm(self):
     ugm_helper.send_config(self.conn, self.ugm)        
     t = time.time()
     tags_helper.send_tag(self.conn, t, t, "trial",{'duration':self.feed_time+self.target_time})
Esempio n. 29
0
 def _send_csp_info(self, cfg):
     desc = dict(cfg)
     t = time.time()
     tags_helper.send_tag(self.conn, t, t, "cspInfo", desc)
Esempio n. 30
0
 def send_tag(self, p_start_timestamp, p_end_timestamp, 
              p_tag_name, p_tag_desc={}, p_tag_channels=""):
     tags_helper.send_tag(self.conn, p_start_timestamp, p_end_timestamp, 
                          p_tag_name, p_tag_desc, p_tag_channels)
Esempio n. 31
0
 def send_tag(self, tag):
     tag = eval(str(tag)) 
     tags_helper.send_tag(self.conn, float(tag['timestamp']), float(tag['timestamp']), tag['name'], p_tag_desc={}, p_tag_channels="")
Esempio n. 32
0
 def send_tag(self, name):
     t = time.time()
     tags_helper.send_tag(self.conn, t, t, str(name), p_tag_desc={}, p_tag_channels="")
Esempio n. 33
0
    #check responses
    if len(resp.keys) == 0:  #No response was made
        resp.keys = None
        #was no response the correct answer?!
        if str(corrAns).lower() == 'none': resp.corr = 1  #correct non-response
        else: resp.corr = 0  #failed to respond (incorrectly)
    #store data for trials (TrialHandler)
    trials.addData('resp.keys', resp.keys)
    trials.addData('resp.corr', resp.corr)
    if resp.keys != None:  #we had a response
        trials.addData('resp.rt', resp.rt)
    t = t_start + word.tStart
    tags_helper.send_tag(
        TAGGER.conn, t, t, "trial", {
            'keys': str(resp.keys),
            'corr': str(resp.corr),
            'rt': str(resp.rt),
            'text': str(text),
            'color': str(letterColor)
        })

#completed 5.0 repeats of 'trials'

acquisition_helper.send_finish_saving(TAGGER.conn)
trials.saveAsPickle(filename + 'trials')
trials.saveAsExcel(filename + '.xlsx',
                   sheetName='trials',
                   stimOut=trials.trialList[0].keys(),
                   dataOut=['n', 'all_mean', 'all_std', 'all_raw'])

#Start of routine thanks
t = 0