Unpack methods for network’s target creation¶
CTImagesMaskedBatch.
unpack
(component='images', **kwargs)[source]Basic way for unpacking components from batch.
Parameters:
- component (str) – component to unpack, can be ‘images’ or ‘masks’.
- data_format (str) – can be ‘channels_last’ or ‘channels_first’. Reflects where to put channels dimension: right after batch dimension or after all spatial axes.
- kwargs (dict) – key-word arguments that will be passed in callable if component argument reffers to method of batch class.
Returns: Return type: ndarray(batch_size, ..) or None
- static
CTImagesMaskedBatch.
make_data_tf
(batch, model=None, mode='segmentation', is_training=True, **kwargs)[source]Prepare data in batch for training neural network implemented in tensorflow.
Parameters:
- mode (str) – mode can be one of following ‘classification’, ‘regression’ or ‘segmentation’. Default is ‘segmentation’.
- data_format (str) – data format batch data. Can be ‘channels_last’ or ‘channels_first’. Default is ‘channels_last’.
- is_training (bool) – whether model is in training or prediction mode. Default is True.
- threshold (int) – threshold value of ‘1’ pixels in masks to consider it cancerous. Default is 10.
Returns: feed dict and fetches for training neural network.
Return type:
- static
CTImagesMaskedBatch.
make_data_keras
(batch, model=None, mode='segmentation', is_training=True, **kwargs)[source]Prepare data in batch for training neural network implemented in keras.
Parameters:
- mode (str) – mode can be one of following ‘classification’, ‘regression’ or ‘segmentation’. Default is ‘segmentation’.
- data_format (str) – data format batch data. Can be ‘channels_last’ or ‘channels_first’. Default is ‘channels_last’.
- is_training (bool) – whether model is in training or prediction mode. Default is True.
- threshold (int) – threshold value of ‘1’ pixels in masks to consider it cancerous. Default is 10.
Returns: kwargs for keras model train method: {‘x’: ndarray(…), ‘y’: ndarrray(…)} for training neural network.
Return type:
CTImagesMaskedBatch.
classification_targets
(threshold=10, **kwargs)[source]Unpack data from batch in format suitable for classification task.
Parameters: threshold (int) – minimum number of ‘1’ pixels in mask to consider it cancerous. Returns: targets for classification task: labels corresponding to cancerous nodules (‘1’) and non-cancerous nodules (‘0’). Return type: ndarray(batch_size, 1)
CTImagesMaskedBatch.
regression_targets
(threshold=10, **kwargs)[source]Unpack data from batch in format suitable for regression task.
Parameters: threshold (int) – minimum number of ‘1’ pixels in mask to consider it cancerous. Returns: targets for regression task: cancer center, size and label(1 for cancerous and 0 for non-cancerous). Note that in case of non-cancerous crop first 6 column of output array will be set to zero. Return type: ndarray(batch_size, 7)
CTImagesMaskedBatch.
segmentation_targets
(data_format='channels_last', **kwargs)[source]Unpack data from batch in format suitable for regression task.
Parameters: data_format (str) – data_format shows where to put new axis for channels dimension: can be ‘channels_last’ or ‘channels_first’. Returns: batch array with masks. Return type: ndarray(batch_size, ..)