def process_data(r0): r0 = lm.shuffle_points(r0) ### CPD registration rtemp0, n, i = lm.get_shape_with_most_points(r0) r1 = lm.register_cpd(r0, rtemp0) ### reorder points: r2 = lm.reorder_points(r1, optimum_order=True, ensure_clockwise=True) ### correspondence: rtemp1 = r2[i] r3 = lm.set_npoints(r2, n) r4 = lm.corresp_roll(r3, rtemp1) return r4, rtemp1
r = lm.read_csv(fnameCSV) i0, i1 = 1, 2 r0, r1 = r[i0], r[i1] #(1) Process: np.random.seed(0) ### shuffle: rA0, rA1 = lm.shuffle_points(r0), lm.shuffle_points(r1) ### reorder: rB0, rB1 = [ lm.reorder_points(r, optimum_order=True, ensure_clockwise=True) for r in [rA0, rA1] ] ### optimum roll correspondence: rD0 = rB0.copy() rD1 = lm.corresp_roll(rB1, rB0) ### intermediary roll: rC0 = rB0.copy() rC1 = np.roll(rB1, 75, axis=0) #(1) Plot: plt.close('all') lm.set_matplotlib_rcparams() fig = plt.figure(figsize=(10, 3)) # create axes: axw, axh = 0.25, 0.95 axx = np.linspace(0, 1, 5)[:4] AX = [plt.axes([x, 0, axw, axh]) for x in axx] ax0, ax1, ax2, ax3 = AX # plot: handles = lm.plot_correspondence(ax0, rA0, rA1)
'Bell', 'Comma', 'Device8', 'Face', 'Flatfish', 'Hammer', 'Heart', 'Horseshoe', 'Key' ] name = names[6] fname0 = os.path.join(dirREPO, 'Data', name, 'contours.csv') r0 = lm.read_csv(fname0) r0 = lm.shuffle_points(r0) ### CPD registration rtemp0, n, i = lm.get_shape_with_most_points(r0) r1 = lm.register_cpd(r0, rtemp0) ### reorder points: r2 = lm.reorder_points(r1, optimum_order=True, ensure_clockwise=True) ### correspondence: rtemp1 = r2[i] r3 = lm.set_npoints(r2, n) r4 = lm.corresp_roll(r3, rtemp1) ### process data: np.random.seed(0) # Case 1 r1, rtemp1 = process_data(r0) np.random.seed(2) # Case 2 r2, rtemp2 = process_data(r0) ### hypothesis tests: rA1, rB1 = r1[:5], r1[5:] rA2, rB2 = r2[:5], r2[5:] results1 = lm.two_sample_test(rA1, rB1, parametric=True) results2 = lm.two_sample_test(rA2, rB2, parametric=True) #(1) Plot all results: plt.close('all') lm.set_matplotlib_rcparams() plt.figure(figsize=(10, 8))