topostats.tracing.tracingfuncs#
Classes#
Skeltonisation algorithm based on the paper "A Fast Parallel Algorithm for |
|
Module Contents#
- class topostats.tracing.tracingfuncs.getSkeleton(image_data, binary_map, number_of_columns, number_of_rows, pixel_size)[source]#
Skeltonisation algorithm based on the paper “A Fast Parallel Algorithm for Thinning Digital Patterns” by Zhang et al., 1984
- image_data#
- binary_map#
- number_of_columns#
- number_of_rows#
- pixel_size#
- p2 = 0#
- p3 = 0#
- p4 = 0#
- p5 = 0#
- p6 = 0#
- p7 = 0#
- p8 = 0#
- mask_being_skeletonised = []#
- output_skeleton = []#
- skeleton_converged = False#
- pruning = True#
- average_height = 0#
- highest_points#
- search_window#
- dir_search#
- _doSkeletonisingIteration()[source]#
Do an iteration of skeletonisation - check for the local binary pixel environment and assess the local height values to decide whether to delete a point
- _deletePixelSubit1(point)[source]#
Function to check whether a single point should be deleted based on both its local binary environment and its local height values
- _deletePixelSubit2(point)[source]#
Function to check whether a single point should be deleted based on both its local binary environment and its local height values
- finalSkeletonisationIteration()[source]#
A final skeletonisation iteration that removes “hanging” pixels. Examples of such pixels are:
[0, 0, 0] [0, 1, 0] [0, 0, 0] [0, 1, 1] [0, 1, 1] [0, 1, 1]
case 1: [0, 1, 0] or case 2: [0, 1, 0] or case 3: [1, 1, 0]
This is useful for the future functions that rely on local pixel environment to make assessments about the overall shape/structure of traces
- class topostats.tracing.tracingfuncs.reorderTrace[source]#
- static linearTrace(trace_coordinates)[source]#
My own function to order the points from a linear trace.
This works by checking the local neighbours for a given pixel (starting at one of the ends). If this pixel has only one neighbour in the array of unordered points, this must be the next pixel in the trace – and it is added to the ordered points trace and removed from the remaining_unordered_coords array.
If there is more than one neighbouring pixel, a fairly simple function (checkVectorsCandidatePoints) finds which pixel incurs the smallest change in angle compared with the rest of the trace and chooses that as the next point.
This process is repeated until all the points are placed in the ordered trace array or the other end point is reached.
- static circularTrace(trace_coordinates)[source]#
An alternative implementation of the linear tracing algorithm but with some adaptations to work with circular dna molecules
- static circularTrace_old(trace_coordinates)[source]#
Reorders the coordinates of a trace from a circular DNA molecule (with no loops) using a polar coordinate system with reference to the center of mass
I think every step of this can be vectorised for speed up
This is vulnerable to bugs if the dna molecule folds in on itself slightly
- class topostats.tracing.tracingfuncs.genTracingFuncs[source]#
-
- static countNeighbours(x, y, trace_coordinates)[source]#
Counts the number of neighbouring points for a given coordinate in a list of points
- static getNeighbours(x, y, trace_coordinates)[source]#
Returns an array containing the neighbouring points for a given coordinate in a list of points