Skip to content

Commit

Permalink
Syntax update + change to fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
frisograce committed May 28, 2024
1 parent 95e432a commit f34faef
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions simpa/utils/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ def rotation_x(theta):
:return: rotation matrix
"""
return torch.tensor([[1, 0, 0],
[0, torch.cos(theta), -torch.sin(theta)],
[0, torch.sin(theta), torch.cos(theta)]])
[0, torch.cos(theta), -torch.sin(theta)],
[0, torch.sin(theta), torch.cos(theta)]])


def rotation_y(theta):
Expand All @@ -145,8 +145,8 @@ def rotation_y(theta):
:return: rotation matrix
"""
return torch.tensor([[torch.cos(theta), 0, torch.sin(theta)],
[0, 1, 0],
[-torch.sin(theta), 0, torch.cos(theta)]])
[0, 1, 0],
[-torch.sin(theta), 0, torch.cos(theta)]])


def rotation_z(theta):
Expand All @@ -157,8 +157,8 @@ def rotation_z(theta):
:return: rotation matrix
"""
return torch.tensor([[torch.cos(theta), -torch.sin(theta), 0],
[torch.sin(theta), torch.cos(theta), 0],
[0, 0, 1]])
[torch.sin(theta), torch.cos(theta), 0],
[0, 0, 1]])


def rotation(angles):
Expand Down
2 changes: 1 addition & 1 deletion simpa/utils/libraries/structure_library/VesselStructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def calculate_vessel_samples(self, position, direction, bifurcation_length, radi
position_array.append(position)
radius_array.append(np.random.uniform(-1, 1) * radius_variation + radius)

step_vector = torch.rand(3).to(self.torch_device) * 2 -1
step_vector = torch.rand(3).to(self.torch_device) * 2 - 1
step_vector = direction + curvature_factor * step_vector
direction = step_vector / torch.linalg.norm(step_vector)
samples += 1
Expand Down
22 changes: 11 additions & 11 deletions simpa_tests/automatic_tests/structure_tests/test_vesseltree.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ def test_bifurcation(self):
left_plane = ts.geometrical_volume[0, :, :]
right_plane = ts.geometrical_volume[-1, :, :]

end_plane_count = measure.label(end_plane, background = 0, return_num = True)[1]
top_plane_count = measure.label(top_plane, background = 0, return_num = True)[1]
bottom_plane_count = measure.label(bottom_plane, background = 0, return_num = True)[1]
left_plane_count = measure.label(left_plane, background = 0, return_num = True)[1]
right_plane_count = measure.label(right_plane, background = 0, return_num = True)[1]
end_plane_count = measure.label(end_plane, background=0, return_num=True)[1]
top_plane_count = measure.label(top_plane, background=0, return_num=True)[1]
bottom_plane_count = measure.label(bottom_plane, background=0, return_num=True)[1]
left_plane_count = measure.label(left_plane, background=0, return_num=True)[1]
right_plane_count = measure.label(right_plane, background=0, return_num=True)[1]
assert end_plane_count + top_plane_count + bottom_plane_count + left_plane_count + right_plane_count == 2

def test_radius_variation_factor(self):
Expand All @@ -77,8 +77,8 @@ def test_radius_variation_factor(self):

vessel_centre = 5
edge_of_vessel = vessel_centre + self.vesseltree_settings[Tags.STRUCTURE_RADIUS_MM]
has_reduced = np.min(ts.geometrical_volume[edge_of_vessel-1,:,vessel_centre])
has_increased = np.max(ts.geometrical_volume[edge_of_vessel+1,:,vessel_centre])
has_reduced = np.min(ts.geometrical_volume[edge_of_vessel-1, :, vessel_centre])
has_increased = np.max(ts.geometrical_volume[edge_of_vessel+1, :, vessel_centre])

assert has_reduced == 0 or has_increased != 0

Expand All @@ -95,10 +95,10 @@ def test_curvature_factor(self):
vessel_centre = 5
edge_of_vessel = radius + vessel_centre

assert np.max(np.nditer(ts.geometrical_volume[edge_of_vessel+1,:,:])) != 0 \ #check above
or np.max(np.nditer(ts.geometrical_volume[-edge_of_vessel-1,:,:])) != 0 \ #check below
or np.max(np.nditer(ts.geometrical_volume[:,:,edge_of_vessel+1])) != 0 \ #check left
or np.max(np.nditer(ts.geometrical_volume[:,:,-edge_of_vessel-1])) != 0 #check right
assert np.max(np.nditer(ts.geometrical_volume[edge_of_vessel+1, :, :])) != 0 \
or np.max(np.nditer(ts.geometrical_volume[-edge_of_vessel-1, :, :])) != 0 \
or np.max(np.nditer(ts.geometrical_volume[:, :, edge_of_vessel+1])) != 0 \
or np.max(np.nditer(ts.geometrical_volume[:, :, -edge_of_vessel-1])) != 0

def test_vessel_tree_geometrical_volume(self):
ts = VesselStructure(self.global_settings, self.vesseltree_settings)
Expand Down

0 comments on commit f34faef

Please sign in to comment.