dosma.models package¶
Submodules¶
dosma.models.oaiunet2d module¶
- @author: Arjun Desai
Stanford University, 2019
-
class
dosma.models.oaiunet2d.IWOAIOAIUnet2D(input_shape, weights_path, force_weights=False)[source]¶ Bases:
dosma.models.oaiunet2d.OAIUnet2DModel trained by Team 6 in the 2019 IWOAI Segmentation Challenge.
References
Desai, et al., “The International Workshop on Osteoarthritis Imaging Knee MRI Segmentation Challenge: A Multi-Institute Evaluation and Analysis Framework on a Standardized Dataset.” arXiv preprint arXiv:2004.14003 (2020). [link]
-
ALIASES= ['iwoai-2019-t6']¶
-
generate_mask(volume: dosma.data_io.med_volume.MedicalVolume)[source]¶ Segment the MRI volumes.
- Parameters
volume (MedicalVolume) – Volume to segment in proper orientation.
- Returns
- Volumes are binarized (0,1)
uint8 3D ndarray of shape
volume.shape.
- Return type
MedicalVolumeor List[MedicalVolume]- Raises
ValueError – If volumes is not 3D ndarray or if tissue is not a string or not in list permitted tissues.
-
-
class
dosma.models.oaiunet2d.IWOAIOAIUnet2DNormalized(input_shape, weights_path, force_weights=False)[source]¶ Bases:
dosma.models.oaiunet2d.IWOAIOAIUnet2DExtension of model trained by Team 6 in the 2019 IWOAI Segmentation Challenge (with normalization).
This model uses the same architecture as
IWOAIOAIUnet2D, but pre-processes the input data by zero-mean, unit-std normalization.References
Desai, et al., “The International Workshop on Osteoarthritis Imaging Knee MRI Segmentation Challenge: A Multi-Institute Evaluation and Analysis Framework on a Standardized Dataset.” arXiv preprint arXiv:2004.14003 (2020).
-
ALIASES= ('iwoai-2019-t6-normalized',)¶
-
-
class
dosma.models.oaiunet2d.OAIUnet2D(input_shape, weights_path, force_weights=False)[source]¶ Bases:
dosma.models.seg_model.KerasSegModelModel trained in Chaudhari et al. IWOAI 2018
Original Github: https://github.com/akshaysc/msk_segmentation
-
ALIASES= ['oai-unet2d', 'oai_unet2d']¶
-
generate_mask(volume: dosma.data_io.med_volume.MedicalVolume)[source]¶ Segment the MRI volumes.
- Parameters
volume (MedicalVolume) – Volume to segment in proper orientation.
- Returns
- Volumes are binarized (0,1)
uint8 3D ndarray of shape
volume.shape.
- Return type
MedicalVolumeor List[MedicalVolume]- Raises
ValueError – If volumes is not 3D ndarray or if tissue is not a string or not in list permitted tissues.
-
sigmoid_threshold= 0.5¶
-
dosma.models.seg_model module¶
Abstract classes to wrap Keras model.
T SegModel: Abstract wrapper for Keras model used for semantic segmentation.
-
class
dosma.models.seg_model.KerasSegModel(input_shape, weights_path, force_weights=False)[source]¶ Bases:
dosma.models.seg_model.SegModelAbstract wrapper for Keras model used for semantic segmentation
-
class
dosma.models.seg_model.SegModel(input_shape, weights_path, force_weights=False)[source]¶ Bases:
abc.ABC- Parameters
input_shape (Tuple[int] or List[Tuple[int]]) – Shapes(s) for initializing input(s) into model in format (height, width, channels).
weights_path (str) – filepath to weights used to initialize Keras model
force_weights (bool, optional) – If True, load weights without any checking. Keras/Tensorflow only.
-
ALIASES= ['']¶
-
abstract
build_model(input_shape, weights_path)[source]¶ Builds a segmentation model architecture and loads weights.
- Parameters
input_shape – Input shape of volume
weights_path –
- Returns
a segmentation model that can be used for segmenting tissues (a Keras/TF/PyTorch model)
-
abstract
generate_mask(volume: dosma.data_io.med_volume.MedicalVolume)[source]¶ Segment the MRI volumes.
- Parameters
volume (MedicalVolume) – Volume to segment in proper orientation.
- Returns
- Volumes are binarized (0,1)
uint8 3D ndarray of shape
volume.shape.
- Return type
MedicalVolumeor List[MedicalVolume]- Raises
ValueError – If volumes is not 3D ndarray or if tissue is not a string or not in list permitted tissues.
-
dosma.models.seg_model.whiten_volume(x: numpy.ndarray, eps: float = 0.0)[source]¶ Whiten volumes by mean and std of all pixels.
- Parameters
x (ndarray) – 3D numpy array (MRI volumes)
eps (float, optional) – Epsilon to avoid division by 0.
- Returns
A numpy array with mean ~ 0 and standard deviation ~ 1
- Return type
ndarray
dosma.models.util module¶
Functions for loading Keras models
- @author: Arjun Desai
Stanford University, 2019
-
dosma.models.util.get_model(model_str, input_shape, weights_path, **kwargs)[source]¶ Get a Keras model :param model_str: model identifier :param input_shape: tuple or list of tuples for initializing input(s) into Keras model :param weights_path: filepath to weights used to initialize Keras model :return: a Keras model
Module contents¶
-
class
dosma.models.IWOAIOAIUnet2D(input_shape, weights_path, force_weights=False)[source]¶ Bases:
dosma.models.oaiunet2d.OAIUnet2DModel trained by Team 6 in the 2019 IWOAI Segmentation Challenge.
References
Desai, et al., “The International Workshop on Osteoarthritis Imaging Knee MRI Segmentation Challenge: A Multi-Institute Evaluation and Analysis Framework on a Standardized Dataset.” arXiv preprint arXiv:2004.14003 (2020). [link]
-
ALIASES= ['iwoai-2019-t6']¶
-
generate_mask(volume: dosma.data_io.med_volume.MedicalVolume)[source]¶ Segment the MRI volumes.
- Parameters
volume (MedicalVolume) – Volume to segment in proper orientation.
- Returns
- Volumes are binarized (0,1)
uint8 3D ndarray of shape
volume.shape.
- Return type
MedicalVolumeor List[MedicalVolume]- Raises
ValueError – If volumes is not 3D ndarray or if tissue is not a string or not in list permitted tissues.
-
-
class
dosma.models.IWOAIOAIUnet2DNormalized(input_shape, weights_path, force_weights=False)[source]¶ Bases:
dosma.models.oaiunet2d.IWOAIOAIUnet2DExtension of model trained by Team 6 in the 2019 IWOAI Segmentation Challenge (with normalization).
This model uses the same architecture as
IWOAIOAIUnet2D, but pre-processes the input data by zero-mean, unit-std normalization.References
Desai, et al., “The International Workshop on Osteoarthritis Imaging Knee MRI Segmentation Challenge: A Multi-Institute Evaluation and Analysis Framework on a Standardized Dataset.” arXiv preprint arXiv:2004.14003 (2020).
-
ALIASES= ('iwoai-2019-t6-normalized',)¶
-
-
class
dosma.models.OAIUnet2D(input_shape, weights_path, force_weights=False)[source]¶ Bases:
dosma.models.seg_model.KerasSegModelModel trained in Chaudhari et al. IWOAI 2018
Original Github: https://github.com/akshaysc/msk_segmentation
-
ALIASES= ['oai-unet2d', 'oai_unet2d']¶
-
generate_mask(volume: dosma.data_io.med_volume.MedicalVolume)[source]¶ Segment the MRI volumes.
- Parameters
volume (MedicalVolume) – Volume to segment in proper orientation.
- Returns
- Volumes are binarized (0,1)
uint8 3D ndarray of shape
volume.shape.
- Return type
MedicalVolumeor List[MedicalVolume]- Raises
ValueError – If volumes is not 3D ndarray or if tissue is not a string or not in list permitted tissues.
-
sigmoid_threshold= 0.5¶
-
-
dosma.models.get_model(model_str, input_shape, weights_path, **kwargs)[source]¶ Get a Keras model :param model_str: model identifier :param input_shape: tuple or list of tuples for initializing input(s) into Keras model :param weights_path: filepath to weights used to initialize Keras model :return: a Keras model