def compareEdgeLengthsBetweenShapes(drift): """ returns the average edge length for the control set and the drift set for a variable drift """ control, test = patientGen.patientList(drift) t = 0 c = 0 for shape in control: c += shape.frameLength() for shape in test: t += shape.frameLength() return (t / len(control), c / len(test))
def differencesBetweenLandmarksOverTime(drift="a", kwarg=None): """ takes a variable drift and generates the control and test patient set then calculates the differences between each landmark and returns a difference vector. """ before, after = patientGen.patientList(drift, kwarg) diff = [] x = before[0].x.shape[0] * len(before) y = before[0].x.shape[1] for eachB, eachA in zip(before, after): diff.append(eachB.x - eachA.x) diff = np.array(diff).reshape(x, y) return diff
def EDMA(): drift = 0.2 control, test = patientGen.patientList(drift) aveCont = euclideanDistanceMatrix( coordinateWiseAverageOfShapes(control) ) aveTest = euclideanDistanceMatrix( coordinateWiseAverageOfShapes(test) ) D, Dbar = averageFormDifferenceMatrix(aveCont,aveTest) T4 = fourTtest(D, Dbar) T4s = bootstrappingTheNullDistribution(control,test) print "Our T4: %s" %T4 print "The random permuation distribution: %s" %np.mean(T4s) plt.clf() fig = plt.hist(T4s) ymax = max(np.histogram(T4s)[0]) plt.plot((T4, T4), (0, ymax*1.15), 'k-') plt.title("EDMA with drift %s and sigma: 0.1"%drift) plt.show()