The bootESA method creates empirical confidence intervals of the Elastic Shape Distance (ESD) between a contour of some true space of interest and contours in some learned mean of that space. These intervals are created using the m-out-of-n bootstrap procedure. A hypothesis test of a null shape can test the shape of the object in the true space of interest. Details are in: https://arxiv.org/pdf/2606.04879
Here are some instructions to go along with the code if you want to use the fdasrsf package (ESA package). A major issue with this method is that the curves must be going the same direction either clockwise or counter clockwise for the confidence intervals of the ESD to be correct. Sometimes the fdasrsf package is able to optimize curves so that the parameterization is correct (both clockwise or both counterclockwise) when calculating the ESD. However, sometimes it will not be able to; there are two options:
- Do not alter source code and see if the ESD is correct. The function in the bootESA repository
esa_distwill output True, False values indicating if a resampled curve is clockwise or counterclockwise. Setesa_dist(...,plot=True)to be able to visually look at the curve direction. As long as all the curves are clockwise or all the curves are counterclockwise, the bootESA method will work. If at least one curve has a different direction thehyptest()function will output an error.
Go to this part of the hyptest.ipynb to test:
###### All contours must be going the same direction.
# You will get an error if you do not have this and your distances will be wrong.
# See example below as an illlustration
# Generate circle which goes clockwise
def circle_curve(n=800, R=1.0, center=(0.0, 0.0)):
t = np.linspace(0, 2*np.pi, n, endpoint=True)
x = center[0] + R * np.cos(t)
y = center[1] - R * np.sin(t)
return np.column_stack((x, y))
clockwise = circle_curve()
# Generate circle which goes counterclockwise
def circle_curve(n=800, R=1.0, center=(0.0, 0.0)):
t = np.linspace(0, 2*np.pi, n, endpoint=True)
x = center[0] + R * np.cos(t)
y = center[1] + R * np.sin(t)
return np.column_stack((x, y))
counterclockwise = circle_curve()
# Sometimes the fdasrsf can get this correct but sometimes it can't, see Readme file for further instructions on how to fix this
ESD, clockwise_bool = esa_dist(clockwise, counterclockwise, 100, True)
# ESD should be zero since they are both circles
print(ESD)
- The second option is to make adjustments to the source code and enforcing one direction for all of the contours and shapes used when calculating the ESD. The confidence set of the ESDs are not correct if the function resamplecurve() is not adjusted. It can sometimes flip the contour from clockwise to counterclockwise in the optimization step. The notebook examples enforce all shapes/contours to be clockwise with one extra step of commenting out the part of the function that changes curve direction:
a) Go to curve_functions.py in fdasrsf package source material
b) Go to the function resamplecurve (should be first one)
c) Remove/comment out this part:
tst = x[:, 1] - x[:, 0] #if tst[0] < 0: # x = fliplr(x)