Skip to content
Snippets Groups Projects
Commit 9491ad65 authored by Joshua Steer's avatar Joshua Steer
Browse files

Modified structure of analyse to version 0.2

parent dbdaa5d6
No related branches found
No related tags found
No related merge requests found
...@@ -16,22 +16,19 @@ import AmpScan.cython_ext as cyext ...@@ -16,22 +16,19 @@ import AmpScan.cython_ext as cyext
class analyseMixin(object): class analyseMixin(object):
def plot_slices(self, axis='Z', slWidth=10, stype=0): def plot_slices(self, axis='Z', slWidth=10, stype=0):
if isinstance(stype, int):
stype = self.stype[stype]
data = getattr(self, stype)
# Find the brim edges # Find the brim edges
ind = np.where(data['faceEdges'][:,1] == -99999) ind = np.where(self.faceEdges[:,1] == -99999)
# Define max Z from lowest point on brim # Define max Z from lowest point on brim
maxZ = data['vert'][data['edges'][ind, :], 2].min() maxZ = self.vert[self.edges[ind, :], 2].min()
fig = plt.figure() fig = plt.figure()
fig.set_size_inches(6, 4.5) fig.set_size_inches(6, 4.5)
ax1 = fig.add_subplot(221, projection='3d') ax1 = fig.add_subplot(221, projection='3d')
ax2 = fig.add_subplot(222) ax2 = fig.add_subplot(222)
#Z position of slices #Z position of slices
slices = np.arange(data['vert'][:,2].min() + slWidth, slices = np.arange(self.vert[:,2].min() + slWidth,
maxZ, slWidth) maxZ, slWidth)
polys = analyseMixin.create_slices_cy(data, slices, axis) polys = self.create_slices_cy(slices, axis)
PolyArea = np.zeros([len(polys)]) PolyArea = np.zeros([len(polys)])
for i, poly in enumerate(polys): for i, poly in enumerate(polys):
ax1.plot(poly[:,0], ax1.plot(poly[:,0],
...@@ -54,29 +51,28 @@ class analyseMixin(object): ...@@ -54,29 +51,28 @@ class analyseMixin(object):
ax2.plot(slices-slices[0], PolyArea) ax2.plot(slices-slices[0], PolyArea)
# Rendering of the limb scan # Rendering of the limb scan
ax3 = fig.add_subplot(2,2,3) ax3 = fig.add_subplot(2,2,3)
self.addActor(stype='limb') Im = self.genIm()
Im = self.genIm(actor=['limb'])
ax3.imshow(Im, None) ax3.imshow(Im, None)
ax3.set_axis_off() ax3.set_axis_off()
# Rendering of the rectification map # Rendering of the rectification map
ax4 = fig.add_subplot(2,2,4) ax4 = fig.add_subplot(2,2,4)
self.addActor(stype='reglimb', CMap = self.CMapN2P) self.addActor(CMap = self.CMapN2P)
Im = self.genIm(actor=['reglimb']) Im = self.genIm()
ax4.imshow(Im, None) ax4.imshow(Im, None)
ax4.set_axis_off() ax4.set_axis_off()
plt.tight_layout() plt.tight_layout()
plt.show() plt.show()
@staticmethod @staticmethod
def create_slices(data, slices, axis='Z'): def create_slices(self, slices, axis='Z'):
vE = data['vert'][:,2][data['edges']] vE = self.vert[:,2][self.edges]
# Find all vertices below plane # Find all vertices below plane
polys = [] polys = []
for i, plane in enumerate(slices): for i, plane in enumerate(slices):
ind = vE < plane ind = vE < plane
# Select edges with one vertex above and one below the slice plane # Select edges with one vertex above and one below the slice plane
validEdgeInd = np.where(np.logical_xor(ind[:,0], ind[:,1]))[0] validEdgeInd = np.where(np.logical_xor(ind[:,0], ind[:,1]))[0]
validfE = data['faceEdges'][validEdgeInd, :].astype(int) validfE = self.faceEdges[validEdgeInd, :].astype(int)
g = defaultdict(set) g = defaultdict(set)
faceOrder = np.zeros(len(validEdgeInd), dtype=int) faceOrder = np.zeros(len(validEdgeInd), dtype=int)
# Run eularian path algorithm to order faces # Run eularian path algorithm to order faces
...@@ -95,7 +91,7 @@ class analyseMixin(object): ...@@ -95,7 +91,7 @@ class analyseMixin(object):
j+=1 j+=1
v = w v = w
# Get array of three edges attached to each face # Get array of three edges attached to each face
validEdges = data['edgesFace'][faceOrder, :] validEdges = self.edgesFace[faceOrder, :]
# Remove the edge that is not intersected by the plane # Remove the edge that is not intersected by the plane
edges = validEdges[np.isin(validEdges, validEdgeInd)].reshape([-1,2]) edges = validEdges[np.isin(validEdges, validEdgeInd)].reshape([-1,2])
# Remove the duplicate edge from order # Remove the duplicate edge from order
...@@ -108,25 +104,25 @@ class analyseMixin(object): ...@@ -108,25 +104,25 @@ class analyseMixin(object):
sortE = e[mask] sortE = e[mask]
# Add first edge to end of array # Add first edge to end of array
sortE = np.append(sortE, sortE[0]) sortE = np.append(sortE, sortE[0])
polyEdge = data['edges'][sortE] polyEdge = self.edges[sortE]
EdgePoints = np.c_[data['vert'][polyEdge[:,0], :], EdgePoints = np.c_[self.vert[polyEdge[:,0], :],
data['vert'][polyEdge[:,1], :]] self.vert[polyEdge[:,1], :]]
#Create poly from #Create poly from
polys.append(analyseMixin.planeEdgeintersect(EdgePoints, plane, axis=axis)) polys.append(analyseMixin.planeEdgeintersect(EdgePoints, plane, axis=axis))
return polys return polys
def create_slices_cy(data, slices, axis='Z'): def create_slices_cy(self, slices, axis='Z'):
vE = data['vert'][:,2][data['edges']] vE = self.vert[:,2][self.edges]
# Find all vertices below plane # Find all vertices below plane
polys = [] polys = []
for i, plane in enumerate(slices): for i, plane in enumerate(slices):
ind = vE < plane ind = vE < plane
# Select edges with one vertex above and one below the slice plane # Select edges with one vertex above and one below the slice plane
validEdgeInd = np.where(np.logical_xor(ind[:,0], ind[:,1]))[0] validEdgeInd = np.where(np.logical_xor(ind[:,0], ind[:,1]))[0]
validfE = data['faceEdges'][validEdgeInd, :].astype(int) validfE = self.faceEdges[validEdgeInd, :].astype(int)
faceOrder = cyext.logEuPath(validfE) faceOrder = cyext.logEuPath(validfE)
#Get array of three edges attached to each face #Get array of three edges attached to each face
validEdges = data['edgesFace'][faceOrder, :] validEdges = self.edgesFace[faceOrder, :]
# Remove the edge that is not intersected by the plane # Remove the edge that is not intersected by the plane
edges = validEdges[np.isin(validEdges, validEdgeInd)].reshape([-1,2]) edges = validEdges[np.isin(validEdges, validEdgeInd)].reshape([-1,2])
# Remove the duplicate edge from order # Remove the duplicate edge from order
...@@ -139,9 +135,9 @@ class analyseMixin(object): ...@@ -139,9 +135,9 @@ class analyseMixin(object):
sortE = e[mask] sortE = e[mask]
# Add first edge to end of array # Add first edge to end of array
sortE = np.append(sortE, sortE[0]) sortE = np.append(sortE, sortE[0])
polyEdge = data['edges'][sortE] polyEdge = self.edges[sortE]
EdgePoints = np.c_[data['vert'][polyEdge[:,0], :], EdgePoints = np.c_[self.vert[polyEdge[:,0], :],
data['vert'][polyEdge[:,1], :]] self.vert[polyEdge[:,1], :]]
# Create poly from # Create poly from
# polys.append(analyseMixin.planeEdgeintersect(EdgePoints, plane, axis=axis)) # polys.append(analyseMixin.planeEdgeintersect(EdgePoints, plane, axis=axis))
polys.append(cyext.planeEdgeIntersect(EdgePoints, plane, 2)) polys.append(cyext.planeEdgeIntersect(EdgePoints, plane, 2))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment