Commit a39bbe4e authored by Edward Andò's avatar Edward Andò
Browse files

safety asserts in labelTet

parent 9cb68e5b
Pipeline #51304 passed with stages
in 24 minutes and 19 seconds
......@@ -760,11 +760,11 @@ def labelTetrahedra(dims, points, connectivity):
----------
dims: tuple representing z,y,x dimensions of the desired labelled output
points: 3 x number of points array of floats
points: number of points x 3 array of floats
List of points that define the vertices of the tetrahedra in Z,Y,X format.
These points are referred to by line number in the connectivity array
connectivity: 4 x number of tetrahedra array of integers
connectivity: number of tetrahedra x 4 array of integers
Connectivity matrix between points that define tetrahedra.
Each line defines a tetrahedron whose number is the line number + 1.
Each line contains 4 integers that indicate the 4 points in the nodePos array.
......@@ -774,6 +774,10 @@ def labelTetrahedra(dims, points, connectivity):
3D array of ints, shape = dims
Labelled 3D volume where voxels are numbered according to the tetrahedron number they fall inside of
"""
assert(len(dims) == 3), "spam.label.labelTetrahedra(): dim is not length 3"
assert(points.shape[1] == 3), "spam.label.labelTetrahedra(): points doesn't have 3 colums"
assert(connectivity.shape[1] == 4), "spam.label.labelTetrahedra(): connectivity doesn't have 4 colums"
assert(points.shape[0] >= connectivity.max()), "spam.label.labelTetrahedra(): connectivity should not refer to points numbers biggest than the number of rows in points"
dims = numpy.array(dims).astype('<u2')
lab = numpy.ones(tuple(dims), dtype=labelType)*connectivity.shape[0]+1
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment