コード例 #1
0
 def blinking_stopped(self):
     time.sleep(1)
     ugm_helper.send_text(self.conn, self.break_text)
     time.sleep(self.break_duration)
     ugm_helper.send_config(self.conn, self.blinking_ugm)
     time.sleep(1)
     ugm_helper.send_start_blinking(self.conn)
コード例 #2
0
 def blinking_stopped(self):
     time.sleep(1)
     ugm_helper.send_text(self.conn, self.break_text)
     time.sleep(self.break_duration)
     ugm_helper.send_config(self.conn, self.blinking_ugm)
     time.sleep(1)
     ugm_helper.send_start_blinking(self.conn)
コード例 #3
0
ファイル: p300_fda_peer.py プロジェクト: BrainTech/openbci
    def handle_message(self, mxmsg):
        #always buffer signal
        if mxmsg.type == types.AMPLIFIER_SIGNAL_MESSAGE:
            l_msg = variables_pb2.SampleVector()
            l_msg.ParseFromString(mxmsg.message)
            #Supply buffer with sample data, the buffer will fire its
            #ret_func (that we defined as self.analysis.analyse) every 'every' samples
            self.buffer.handle_sample_vect(l_msg)
            if DEBUG:
                self.debug.next_sample()

        #process blinks only when hold_time passed
        if self._last_dec_time > 0:
            t = time.time() - self._last_dec_time
            if t > self.hold_after_dec:
                self._last_dec_time = 0
                ugm_helper.send_start_blinking(self.conn)
            else:
                self.no_response()
                return

        if mxmsg.type == types.BLINK_MESSAGE:
            l_msg = variables_pb2.Blink()
            l_msg.ParseFromString(mxmsg.message)
            self.buffer.handle_blink(l_msg)
            
        self.no_response()
コード例 #4
0
ファイル: bci_p300_fda_peer.py プロジェクト: vjenissr/openbci
    def handle_message(self, mxmsg):
        #always buffer signal
        if mxmsg.type == types.AMPLIFIER_SIGNAL_MESSAGE:
            l_msg = variables_pb2.SampleVector()
            l_msg.ParseFromString(mxmsg.message)
            #Supply buffer with sample data, the buffer will fire its
            #ret_func (that we defined as self.analysis.analyse) every 'every' samples
            self.buffer.handle_sample_vect(l_msg)
            if DEBUG:
                self.debug.next_sample()

        #process blinks only when hold_time passed
        if self._last_dec_time > 0:
            t = time.time() - self._last_dec_time
            if t > self.hold_after_dec:
                self._last_dec_time = 0
                ugm_helper.send_start_blinking(self.conn)
            else:
                self.no_response()
                return

        if mxmsg.type == types.BLINK_MESSAGE:
            l_msg = variables_pb2.Blink()
            l_msg.ParseFromString(mxmsg.message)
            self.buffer.handle_blink(l_msg)
            
        self.no_response()
コード例 #5
0
 def begin(self):
     ugm_helper.send_text(self.conn, self.hi_text)
     #keystroke.wait([" "])
     time.sleep(5)
     self.logger.info("Send begin config ...")
     ugm_helper.send_config(self.conn, self.blinking_ugm)
     self.logger.info("Send start blinking on begin ...")
     ugm_helper.send_start_blinking(self.conn)
コード例 #6
0
 def begin(self):
     ugm_helper.send_text(self.conn, self.hi_text)
     #keystroke.wait([" "])
     time.sleep(5)
     self.logger.info("Send begin config ...")
     ugm_helper.send_config(self.conn, self.blinking_ugm)
     self.logger.info("Send start blinking on begin ...")
     ugm_helper.send_start_blinking(self.conn)
