def test(): for i in range(10): # how many times I want to get data t1 = time.time() cortex = Cortex('./cortex_creds') asyncio.run(do_stuff(cortex)) cortex.close() t2 = time.time() print(t2 - t1)
async def init_cortex(creds): ''' cortex.authorize token return should be stored and checked cortex.queryheadsets should be also stored, since is the same id cortex.create_session and cortex.create_record are still under study, they can remain, but hopefully we'll only need cortex.subscribe with the right configuration ''' if creds is None: raise ValueError(f'No credentials found') cortex = Cortex(creds) await cortex.authorize(license_id=LICENSE_ID,debit=50) await cortex.query_headsets() if len(cortex.headsets) < 1: raise ValueError(f'No headsets found') await cortex.create_session(activate=True,headset_id=cortex.headsets[0]) await cortex.create_record(title="emotiv raw trial") await cortex.subscribe(['eeg']) return cortex
def test(): cortex = Cortex('./cortex_creds') asyncio.run(do_stuff(cortex)) cortex.close()
def test(): print("hello world") cortex = Cortex('credentials.txt') asyncio.run(do_stuff(cortex)) cortex.close()
def run(): cortex = Cortex('./cortex_creds') asyncio.run(collect_data(cortex)) cortex.close()
def thr2(): cortex = Cortex('./cortex_creds') asyncio.run(do_stuff(cortex, 1)) cortex.close()
if __name__ == '__main__': args = parser.parse_args() test = args.test model_file = Path(args.model_file) if not model_file.exists(): raise FileNotFoundError(f"Model file {model_file} does not exist") model = load_model(str(model_file)) model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=model.metrics + ["acc"], weighted_metrics=model.metrics + ["acc"]) sequence_length = model.layers[0].input_shape[1] if not test: cortex = Cortex('./cortex_creds') loop = asyncio.new_event_loop() if not test: cortex = loop.run_until_complete(_init(cortex)) asyncio.set_event_loop(loop) # new_main_loop() cozmo.run_program(main_loop)