forked from btorb/btmorph_v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added functions in NeuronMorphogy to calculate intersection vs distan…
…ce and length vs distance
- Loading branch information
Showing
7 changed files
with
356 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from btmorph2.auxFuncs import getIntersectionXYZs | ||
import numpy as np | ||
|
||
|
||
def getPointAtDistance_test(): | ||
""" | ||
Testing getIntersectionXYZs function | ||
""" | ||
|
||
# case1, two equal real intersections | ||
parentXYZ = [20, 0, 0] | ||
childXYZ = [20, -10, 0] | ||
centeredAt = [0, 0, 0] | ||
radius = 20 | ||
expectedIntersects = [[20, 0, 0], [20, 0, 0]] | ||
intersects = getIntersectionXYZs(parentXYZ, childXYZ, centeredAt, radius) | ||
assert np.shape(expectedIntersects) == np.shape(intersects) and np.allclose(expectedIntersects, intersects, | ||
atol=1e-2) | ||
|
||
# case2, one real intersections | ||
parentXYZ = [10, 0, 0] | ||
childXYZ = [20, -10, 0] | ||
centeredAt = [0, 0, 0] | ||
radius = 15 | ||
expectedIntersects = [[14.35, -4.35, 0.0]] | ||
intersects = getIntersectionXYZs(parentXYZ, childXYZ, centeredAt, radius) | ||
assert np.shape(expectedIntersects) == np.shape(intersects) and np.allclose(expectedIntersects, intersects, | ||
atol=1e-2) | ||
|
||
# case 3, one real intersections | ||
parentXYZ = [20, 0, 0] | ||
childXYZ = [30, 10, 0] | ||
centeredAt = [0, 0, 0] | ||
radius = 25 | ||
expectedIntersects = [[24.58, 4.58, 0.0]] | ||
intersects = getIntersectionXYZs(parentXYZ, childXYZ, centeredAt, radius) | ||
assert np.shape(expectedIntersects) == np.shape(intersects) and np.allclose(expectedIntersects, intersects, | ||
atol=1e-2) | ||
|
||
# case 4, no intersections | ||
parentXYZ = [50, -10, 0] | ||
childXYZ = [50, -20, 0] | ||
centeredAt = [0, 0, 0] | ||
radius = 50 | ||
expectedIntersects = [] | ||
intersects = getIntersectionXYZs(parentXYZ, childXYZ, centeredAt, radius) | ||
assert np.shape(expectedIntersects) == np.shape(intersects) and np.allclose(expectedIntersects, intersects, | ||
atol=1e-2) | ||
|
||
# case 5, two unequal real intersections | ||
parentXYZ = [2.5, 7.5, 0] | ||
childXYZ = [2.5, -7.5, 0] | ||
centeredAt = [0, 0, 0] | ||
radius = 5 | ||
expectedIntersects = [[2.5, 4.33, 0.0], [2.5, -4.33, 0.0]] | ||
intersects = getIntersectionXYZs(parentXYZ, childXYZ, centeredAt, radius) | ||
assert np.shape(expectedIntersects) == np.shape(intersects) and np.allclose(expectedIntersects, intersects, | ||
atol=1e-2) | ||
|
||
if __name__ == "__main__": | ||
intersects = getIntersectionXYZs(p1=[20, 30, 0], p2=[30, 40, 0], radius=50, centeredAt=[0, 0, 0]) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Horton-Strahler index example from wikipedia | ||
#http://en.wikipedia.org/wiki/Strahler_number | ||
#http://en.wikipedia.org/wiki/File:Flussordnung_%28Strahler%29.svg | ||
#For testing purposes | ||
1 1 -1.0 -1.0 -1.0 1.9 -1 | ||
2 3 0.0 10 0.0 1 1 | ||
3 3 -10.0 20.0 0.0 1 2 | ||
4 3 0.0 20.0 0.0 1 2 | ||
5 3 10.0 30.0 0.0 1 4 | ||
6 3 20.0 30.0 0.0 1 5 | ||
7 3 30.0 30.0 0.0 1 6 | ||
8 3 30.0 40.0 0.0 1 6 | ||
9 3 10.0 40.0 0.0 1 5 | ||
10 3 20.0 40.0 0.0 1 9 | ||
11 3 10.0 50.0 0.0 1 9 | ||
12 3 0.0 30.0 0.0 1 4 | ||
13 3 -10.0 40.0 0.0 1 12 | ||
14 3 0.0 40.0 0.0 1 12 | ||
15 3 -10.0 50.0 0.0 1 14 | ||
16 3 -20.0 50.0 0.0 1 15 | ||
17 3 -10.0 60.0 0.0 1 15 | ||
18 3 0.0 50.0 0.0 1 14 | ||
19 3 0.0 60.0 0.0 1 18 | ||
20 3 10.0 60.0 0.0 1 18 | ||
21 3 12.5 -2.5 0.0 1 2 | ||
22 3 -17.5 42.5 0.0 1 16 |
Oops, something went wrong.