コード例 #7
0
ファイル: bci_p300_fda_peer.py プロジェクト: vjenissr/openbci
    def __init__(self, addresses):
        #Create a helper object to get configuration from the system
        super(BCIP300Fda, self).__init__(addresses=addresses,
                                          type=peers.P300_ANALYSIS)
        #get stats from file
        cfg = self._get_csp_config()
        cfg['pPercent'] = float(self.config.get_param('analysis_treshold'))
        cfg['nMin'] = int(self.config.get_param("n_min"))
        cfg['nMax'] = int(self.config.get_param("n_max"))
        cfg['nLast'] = int(self.config.get_param("n_last"))
        
        cfg['debug_flag'] = int(self.config.get_param('debug_flag'))

        cfg['row'] = int(self.config.get_param('row_count'))
        cfg['col'] = int(self.config.get_param('col_count'))
        row, col = cfg['row'], cfg['col']
        #~ row = cfg['row_count'] = 6
        #~ col = cfg['col_count'] = 6
      
        print "\n"*5
        self.logger.info("COL = " + str(col) + "\n" + "ROW = " +str(row) )
        print "\n"*5

        
        montage_matrix = self._get_montage_matrix(cfg)
            
        #dec_count = int(self.config.get_param('dec_count'))

        #Create analysis object to analyse data 
        self.analysis = self._get_analysis(self.send_decision, cfg, montage_matrix)

        #Initialise round buffer that will supply analysis with data
        #See auto_ring_buffer documentation
        sampling = int(self.config.get_param('sampling_rate'))
        channels_count = len(self.config.get_param('channel_names').split(';'))
        self.buffer = auto_blink_buffer.AutoBlinkBuffer(
            from_blink=0,
            samples_count=int(float(cfg['buffer'])),
            sampling=sampling,
            num_of_channels=channels_count,
            ret_func=self.analysis.analyse,
            ret_format=self.config.get_param('buffer_ret_format'),
            copy_on_ret=int(self.config.get_param('buffer_copy_on_ret'))
            )
        
        self.hold_after_dec = float(self.config.get_param('hold_after_dec'))
        if DEBUG:
            self.debug = streaming_debug.Debug(int(self.config.get_param('sampling_rate')),
                                               self.logger,
                                               int(self.config.get_param('samples_per_packet')))
                                                   
        self._last_dec_time = time.time() + 1 #sleep 5 first seconds..
        ugm_helper.send_start_blinking(self.conn)
        self.ready()
        self.logger.info("BCIAnalysisServer init finished!")
コード例 #8
0
    def begin(self):
        ugm_helper.send_config(self.conn, self.status_ugm)
        ugm_helper.send_status(self.conn, self.hi_text)
        time.sleep(5)
        ugm_helper.send_status(self.conn, self.hi_text_2)
        time.sleep(8)
        ugm_helper.send_status(self.conn, self.hi_text_3)
        time.sleep(3)
        ugm_helper.send_status(self.conn, "")

        self.logger.info("Send begin config ...")
        ugm_helper.send_config(self.conn, self.blinking_ugm)
        self.logger.info("Send start blinking on begin ...")
        ugm_helper.send_start_blinking(self.conn)
コード例 #9
0
    def begin(self):
        ugm_helper.send_config(self.conn, self.status_ugm)
        ugm_helper.send_status(self.conn, self.hi_text)
        time.sleep(5)
        ugm_helper.send_status(self.conn, self.hi_text_2)
        time.sleep(8)
        ugm_helper.send_status(self.conn, self.hi_text_3)
        time.sleep(3)
        ugm_helper.send_status(self.conn, "")

        self.logger.info("Send begin config ...")
        ugm_helper.send_config(self.conn, self.blinking_ugm)
        self.logger.info("Send start blinking on begin ...")
        ugm_helper.send_start_blinking(self.conn)
コード例 #10
0
    def __init__(self, addresses):
        # Create a helper object to get configuration from the system
        super(BCIP300Fda, self).__init__(addresses=addresses, type=peers.P300_ANALYSIS)
        # get stats from file
        cfg = self._get_csp_config()
        cfg["pPercent"] = float(self.config.get_param("analysis_treshold"))
        cfg["nMin"] = int(self.config.get_param("n_min"))
        cfg["nMax"] = int(self.config.get_param("n_max"))
        cfg["nLast"] = int(self.config.get_param("n_last"))

        cfg["debug_flag"] = int(self.config.get_param("debug_flag"))

        montage_matrix = self._get_montage_matrix(cfg)
        blink_field_ids = self.config.get_param("blink_field_ids").split(";")
        self.blink_field_ids = [int(ids) for ids in blink_field_ids]

        # Create analysis object to analyse data
        self.analysis = self._get_analysis(self.send_decision, cfg, montage_matrix)

        # Initialise round buffer that will supply analysis with data
        # See auto_ring_buffer documentation
        sampling = int(self.config.get_param("sampling_rate"))
        channels_count = len(self.config.get_param("channel_names").split(";"))
        self.buffer = auto_blink_buffer.AutoBlinkBuffer(
            from_blink=0,
            samples_count=int(float(cfg["buffer"])),
            sampling=sampling,
            num_of_channels=channels_count,
            ret_func=self.analysis.analyse,
            ret_format=self.config.get_param("buffer_ret_format"),
            copy_on_ret=int(self.config.get_param("buffer_copy_on_ret")),
        )

        self.hold_after_dec = float(self.config.get_param("hold_after_dec"))
        if DEBUG:
            self.debug = streaming_debug.Debug(
                int(self.config.get_param("sampling_rate")),
                self.logger,
                int(self.config.get_param("samples_per_packet")),
            )

        self._last_dec_time = time.time() + 1  # sleep 5 first seconds..
        ugm_helper.send_start_blinking(self.conn)
        self.ready()
        self.logger.info("BCIAnalysisServer init finished!")
