def main(): parser = argparse.ArgumentParser() parser.add_argument('--serial-port', type=str, help='serial port', required=True) parser.add_argument('--mac-address', type=str, help='mac address', required=False, default='') args = parser.parse_args() BoardShim.enable_dev_board_logger() params = BrainFlowInputParams() params.serial_port = args.serial_port params.mac_address = args.mac_address board = BoardShim(BoardIds.GANGLION_BOARD.value, params) board.prepare_session() # expected result: 5 seconds of resistance data(unknown sampling rate) after that 5 seconds of exg data board.config_board('z') board.start_stream(45000, 'file://raw_data.csv:w') time.sleep(5) board.config_board('Z') time.sleep(5) data = board.get_board_data() board.stop_stream() board.release_session() print(data) resistance_channels = BoardShim.get_resistance_channels( BoardIds.GANGLION_BOARD.value) print(resistance_channels)
os.makedirs(todays_sessions_path, exist_ok=True) # assuming that there is one directory per session (i.e. morning and night) todays_sessions = os.listdir(todays_sessions_path) curr_sesh_name = f"Session_{len(todays_sessions)+1}" if args.synth: curr_sesh_name += "_SYNTH" current_session_dir = os.path.join(todays_sessions_path, curr_sesh_name) os.mkdir(current_session_dir) raw_data_path = os.path.join(current_session_dir, "raw_data.csv") board_id = BoardIds.SYNTHETIC_BOARD.value if args.synth else BoardIds.CYTON_DAISY_BOARD.value sampling_rate = BoardShim.get_sampling_rate(board_id) eegs = BoardShim.get_eeg_channels(board_id) battery = BoardShim.get_battery_channel(board_id) resistance = BoardShim.get_resistance_channels(board_id) timestamp = BoardShim.get_timestamp_channel(board_id) others = BoardShim.get_accel_channels( board_id) if args.synth else BoardShim.get_other_channels(board_id) columns = ['timestamp'] + [f'ch_{x+1}' for x in range(len(eegs)) ] + [f'aux_{x+1}' for x in range(len(others))] with open(raw_data_path, 'w') as raw: raw.write(','.join(columns) + '\n') if args.debug: BoardShim.enable_dev_board_logger() for c in ['eegs', 'battery', 'resistance', 'others', 'timestamp']: log_debug(f'Channel for {c} is {eval(c)} ') log_debug(f"sampling rate is {sampling_rate} with board ID {board_id}") DataFilter.write_file