Skip to content

Commit 9d23067

Browse files
get distances
1 parent 9fcd95f commit 9d23067

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

wormbrain/brains.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,29 @@ def get_closest_neuron(self,volume,coord,inverse_match=True,z_true=False,coord_o
767767

768768
return closest
769769

770+
def get_distance(self, volume, i, j):
771+
'''Get the distance, in trueCoords units, between neuron i and neuron j.
772+
773+
Parameters
774+
----------
775+
volume: int
776+
Index of the volume in which to compute the distance.
777+
i, j: int
778+
Indices of the two neurons.
779+
780+
Returns
781+
-------
782+
d: float
783+
Euclidean distance between neurons i and j.
784+
'''
785+
786+
c = self.trueCoords(volume)
787+
ci = c[i]
788+
cj = c[j]
789+
d = np.sqrt(np.sum((ci-cj)**2))
790+
791+
return d
792+
770793
def set_labels(self, vol, labels, confidences=None):
771794
self.labels[vol] = labels
772795
if confidences is not None:

0 commit comments

Comments
 (0)