BioExp.helpers package¶
Submodules¶
BioExp.helpers.get_gram_matrix module¶
BioExp.helpers.losses module¶
-
BioExp.helpers.losses.
gen_dice_loss
(y_true, y_pred)[source]¶ computes the sum of two losses : generalised dice loss and weighted cross entropy
-
BioExp.helpers.losses.
soft_dice_loss
(y_true, y_pred)[source]¶ Soft dice loss calculation for arbitrary batch size, number of classes, and number of spatial dimensions. Assumes the channels_last format.
- # Arguments
- y_true: b x X x Y( x Z…) x c One hot encoding of ground truth y_pred: b x X x Y( x Z…) x c Network output, must sum to 1 over c channel (such as after softmax) epsilon: Used for numerical stability to avoid divide by zero errors
- # References
V-Net: Fully Convolutional Neural Networks for Volumetric Medical Image Segmentation https://arxiv.org/abs/1606.04797 More details on Dice loss formulation https://mediatum.ub.tum.de/doc/1395260/1395260.pdf (page 72)
Adapted from https://github.com/Lasagne/Recipes/issues/99#issuecomment-347775022
BioExp.helpers.metrics module¶
BioExp.helpers.models module¶
-
BioExp.helpers.models.
categorical_focal_loss
(y_true, y_pred)[source]¶ Parameters: - y_true – A tensor of the same shape as y_pred
- y_pred – A tensor resulting from a softmax
Returns: Output tensor.
-
BioExp.helpers.models.
conv_block
(prev, num_filters, kernel=(3, 3), strides=(1, 1), act='relu', prefix=None)[source]¶
-
BioExp.helpers.models.
dense_block
(x, blocks, name)[source]¶ A dense block. # Arguments
x: input tensor. blocks: integer, the number of building blocks. name: string, block label.- # Returns
- output tensor for the block.
-
BioExp.helpers.models.
dense_conv_block
(x, growth_rate, name)[source]¶ A building block for a dense block. # Arguments
x: input tensor. growth_rate: float, growth rate at dense layers. name: string, block label.- # Returns
- Output tensor for the block.
BioExp.helpers.pb_file_generation module¶
-
BioExp.helpers.pb_file_generation.
generate_pb
(model_path, layer_name, pb_path, wts_path)[source]¶ freezes model weights and convert entire graph into .pb file
model_path: saved model path (model architecture) (str) layer_name: name of output layer (str) pb_path : path to save pb file wts_path : saved model weights
BioExp.helpers.radfeatures module¶
BioExp.helpers.transform module¶
BioExp.helpers.utils module¶
-
BioExp.helpers.utils.
apply_modifications_custom
(model, custom_objects=None)[source]¶ Applies modifications to the model layers to create a new Graph. For example, simply changing model.layers[idx].activation = new activation does not change the graph. The entire graph needs to be updated with modified inbound and outbound tensors because of change in layer building function. :param model: The keras.models.Model instance.
Returns: The modified model with changes applied. Does not mutate the original model.
-
BioExp.helpers.utils.
load_file
(rgbpath, maskpath=None)[source]¶ loads rgb image
rgbpath: rgb image path maskpath: segmentation path if exists
-
BioExp.helpers.utils.
load_vol
(t1path, t2path, t1cepath, flairpath, segpath=None, slicen=-1, pad=None)[source]¶ loads volume if exists
rootpath : patient data root path slicen : sice which needs to ne loaded pad : number of pixels to be padded
in X, Y direction
-
BioExp.helpers.utils.
load_vol_brats
(rootpath, slicen=-1, pad=None)[source]¶ loads volume if exists
rootpath : patient data root path slicen : sice which needs to ne loaded pad : number of pixels to be padded
in X, Y direction