diff --git a/web-server/plugins/slycat-dac/py/dac_compute_coords.py b/web-server/plugins/slycat-dac/py/dac_compute_coords.py index 0fbec471f..86e03753a 100755 --- a/web-server/plugins/slycat-dac/py/dac_compute_coords.py +++ b/web-server/plugins/slycat-dac/py/dac_compute_coords.py @@ -28,7 +28,11 @@ from scipy import spatial from sklearn.decomposition import PCA -from natsort import natsorted +# better version of natural sort +# from natsort import natsorted + +# for natural sort function +import re import cherrypy @@ -703,6 +707,16 @@ def compute_prop_dist_vec(prop_vec, vec_length): return prop_dist_vec / prop_dist_vec_max +# helper function for compute alpha to do natural sort +# taken from Ned Batchelder's blog +def natsorted( l ): + + convert = lambda text: int(text) if text.isdigit() else text + alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)] + + return sorted(l, key=alphanum_key) + + # use max-min algorithm to choose landmarks def select_landmarks(num_points, num_landmarks, variable):