except: continue try: # reading tables of this subject stays = read_stays(os.path.join(args.subjects_root_path, subject_dir)) diagnoses = read_diagnoses( os.path.join(args.subjects_root_path, subject_dir)) events = read_events(os.path.join(args.subjects_root_path, subject_dir)) except: sys.stderr.write( 'Error reading from disk for subject: {}\n'.format(subject_id)) continue episodic_data = assemble_episodic_data(stays, diagnoses) # cleaning and converting to time series events = map_itemids_to_variables(events, var_map) events = clean_events(events) if events.shape[0] == 0: # no valid events for this subject continue timeseries = convert_events_to_timeseries(events, variables=variables) # extracting separate episodes for i in range(stays.shape[0]): stay_id = stays.ICUSTAY_ID.iloc[i] intime = stays.INTIME.iloc[i] outtime = stays.OUTTIME.iloc[i]
sys.stdout.flush() try: sys.stdout.write('reading...') sys.stdout.flush() stays = read_stays(os.path.join(args.subjects_root_path, subject_dir)) diagnoses = read_diagnoses(os.path.join(args.subjects_root_path, subject_dir)) events = read_events(os.path.join(args.subjects_root_path, subject_dir)) except: sys.stdout.write('error reading from disk!\n') continue else: sys.stdout.write('got {0} stays, {1} diagnoses, {2} events...'.format(stays.shape[0], diagnoses.shape[0], events.shape[0])) sys.stdout.flush() episodic_data = assemble_episodic_data(stays, diagnoses) sys.stdout.write('cleaning and converting to time series...') sys.stdout.flush() events = map_itemids_to_variables(events, var_map) events = clean_events(events) if events.shape[0] == 0: sys.stdout.write('no valid events!\n') continue timeseries = convert_events_to_timeseries(events, variables=variables) sys.stdout.write('extracting separate episodes...') sys.stdout.flush() for i in range(stays.shape[0]): stay_id = stays.ICUSTAY_ID.iloc[i]