-
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.
Merge branch 'main' into refactor-img-windows
- Loading branch information
Showing
6 changed files
with
106 additions
and
193 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
29 changes: 29 additions & 0 deletions
29
src/deep_neurographs/machine_learning/archived/features.txt
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,29 @@ | ||
""" | ||
Created on Sat May 9 11:00:00 2024 | ||
|
||
@author: Anna Grim | ||
@email: anna.grim@alleninstitute.org | ||
|
||
Archived routines for feature generation. | ||
|
||
""" | ||
|
||
def compute_curvature(neurograph, edge): | ||
kappa = curvature(neurograph.edges[edge]["xyz"]) | ||
n_pts = len(kappa) | ||
if n_pts <= N_BRANCH_PTS: | ||
sampled_kappa = np.zeros((N_BRANCH_PTS)) | ||
sampled_kappa[0:n_pts] = kappa | ||
else: | ||
idxs = np.linspace(0, n_pts - 1, N_BRANCH_PTS).astype(int) | ||
sampled_kappa = kappa[idxs] | ||
return np.array(sampled_kappa) | ||
|
||
|
||
def curvature(xyz_list): | ||
a = np.linalg.norm(xyz_list[1:-1] - xyz_list[:-2], axis=1) | ||
b = np.linalg.norm(xyz_list[2:] - xyz_list[1:-1], axis=1) | ||
c = np.linalg.norm(xyz_list[2:] - xyz_list[:-2], axis=1) | ||
s = 0.5 * (a + b + c) | ||
delta = np.sqrt(s * (s - a) * (s - b) * (s - c)) | ||
return 4 * delta / (a * b * c) |
Oops, something went wrong.