self.nskECG.ecgalgResetLib()
						self.nskECG.ecg_buffer.task_done() #let queue know that we're done
						continue
				else: # leadoff==200, or lead is on
					leadoff_count=0

				D = self.nskECG.ecgalgAnalyzeRaw(D)

				self.cur_lead_on = D['leadoff']
				if 'hrv' in D:
					self.cur_hrv = D['hrv']
					self.cur_hrv_t = D['timestamp']

			# we keep looping until something tells us to stop
		pass #		


	def is_lead_on(self):
		return self.cur_lead_on

	def get_hrv(self):
		return self.cur_hrv


# c = pycurl.Curl()
# c.setopt(c.URL, ' http://cloudbrain.rocks/link?pub_metric=eeg&sub_metric=muse-001-eeg&publisher=muse-001&subscriber=booth-example&pub_ip=54.183.68.29&sub_ip=54.183.68.29')
# c.perform()

ecg = ecg_fake()
sc = ChangeYourBrainStateControl('blah', None, ecg=ecg, vis_period_sec = .25, baseline_sec = 5, condition_sec = 5, baseline_inst_sec = 2, condition_inst_sec = 2)
sc.tag_in()
        chrome_path = '/usr/bin/google-chrome %s'
        webbrowser.get(chrome_path).open(biodata_viz_url)
    print 'Chrome Loaded'

    print 'hello world 4'

    # webbrowser.get(chrome_path).open(biodata_viz_url)
    # webbrowser.open(biodata_viz_url)
    #time.sleep(4)

    # uncomment next line to run full timing
    if timing == "live":
        sc = ChangeYourBrainStateControl(sb_client.client_name,
                                         sb_server_2,
                                         ecg=ecg,
                                         vis_period_sec=.25,
                                         baseline_sec=30,
                                         condition_sec=90,
                                         baseline_inst_sec=6,
                                         condition_inst_sec=9)
    # uncomment the next line to run expidited timing (DO NOT CHANGE VALUES)
    elif timing == "debug":
        sc = ChangeYourBrainStateControl(sb_client.client_name,
                                         sb_server_2,
                                         ecg=ecg,
                                         vis_period_sec=.25,
                                         baseline_sec=5,
                                         condition_sec=5,
                                         baseline_inst_sec=2,
                                         condition_inst_sec=2)
    print 'ChangeYourBrain state engine started, beginning protocol.'
    sb_client.set_handle_value('alpha_absolute', sc.process_eeg_alpha)
        chrome_path = 'open -a /Applications/Google\ Chrome.app %s'
        webbrowser.get(chrome_path).open(biodata_viz_url)
    else: # Linux
        chrome_path = '/usr/bin/google-chrome %s'
        webbrowser.get(chrome_path).open(biodata_viz_url)
    print 'Chrome Loaded'

    print 'hello world 4'

    # webbrowser.get(chrome_path).open(biodata_viz_url)
    # webbrowser.open(biodata_viz_url)
    #time.sleep(4)

    # uncomment next line to run full timing
    if timing == "live":
        sc = ChangeYourBrainStateControl(sb_client.client_name, sb_server_2, ecg=ecg, vis_period_sec = .25, baseline_sec = 30, condition_sec = 90, baseline_inst_sec = 6, condition_inst_sec = 9)
    # uncomment the next line to run expidited timing (DO NOT CHANGE VALUES)
    elif timing == "debug":
        sc = ChangeYourBrainStateControl(sb_client.client_name, sb_server_2, ecg=ecg, vis_period_sec = .25, baseline_sec = 5, condition_sec = 5, baseline_inst_sec = 2, condition_inst_sec = 2)
    print 'ChangeYourBrain state engine started, beginning protocol.'
    sb_client.set_handle_value('alpha_absolute',sc.process_eeg_alpha)

    print 'waiting for tag in'
    if (eeg_source == 'real'):
        #time.sleep(4)
        #sc.tag_in()
        sb_client.set_handle_value(eeg_connect_string,sc.tag_in)
    else:
        time.sleep(4)
        sc.tag_in()
        time.sleep(12)
Exemplo n.º 4
0
                D = self.nskECG.ecgalgAnalyzeRaw(D)

                self.cur_lead_on = D['leadoff']
                if 'hrv' in D:
                    self.cur_hrv = D['hrv']
                    self.cur_hrv_t = D['timestamp']

            # we keep looping until something tells us to stop
        pass  #

    def is_lead_on(self):
        return self.cur_lead_on

    def get_hrv(self):
        return self.cur_hrv


# c = pycurl.Curl()
# c.setopt(c.URL, ' http://cloudbrain.rocks/link?pub_metric=eeg&sub_metric=muse-001-eeg&publisher=muse-001&subscriber=booth-example&pub_ip=54.183.68.29&sub_ip=54.183.68.29')
# c.perform()

ecg = ecg_fake()
sc = ChangeYourBrainStateControl('blah',
                                 None,
                                 ecg=ecg,
                                 vis_period_sec=.25,
                                 baseline_sec=5,
                                 condition_sec=5,
                                 baseline_inst_sec=2,
                                 condition_inst_sec=2)
sc.tag_in()