def tierpsy_plate_summary_augmented(fname, is_manual_index=False, delta_time=1 / 3, **fold_args): fps = read_fps(fname) data_in = read_data(fname, is_manual_index) if data_in is None: return timeseries_data, blob_features = data_in fold_index = augment_data(timeseries_data, fps=fps, **fold_args) all_summary = [] for i_fold, ind_fold in enumerate(fold_index): timeseries_data_r = timeseries_data[ind_fold].reset_index(drop=True) blob_features_r = blob_features[ind_fold].reset_index(drop=True) plate_feats = get_summary_stats(timeseries_data_r, fps, blob_features_r, delta_time) plate_feats = pd.DataFrame(plate_feats).T plate_feats.insert(0, 'i_fold', i_fold) all_summary.append(plate_feats) all_summary = pd.concat(all_summary, ignore_index=True) return all_summary
def tierpsy_plate_summary_augmented(fname, filter_params, time_windows, time_units, only_abs_ventral=False, selected_feat=None, is_manual_index=False, delta_time=1 / 3, **fold_args): fps = read_fps(fname) data_in = read_data(fname, filter_params, time_windows, time_units, fps, is_manual_index) if data_in is None: return [pd.DataFrame() for iwin in range(len(time_windows))] timeseries_data, blob_features = data_in # initialize list of summaries for all time windows all_summaries_list = [] # loop over time windows for iwin, window in enumerate(time_windows): if timeseries_data[iwin].empty: all_summary = pd.DataFrame([]) else: fold_index = augment_data(timeseries_data[iwin], fps=fps, **fold_args) # initialize list of augmented plate summaries for given time window all_summary = [] # loop over folds for i_fold, ind_fold in enumerate(fold_index): timeseries_data_r = timeseries_data[iwin][ ind_fold].reset_index(drop=True) blob_features_r = blob_features[iwin][ind_fold].reset_index( drop=True) plate_feats = get_summary_stats( timeseries_data_r, fps, blob_features_r, delta_time, only_abs_ventral=only_abs_ventral, selected_feat=selected_feat) plate_feats['n_skeletons'] = count_skeletons(timeseries_data_r) plate_feats = pd.DataFrame(plate_feats).T plate_feats.insert(0, 'i_fold', i_fold) all_summary.append(plate_feats) # concatenate all folds in given time window into one dataframe all_summary = pd.concat(all_summary, ignore_index=True, sort=False) # add dataframe to the list of summaries for all time windows all_summaries_list.append(all_summary) return all_summaries_list
def ow_plate_summary_augmented(fname, **fold_args): #NOTE: I will only augment the timeseries features. #It is not trivial to include the event features sampling over time. fps = read_fps(fname) with pd.HDFStore(fname, 'r') as fid: features_timeseries = fid['/features_timeseries'] fold_index = augment_data(features_timeseries, fps=fps, **fold_args) valid_order = None wStats = WormStats() all_summary = [] for i_fold, ind_fold in enumerate(fold_index): timeseries_data_r = features_timeseries[ind_fold].reset_index(drop=True) all_feats = {} for cc in timeseries_data_r: all_feats[cc] = timeseries_data_r[cc].values exp_feats = wStats.getWormStats(all_feats, np.nanmean) exp_feats = pd.DataFrame(exp_feats) if valid_order is None: #only calculate this the first time... valid_order = [x for x in exp_feats.columns if x not in wStats.extra_fields] exp_feats = exp_feats.loc[:, valid_order] exp_feats.insert(0, 'i_fold', i_fold) all_summary.append(exp_feats) all_summary = pd.concat(all_summary, ignore_index=True) return all_summary