analyse module¶
Package for dealing with analysis methods of the ampObject and generating reports Copyright: Joshua Steer 2020, Joshua.Steer@soton.ac.uk
- CMapOut(amp, colors)
Colour Map with 4 views (copied Josh’s code)
- MeasurementsOut(amp, pos)
Calculates perimeter of limb/cast at intervals from mid-patella to the end of stump Takes position of mid-patella (x,y,z) coordinates as input Also creates images of limb views and graphs of CSA/Widths, which are used in the PDF. Calls the function responsible for adding the information to the PDF template. TODO: Split this into functions for each part i.e. Volume measure, CSA, widths
- Return type
The path to the output file
- calc_csa(polys)
Calculate the cross sectional area of each polygon from the slicing of the AmpObject
- Parameters
polys (list) – A list of numpy arrays, each array contains the vertices of the polygon generated from the slice. Generate using ampscan.analyse.create_slices()
- Returns
csa – Returns the cross-sectional area of the limb in mm^2 along the axis
- Return type
array_like
- calc_perimeter(polys)
Calculate the perimeter of each polygon from the slicing of the AmpObject
- Parameters
polys (list) – A list of numpy arrays, each array contains the vertices of the polygon generated from the slice. Generate using ampscan.analyse.create_slices()
- Returns
perimeter – Returns the perimeter of the limb in mm along the axis
- Return type
array_like
- calc_volume_closed(amp_in, return_closed=False)
Calculates the volume of a closed surface. If the surface is not closed the algorithm fills in the holes using a simple hole filling algorithm, the surface without holes can be accessed if return_closed is set to True.
- Parameters
amp (AmpObject) – The AmpObject to analyse
return_closed (bool, default False) – Indicate whether to return the shape with holes filled in
- Returns
vol (float) – The volume of the AmpObject
amp (AmpObject) – If return_closed is True, then the closed shape is returned
- calc_widths(polys)
Calculate the coronal and sagittal widths of each polygon from the slicing of the AmpObject
Assumes that coronal width corresponds with the x-axis
- Parameters
polys (list) – A list of numpy arrays, each array contains the vertices of the polygon generated from the slice. Generate using ampscan.analyse.create_slices()
- Returns
cor_width (array_like) – Returns the coronal width in mm along the axis
sag_width (array_like) – Returns the sagittal width in mm along the axis
- create_slices(amp, *args, typ='slices', axis=2, order=True)
Generate polygons from planar slices through the AmpObject. The slices are either defined as a list of positions in some axis
- Parameters
amp (AmpObject) – The AmpObject to analyse
slices (array_like) – An array of the slice positions to take in the specified axis
limits (array_like) – The limits of the slices, either in real world units or normalised depending on that specified in typ
intervals (float) – The distance between slices, use in conjunction with
typ (str, 'slices', 'real_intervals', 'norm_intervals') – The height of the slice planes
axis (int, default 2) – The index of the axis to take the slices along
- Returns
polys – A list of numpy arrays, each array contains the vertices of the polygon generated from the slice
- Return type
list
Examples
>>> amp = AmpObject(filename) >>> polys = create_slices(amp, [0.05, 0.95], 0.01, typ='norm_intervals', axis=2) >>> polys = create_slices(amp, [-150, -100, -50, 0], typ='slices', axis=2) >>> polys = create_slices(amp, [-150, 0], 10, typ='real_intervals', axis=2)
- est_volume(polys)
Estimate the volume of the limb using bounds of the slices
- Parameters
polys (list) – A list of numpy arrays, each array contains the vertices of the polygon generated from the slice. Generate using ampscan.analyse.create_slices()
- Returns
Volume – Returns the estimated volume of the limb in mm^3 along the axis
- Return type
float
- logEuPath(arr)
Calculate the eularian path for an array of edges so the vertices all connect
- planeEdgeIntersect_cy(arr, plane, axisInd)
Calculate the intersection between a an array of edges and a plane
- Parameters
edges (array_like) – The edge array which have been calculated to cross the plane
plane (float) – The height of the plane
axis (int, default 2) – The index of the axis of the slice
- Returns
intersectPoints – The intersection points between the edges and the plane
- Return type
ndarray
- planeEdgeintersect(edges, plane, axis=2)
Calculate the intersection between a an array of edges and a plane
- Parameters
edges (array_like) – The edge array which have been calculated to cross the plane
plane (float) – The height of the plane
axis (int, default 2) – The index of the axis of the slice
- Returns
intersectPoints – The intersection points between the edges and the plane
- Return type
ndarray
- plot_slices(amp, axis=2, slWidth=10)
Generate a mpl figure with information about the AmpObject
Top Left - Slices Top Right - Change in cross sectional area through slices Bottom Left - Rendering of shape Bottom Right - Rendering of shape with values
TODO: Split this up so each figure is it’s own function, top level function to tailor figure to user
- Parameters
axis (int, default 2) – Axis along which to take slices
slWidth (float, default 10) – Distance between slices
- Returns
fig (mpl figure) – The mpl figure generated by the function
ax (tuple) – A tuple of axes used for each subplot in the figure
- visualise_slices(amp)
Create an mpl figure with the 3D rendering, slices, slice height and cross sectional area