Module functions
Functions have been documented using sphinx.ext.autodoc and the docstring
style extension ‘sphinx.ext.napoleon’:
Module contours
- Modules.contours.al_ratio(contour_length, contour_area)
Determines ratio of contour length and area
- Parameters
contour_length (ndarray) – 1 dimensional array with type float that contains length of contours
contour_area (ndarray) – 1 dimensional array with type float that contains area of contours
- Returns
ratio – 1 dimensional array with type float that contains ratio of contour length to area
- Return type
ndarray
- Modules.contours.draw_cont(img, contour, name, directory)
Draws contours and returns image
- Parameters
- Returns
new_img – N x N dimensional array that contains the selected contours
- Return type
ndarray
- Modules.contours.filter_cont(contour, index)
Selects contours by index
- Parameters
contour (contours) – Contours that contains list of coordinates of detected contours
index (ndarray) – 1 dimensional array with type int that contains index of selected contours
- Returns
cnt – N x 2 dimensional array with type contours that contains selected contours
- Return type
ndarray
- Modules.contours.filter_df(ind, c_length, c_area, c_ratio)
Writes new DataFrame with selected data
- Parameters
ind (ndarray) – 1 dimensional array with type int that contains the index of data selected from other DataFrame
c_length (ndarray) – 1 dimensional array with type float that contains the length of selected contours
c_area (ndarray) – 1 dimensional array with type float that contains the area of selected contour
c_ratio (ndarray) – 1 dimensional array with type float that contains the ratio of contour length and area
- Returns
df (DataFrame) – DataFrame that contains properties of selected contours
length (ndarray) – 1 dimensional array with type float that contains the length of each selected contour
area (ndarray) – 1 dimensional array with type float that contains the area of each selected contour
ratio (ndarray) – 1 dimensional array with type float that contains the length/area ratio of each selected contour
- Modules.contours.filter_values(df, column, min_val, max_val)
Filters column in DataFrame by values
- Parameters
- Returns
ind – 1 dimensional array with type int that describes values, which fulfill conditions
- Return type
ndarray
- Modules.contours.find_cont(img)
Detects contours and draws them in RGB image
- Parameters
img (ndarray) – N x N dimensional array with type int that contains the image to process
- Returns
canvas (ndarray) – N x N dimensional array that contains the detected contours
contour (contours) – List of coordinates of contours that were detected in the image
- Modules.contours.find_contour_img(img, img_thr, directory)
Finds contours, filters them by manually chosen values and returns filtered contours
- Parameters
img (ndarray) – N x N dimensional array with type int that contains the original image
img_thr (ndarray) – N x N dimensional array with type int that contains the thresholded image
directory (str) – The directory where the image is saved
- Returns
c_a – N x N x 2 array with type contours that contains selected contours
- Return type
ndarray
- Modules.contours.find_extrema(img)
Finds index of max and min value in image
- Parameters
img (image) – N dimensional array with type float that contains the z_values of the data
- Returns
z_min (int) – Minimum value in array
z_max (int) – Maximum value in array
- Modules.contours.get_contarea(contour)
Determines area that is surrounded by contour and its length
- Parameters
contour (contours) – Contours that contains list of coordinates of detected contours
- Returns
length (ndarray) – 1 dimensional array with type float that contains length of contours
area (ndarray) – 1 dimensional array with type float that contains area of contours
- Modules.contours.normalise_zvalues(img)
Returns normalised grayscale image
- Parameters
img (image) – N dimensional array with type float that contains the z_values of the data
- Returns
imggr – N x N dimensional array with type int that contains grayscale values of the image
- Return type
ndarray
- Modules.contours.RGB_2_bin(img, value)
Converts RGB image to grayscale image
- Parameters
img (image) –
value (int) – The value, which determines if the point is True or False
- Returns
img_new – N x N dimensional array that contains a binary image
- Return type
ndarray
- Modules.contours.write_df(c_length, c_area, ratio)
Writes data in pandas data frame
- Parameters
c_length (ndarray) – 1 dimensional array with type float that contains list of contour lengths
c_area (ndarray) – 1 dimensional array with type float that contains list of contour areas
ratio (ndarray) – 1 dimensional array with type float that contains ratio of contour length to area
- Returns
df – DataFrame that contains contour length, area and ratio length/area
- Return type
DataFrame
Module extractCuts
- Modules.extractCuts.calc_asymcut(values, coord, ori, imgh, imgrh, imgw, imgrw, centre)
Determines the cross-section along the most asymmetric cut through the z_values and shifts the origin to the geometric centre
- Parameters
values (ndarray) – N dimensional array with type float that contains the grayscale values of the original image
coord (ndarray) – 1 dimensional array with type (float, float), (float, float) that contains the x- and y-coordinate left of a point and the x- and y-coordinate right of a point
ori (str) – Orientation of the straight: parallel, perpendicular
imgh (int) – The height of the image
imgrh (int) – The resolution of the image in y-direction
imgw (int) – The width of the image
imgrw (int) – The resolution of the imag in x-direction
centre (ndarray) – N dimensional array with type float, float that contains the x- and y-coordinates of the geometric centre
- Returns
cxpara (ndarray) – 1 dimensional array with type float that contains the x-coordinates of the asymmetric cut
cypara (ndarray) – 1 dimensional array with type float that contains the y-coordinates of the asymmetric cut
zpara (ndarray) – 1 dimensional array with type float that contains the z-coordinates of the asymmetric cut
cxperp (ndarray) – 1 dimensional array with type float that contains the x-coordinates of the perpendicular asymmetric cut
cyperp (ndarray) – 1 dimensional array with type float that contains the y-coordinates of the perpendicular asymmetric cut
ziperp (ndarray) – 1 dimensional array with type float that contains the z-coordinates of the perpendicular asymmetric cut
zipar (ndarray) – 1 dimensional array with type float that contains the z-coordinates of the asymmetric cut
cut (ndarray) – 1 dimensional array with type float that contains the points of the asymmetric cut in µm
pcut (ndarray) – 1 dimensional array with type float that contains the points of the perpendicular asymmetric cut in µm
x2cs (ndarray) – 2 dimensional array with type float that contains the x-coordinates of the asymmetric parallel and perpendicular cut
y2cs (ndarray) – 2 dimensional array with type float that contains the y-coordinates of the asymmetric parallel and perpendicular cut
z2cs (ndarray) – 2 dimensional array with type float that contains the z-coordinates of the asymmetric parallel and perpendicular cut
cut2 (ndarray) – 2 dimensional array with type float that contains the points of the parallel and perpendicular asymmetric cut in µm
- Modules.extractCuts.calc_straight(circle_found, mcentre, centre, imgh, imgrh, imgw, imrw)
Determines the straight betweeen the centre of mass and the geometric centre and the values of the points on the straight within a range of 50 pixels (much larger than cell diameter) around the geometric centre. Calculates the perpendicular straight and the values of the points on the straight.
- Parameters
circle_found (ndarray) – 1 dimensional array with type float, float, float that contains the x- and y-coordinate of the centre and the radius of the bounding circle
mcentre (ndarray) – N dimensional array with type float, float that contains the x- and y-coordinates of the centre of mass weighted by the corresponding z-values
centre (ndarray) – N dimensional array with type float, float that contains the x- and y-coordinates of the geometric centre
imgh (int) – The height of the image
imgrh (int) – The resolution of the image in y-direction
imgw (int) – The width of the image
imgrw (int) – The resolution of the imag in x-direction
- Returns
xrs (ndarray) – 1 dimensional array with type float that contains all x coordinates on the straight right of the geometric centre within a range of 50 pixels
yrs (ndarray) – 1 dimensional array with type float that contains all y coordinates on the straight right of the geometric centre within a range of 50 pixels
xls (ndarray) – 1 dimensional array with type float that contains all x coordinates on the straight left of the geometric centre within a range of 50 pixels
yls (ndarray) – 1 dimensional array with type float that contains all y coordinates on the straight left of the geometric centre within a range of 50 pixels
xprs (ndarray) – 1 dimensional array with type float that contains all x coordinates on the perpendicular straight right of the geometric centre within a range of 50 pixels
yprs (ndarray) – 1 dimensional array with type float that contains all y coordinates on the perpendicular straight right of the geometric centre within a range of 50 pixels
xpls (ndarray) – 1 dimensional array with type float that contains all x coordinates on the perpendicular straight left of the geometric centre within a range of 50 pixels
ypls (ndarray) – 1 dimensional array with type float that contains all y coordinates on the perpendicular straight left of the geometric centre within a range of 50 pixels
- Modules.extractCuts.centre_of_mass(all_coord, img)
Determines the centre of mass inside a rectangle weighted by the corresponding z-values
- Parameters
all_coord (ndarray) – 1 dimensional array with type float, float that contains all x- and y-coordinates inside a rectangle
img (ndarray) – N dimensional array with type float that contains the z_values of the data
- Returns
centre_mass – N x 2 array with type float, float that contains the x- and y-coordinates of the centre of mass weighted by the corresponding z-values
- Return type
ndarray
- Modules.extractCuts.find_coordborder(cnt_drawn, img)
Finds points inside cell contour and returns their coordinates
- Parameters
cnt_drawn (ndarray) – 1 dimensional array with type int, int, float, float that contains the index of a rectangle with corresponding contour, the y- and x-coordinate of the contour
img (ndarray) – N dimensional array with type float that contains the z_values of the data
- Returns
img_coord – N x 3 array with type float, float, float that contains the y-coordinate, the minimum and maximum x-coordinate of the points inside a contour
- Return type
ndarray
- Modules.extractCuts.geometric_centre(img_coord)
Determines the geometric centre of a contour (cell)
- Parameters
img_coord (ndarray) – 1 dimensional array with type float, float, float that contains the y-coordinate, the minimum and maximum x-coordinate
- Returns
centre (ndarray) – N x 2 array with type float, float that contains the x- and y-coordinate of the centre of a rectangle
all_coord (ndarray) – N x N x 2 array with type float, float that contains all x- and y-coordinates inside a rectangle
- Modules.extractCuts.match_coord(x_straight, y_straight, cntCell)
Finds contour points on the straight and sorts the coordinates by distance of the point from the geometric centre
- Parameters
x_straight (ndarray) – 1 dimensional array with type float that contains all x coordinates on the straight within a range of 50 pixels
y_straight (ndarray) – 1 dimensional array with type float that contains all x coordinates on the straight within a range of 50 pixels
cnt_drawn (ndarray) – 1 dimensional array with type int, int, float, float that contains the index of a rectangle with corresponding contour, the y- and x-coordinate of the contour
- Returns
match_coord (ndarray) – N x 3 array with type float, float, float that contains the x-coordinate, the y-coordinate and the distance of the point from the geometric centre
sort_coord (ndarray) – N x 2 array with type float, float that contains the x- and y-coordinate of a point
- Modules.extractCuts.points_incell(img_coord, img)
Determines the z-value of all points inside a contour
- Parameters
img_coord (ndarray) – 1 dimensional array with type float, float, float that contains the y-coordinate, the minimum and maximum x-coordinate of the points inside a contour
img (ndarray) – N dimensional array with type float that contains the z_values of the data
- Returns
points_inside – N x N dimensional array with type float that contains all z-values inside a contour
- Return type
ndarray
- Modules.extractCuts.sort_coord(coord_rmatch, coord_lmatch)
Sorts the matching coordinates by distance between left point and right point
- Parameters
coord_rmatch (ndarray) – 2 dimensional array with type float, float that contains the x-coordinate and the y-coordinate right of the centre
coord_lmatch (ndarray) – 2 dimensional array with type float, float that contains the x-coordinate and the y-coordinate left of the centre
- Returns
coord_sort – N x 2 dimensional array with type float, float that contains the x- and y-coordinates of the points intersecting with the straight of highest asymmetry left and right of the centre of the object
- Return type
ndarray
Module NN
- Modules.NN.format_values(name, spath)
Formats values and writes them into array
- Modules.NN.format_NN_values(name, spath)
Formats values for NN input and writes them into array
- Modules.NN.read_images(path)
Reads text files of characteristic cuts and labels them according to their category
- Parameters
path (str) – The name of the folder that contains the characteristic cuts
- Returns
carr_form (ndarray) – N x (N x N) dimensional array with type float that contains N times two characteristic cross-sections with 50 data points
label_form (ndarray) – 1 dimensional array with type int that contains the labels of N cells
- Modules.NN.train_model(model, carr_form, label_form, cut_train, label_train, directory, mname, tlabel)
Trains NN model on a combination of old and new data
- Parameters
model (Sequential) – The pre-trained neural network
carr_form (ndarray) – N x 2 x 50 array with type float that contains N times two characteristic cross-sections with 50 data points
label_form (ndarray) – N x 1 array with type int that contains the labels of N cells
directory (str) – The name of the network folder
mname (str) – The name of the new network
tlabel (tkinter Label) – Displays the progres of the calculation
- Returns
model – Sequential class that contains the trained new keras model
- Return type
tf.keras.Sequential