def loop_show_asymmetry(prefix, grouping_keys=['Gender', 'FDH_23_Handedness_Prtcpnt'], xaxis_key='Age_At_IMGExam', plots='regressions'): """ Loop over all properties to show asymmetry.""" data = get_all_data() data.filter(lambda k, v: 'fuzzy' not in k) # Remove 'fuzzy' data.filter([partial(lambda k, v, p: (k.startswith(p) or k in grouping_keys or k == xaxis_key), p=p) for p in prefix]) # Process & plot the data. stats = [] regressions = [] group_samples = [] measure_keys = data.get_twohemi_keys() for pi, key in enumerate(sorted(measure_keys)): print("Comparing %d (%s)..." % (pi, key)) gn, ss, rv, gs = compare_group_asymmetry(data.data_dict, xaxis_key=xaxis_key, yaxis_key=key, plots=plots, grouping_keys=grouping_keys, measure_key=key) stats.append(ss) regressions.append(rv) group_samples.append(gs) if 'regression_stats' in plots: dump_regressions_csv(regressions, group_names=gn, measure_names=measure_keys) plot_regressions_scatter(regressions, group_names=gn, measure_names=measure_keys) if 'stat_distributions' in plots: plot_stat_distributions(stats, group_names=gn) plt.show()
""" import sys from functools import partial from export import EXPORTED_PING_SPREADSHEET from ping.apps import PINGSession from ping.data import PINGData from research.data import get_all_data if len(sys.argv) > 1: # Someone told us about an existing csv csv_file = sys.argv[1] else: # We will build a csv on the fly. csv_file = EXPORTED_PING_SPREADSHEET filter_fns = [partial(lambda k, v: k.startswith(p), p=p) for p in PINGData.IMAGING_PREFIX] data = get_all_data(filter_fns=filter_fns) data.export(out_file=csv_file) for key in sorted(data.data_dict.keys()): print(key) # Upload the new spreadsheet. sess = PINGSession() sess.login() sess.upload_user_spreadsheet(csv_file)
elif len(sys.argv) > 6: do_usage(sys.argv, "Too many arguments.") elif len(sys.argv) < 4: do_usage(sys.argv, "Too few keys.") else: prefix, x_key, y_key = sys.argv[1:4] prefix = prefix.split(',') y_key = y_key.split(',') size_key = None if len(sys.argv) < 5 else sys.argv[4].split(',') color_key = None if len(sys.argv) < 6 else sys.argv[5].split(',') # Get prefix prefix_filter_fn = lambda k, v: np.any([k.startswith(p) for p in prefix]) # Load the data (should group, but ... later.) data = get_all_data().filter(prefix_filter_fn) size_label = ' Marker size indicates\n %s %s' % ( compute_scatter_label(size_key, part='key_type').lower(), ', '.join([prefix2text(p).lower() for p in prefix])) ax = plot_scatter_4D(data, x_key=x_key, y_key=y_key, size_key=size_key, color_key=color_key, size_label=size_label, add_marker_text=False) #x_label='Asymmetry Index (mean)', y_label='Asymmetry Index (std)', ax.get_figure().suptitle(', '.join([prefix2text(p) for p in prefix]), fontsize=24) plt.show()