src.imagedata.apps.Siemens package
Submodules
src.imagedata.apps.Siemens.ROI module
ROI objects
- class src.imagedata.apps.Siemens.ROI.EllipseROI(centre, angles, thickness, label, stu_ins_uid, ser_ins_uid, sop_ins_uid)[source]
Bases:
ROI
Ellipse ROI object.
- Variables:
centre_cm
angles_cm
thickness_cm
radius_cm
radius_matrix
- draw_roi_on_canvas(canvas, colour=1, threshold=0.5, fill=False)[source]
Make a 2D mask [ny,nx] on canvas
- Parameters:
canvas – 2D [ny,nx]
fill – fill color
self.points_matrix – polygon points
self._slice
- Returns:
canvas
- class src.imagedata.apps.Siemens.ROI.PolygonROI(polygon, label, stu_ins_uid, ser_ins_uid, sop_ins_uid)[source]
Bases:
ROI
Polygon ROI object.
- Variables:
points
- draw_roi_on_canvas(canvas, colour=1, threshold=0.5, fill=False)[source]
Make a 2D mask [ny,nx] on canvas
- Parameters:
canvas – 2D [ny,nx]
self.points_matrix – polygon points
self._slice
fill – whether to fill polygon interior
- Returns:
canvas
- class src.imagedata.apps.Siemens.ROI.ROI(label, stu_ins_uid, ser_ins_uid, sop_ins_uid)[source]
Bases:
object
General ROI object.
- Variables:
points
points_matrix
slice
label
stu_ins_uid
ser_ins_uid
sop_ins_uid
- static create_canvas(shape, mode=<class 'bool'>)[source]
Make a 2D [ny,nx] canvas
- Parameters:
shape – 4D [nt,nz,ny,nx] or 3D [nz,ny,nx] shape
mode – bool for binary image, np.uint8 for 8-bit grayscale image
- abstract draw_roi_on_canvas(canvas, colour=1, threshold=0.5, fill=False)[source]
Make a 2D mask [ny,nx] on canvas
- Parameters:
canvas – 2D [ny,nx]
colour – mask color
fill – whether to fill interior of ROI
self.points_matrix – polygon points
self._slice
- Returns:
binary img of shape [ny,nx]
- draw_roi_on_numpy(mask, colour=1, threshold=0.5, fill=True)[source]
Draw the ROI on an existing numpy array
- Parameters:
mask – numpy array [nz,ny,nx]
colour – mask colour (int)
threshold – alpha blend (float)
fill – whether to fill interior of ROI (bool)
- Returns:
modified numpy array [nz,ny,nx]
- Return type:
mask
- abstract get_points_cm()[source]
Get ROI points as Numpy array in cm real coordinates
- Returns:
np.array([points,3]) where each row is (z,y,x) in cm
src.imagedata.apps.Siemens.draw_antialiased module
Library to draw an antialiased line. http://stackoverflow.com/questions/3122049/drawing-an-anti-aliased-line-with-thepython-imaging-library https://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm
https://yellowsplash.wordpress.com/2009/10/23/fast-antialiased-circles-and-ellipses-from-xiaolin-wus-concepts/ https://stackoverflow.com/questions/37589165/drawing-an-antialiased-circle-as-described-by-xaolin-wu#37714284
- src.imagedata.apps.Siemens.draw_antialiased.boundary_fill4(canvas, start_x, start_y, boundary_value, fill_value)[source]
- src.imagedata.apps.Siemens.draw_antialiased.draw_circle_mask(canvas, center_x, center_y, outer_radius, colour, threshold, fill=True)[source]
Draw circle mask on NumPy array.
Apply algorithm for drawing anti-aliased circle. Draw points only when the alpha blending is above a set threshold. Only given _colour value is drawn. Intended usage is as a mask index.
Optionally, fill the circle with the same _colour.
- Parameters:
canvas – numpy array
center_x – center of circle in array coordinates (int)
center_y – center of circle in array coordinates (int)
outer_radius – radius of circle in array dimension (float)
colour – _colour to draw (mask index) (int)
threshold – only pixels with an alpha > threshold will be drawn (float, 0.0-1.0)
fill – whether to fill the circle (boolean)
- src.imagedata.apps.Siemens.draw_antialiased.draw_ellipse_mask(canvas, center_x, center_y, outer_radius, colour, threshold, fill=True)[source]
Draw ellipse mask on NumPy array.
Apply algorithm for drawing anti-aliased ellipse. Draw points only when the alpha blending is above a set threshold. Only given _colour value is drawn. Intended usage is as a mask index.
Optionally, fill the ellipse with the same _colour.
- Reference:
https://yellowsplash.wordpress.com/2009/10/23/fast-antialiased-circles-and-ellipses-from-xiaolin-wus-concepts/ https://stackoverflow.com/questions/37589165/drawing-an-antialiased-circle-as-described-by-xaolin-wu#37714284
- Parameters:
canvas – numpy array
center_x – center of ellipse in array coordinates (int)
center_y – center of ellipse in array coordinates (int)
outer_radius – radius of circle in array dimension (float)
colour – colour to draw (mask index) (int)
threshold – only pixels with an alpha > threshold will be drawn (float, 0.0-1.0)
fill – whether to fill the circle (boolean)
- src.imagedata.apps.Siemens.draw_antialiased.draw_line_mask(canvas, x1, y1, x2, y2, colour, threshold)[source]
Draw line mask on NumPy array.
Apply the Xialon Wu anti-aliasing algorithm for drawing line. Draw points only when the alpha blending is above a set threshold. Only given colour value is drawn. Intended usage is as a mask index.
- Parameters:
canvas – 2D numpy array (np.ndarray)
x1 (float) – line end points
y1 (float) – line end points
x2 (float) – line end points
y2 (float) – line end points
colour (int) – colour to draw ‘mask index’
threshold (float) – only pixels with an alpha > threshold will be drawn, 0.0-1.0
- src.imagedata.apps.Siemens.draw_antialiased.draw_polygon_mask(canvas, points, colour, threshold, fill=True)[source]
Make a 2D mask [ny,nx] on canvas
Optionally, fill the polygon with the same colour.
- Parameters:
canvas – numpy array
points – polygon points (list of tuples (x,y)) (float)
colour – colour to draw (mask index) (int)
threshold – only pixels with an alpha > threshold will be drawn (float, 0.0-1.0)
fill – whether to fill the circle (boolean)
- src.imagedata.apps.Siemens.draw_antialiased.flood_fill4(canvas, start_x, start_y, old_value, fill_value)[source]
src.imagedata.apps.Siemens.evidence2mask module
Read Siemens Syngo.VIA Basic Reading
- src.imagedata.apps.Siemens.evidence2mask.evidence2roi(im, uid_table=None, content=None)[source]
overrows = image[(0x6000, 0x0010)].value overcols = image[(0x6000, 0x0011)].value overkey=(0x6000, 0x3000) overlay=image[overkey].value
a=bitarray.bitarray(overlay, endian=’little’)
- while len(a) < len(overlay)*8:
a.append(0)
c = np.array(a.tolist()) c = c.astype(np.uint8) #c = c.reshape((overcols, overrows)) c = c.reshape((overrows, overcols))
- src.imagedata.apps.Siemens.evidence2mask.make_mask_in_slice(roi_type, si, points, shape)[source]
Make a 3D mask [nz,ny,nx]