コード例 #11
0
ファイル: p300_fda_peer.py プロジェクト: BrainTech/openbci
    def __init__(self, addresses):
        #Create a helper object to get configuration from the system
        super(BCIP300Csp, self).__init__(addresses=addresses,
                                          type=peers.P300_ANALYSIS)
        #get stats from file
        cfg = self._get_csp_config()
        #~ cfg['pVal'] = float(self.config.get_param('analysis_treshold'))
        
        montage_matrix = self._get_montage_matrix(cfg)
            
        #dec_count = int(self.config.get_param('dec_count'))

        #Create analysis object to analyse data 
        self.analysis = self._get_analysis(self.send_results, cfg, montage_matrix)

        #Initialise round buffer that will supply analysis with data
        #See auto_ring_buffer documentation
        sampling = int(self.config.get_param('sampling_rate'))
        channels_count = len(self.config.get_param('channel_names').split(';'))
        self.buffer = auto_blink_buffer.AutoBlinkBuffer(
            from_blink=0,
            samples_count=int(float(cfg['buffer'])),
            sampling=sampling,
            num_of_channels=channels_count,
            ret_func=self.analysis.analyse,
            ret_format=self.config.get_param('buffer_ret_format'),
            copy_on_ret=int(self.config.get_param('buffer_copy_on_ret'))
            )
        
        self.hold_after_dec = float(self.config.get_param('hold_after_dec'))
        if DEBUG:
            self.debug = streaming_debug.Debug(int(self.config.get_param('sampling_rate')),
                                               LOGGER,
                                               int(self.config.get_param('samples_per_packet')))
                                                   
        self._last_dec_time = time.time() + 1 #sleep 5 first seconds..
        ugm_helper.send_start_blinking(self.conn)
        self.ready()
        LOGGER.info("BCIAnalysisServer init finished!")
コード例 #12
0
    def __init__(self, addresses):
        #Create a helper object to get configuration from the system
        super(BCIP300Csp, self).__init__(addresses=addresses,
                                         type=peers.P300_ANALYSIS)
        #get stats from file
        cfg = self._get_csp_config()
        #~ cfg['pVal'] = float(self.config.get_param('analysis_treshold'))

        montage_matrix = self._get_montage_matrix(cfg)

        #dec_count = int(self.config.get_param('dec_count'))

        #Create analysis object to analyse data
        self.analysis = self._get_analysis(self.send_results, cfg,
                                           montage_matrix)

        #Initialise round buffer that will supply analysis with data
        #See auto_ring_buffer documentation
        sampling = int(self.config.get_param('sampling_rate'))
        channels_count = len(self.config.get_param('channel_names').split(';'))
        self.buffer = auto_blink_buffer.AutoBlinkBuffer(
            from_blink=0,
            samples_count=int(float(cfg['buffer'])),
            sampling=sampling,
            num_of_channels=channels_count,
            ret_func=self.analysis.analyse,
            ret_format=self.config.get_param('buffer_ret_format'),
            copy_on_ret=int(self.config.get_param('buffer_copy_on_ret')))

        self.hold_after_dec = float(self.config.get_param('hold_after_dec'))
        if DEBUG:
            self.debug = streaming_debug.Debug(
                int(self.config.get_param('sampling_rate')), LOGGER,
                int(self.config.get_param('samples_per_packet')))

        self._last_dec_time = time.time() + 1  #sleep 5 first seconds..
        ugm_helper.send_start_blinking(self.conn)
        self.ready()
        LOGGER.info("BCIAnalysisServer init finished!")