HypVINN.run_prediction¶
- HypVINN.run_prediction.get_prediction(subject_name, modalities, orig_zoom, model, target_shape, view_opts, out_scale=None, mode='t1t2')[source]¶
Run the prediction for the Hypothalamus Segmentation model.
This function sets up the prediction process for the Hypothalamus Segmentation model. It runs the model for each plane (axial, coronal, sagittal), accumulates the prediction probabilities, and then generates the final prediction.
- Parameters:
- subject_name
str
The name of the subject.
- modalities
ModalityDict
A dictionary containing the modalities (T1 and/or T2) and their corresponding images.
- orig_zoom
npt.NDArray
[float
] The original zoom of the subject.
- model
Inference
The Inference object of the model.
- target_shape
tuple
[int
,int
,int
] The target shape of the output prediction.
- view_opts
ViewOperations
A dictionary containing the configurations for each plane.
- out_scale
optional
The output scale. Default is None.
- mode
ModalityMode
, default=”t1t2” The mode of operation. Can be ‘t1’, ‘t2’, or ‘t1t2’. Default is ‘t1t2’.
- subject_name
- Returns:
- pred_classes:
npt.NDArray
[int
] The final prediction of the model.
- pred_classes:
- HypVINN.run_prediction.load_volumes(mode, t1_path=None, t2_path=None)[source]¶
Load the volumes of T1 and T2 images.
This function loads the T1 and T2 images, checks their compatibility based on the mode, and returns the loaded volumes along with their affine transformations, headers, zoom levels, and sizes.
- Parameters:
- Returns:
tuple
A tuple containing the following elements: - modalities: A dictionary with keys ‘t1’ and/or ‘t2’ and values being the corresponding loaded and rescaled images. - affine: The affine transformation of the loaded image(s). - header: The header of the loaded image(s). - zoom: The zoom level of the loaded image(s). - size: The size of the loaded image(s).
- Raises:
RuntimeError
If the mode is inconsistent with the provided image paths, or if the number of dimensions of the data is invalid.
ValueError
If the mode is invalid, or if a header is missing.
AssertionError
If the mode is ‘t1t2’ but the T1 and T2 images have different resolutions or sizes.
- HypVINN.run_prediction.option_parse()[source]¶
A function to create an ArgumentParser object and parse the command line arguments.
- Returns:
argparse.ArgumentParser
The parser object to parse arguments from the command line.
- HypVINN.run_prediction.prepare_checkpoints(ckpt_ax, ckpt_cor, ckpt_sag)[source]¶
Prepare the checkpoints for the Hypothalamus Segmentation model.
This function checks if the checkpoint files for the axial, coronal, and sagittal planes exist. If they do not exist, it downloads them from the default URLs specified in the configuration file.
- HypVINN.run_prediction.set_up_cfgs(cfg, out_dir, batch_size=1)[source]¶
Set up the configuration for the Hypothalamus Segmentation model.
This function loads the configuration, sets the output directory and batch size, and adjusts the output tensor dimensions based on the padded size specified in the configuration.