Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions slam/sulcal_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ def get_sulcal_graph(adjacency, basins, ridges, save=True, outdir=None):
i = labels.index(pair[0])
j = labels.index(pair[1])
edge_attributes[i, j] = values # add all dictionary values
print(values)
for ed in range(len(graph.edges)):
print("Edge "+str(ed)+" attributes:",
graph.edges[list(graph.edges)[ed]].keys())
# print(values)
# for ed in range(len(graph.edges)):
# print("Edge "+str(ed)+" attributes:",
# graph.edges[list(graph.edges)[ed]].keys())

nx.set_edge_attributes(graph, edge_attributes)
for ed in range(len(graph.edges)):
print("Edge "+str(ed)+" attributes:",
graph.edges[list(graph.edges)[ed]].keys())
# for ed in range(len(graph.edges)):
# print("Edge "+str(ed)+" attributes:",
# graph.edges[list(graph.edges)[ed]].keys())

if save:
if not outdir:
Expand Down
10 changes: 6 additions & 4 deletions tests/test_sulcal_depth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@

acceptable_error = 0.0001


class TestSulcalDepth(unittest.TestCase):
test_mesh = sio.load_mesh('examples/data/example_mesh.gii')
test_dpf = sio.load_texture('examples/data/example_dpf.gii').darray[0]
test_dpf_star = sio.load_texture('examples/data/example_dpf_star.gii').darray[0]
dpf = sdepth.depth_potential_function(test_mesh)[0]
dpf = sdepth.depth_potential_function(test_mesh, alphas=[0.3])[0]
dpf_star = sdepth.dpf_star(test_mesh)[0]

def test_basic(self):
# test size
self.assertTrue(self.test_dpf.shape==self.dpf.shape)
self.assertTrue(self.test_dpf.shape == self.dpf.shape)
self.assertTrue(self.test_dpf_star.shape == self.dpf_star.shape)

def test_consistency(self):
self.assertTrue(np.max(np.abs(self.test_dpf-self.dpf)) < acceptable_error)
self.assertTrue(np.max(np.abs(self.test_dpf - self.dpf)) < acceptable_error)
self.assertTrue(np.max(np.abs(self.test_dpf_star - self.dpf_star)) < acceptable_error)

if __name__ == "__main__":

if __name__ == "__main__":
unittest.main()
5 changes: 3 additions & 2 deletions tests/test_sulcal_graph.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
import numpy as np
import networkx as nx
from slam import sulcal_graph
from slam import sulcal_graph, geodesics
from slam import texture


Expand Down Expand Up @@ -65,8 +65,9 @@ def test_add_geodesic_distances(self):
def mock_compute_gdist(mesh, ridge):
return np.array([0.0, 1.0, 2.0, 3.0, 4.0])

sulcal_graph.geodesics.compute_gdist = mock_compute_gdist
geodesics.compute_gdist = mock_compute_gdist
g = sulcal_graph.add_geodesic_distances_to_graph(self.graph, self.mesh, save=False)
print(g.edges[list(g.edges)[0]])

self.assertIn("geodesic_distance_btw_ridge_pit_i", g.edges[list(g.edges)[0]].keys())
self.assertIn("geodesic_distance_btw_ridge_pit_j", g.edges[list(g.edges)[0]].keys())
Expand Down
Loading