scilpy.ml package
scilpy.ml.bundleparc.attention module
- scilpy.ml.bundleparc.attention.have_torch = True
The classes in this file are from the SAM-Med3D repository: https://github.com/uni-medical/SAM-Med3D
- scilpy.ml.bundleparc.attention.torch = <Mock id='128197956431184'>
The classes in this file are from the SAM-Med3D repository: https://github.com/uni-medical/SAM-Med3D
scilpy.ml.bundleparc.bundleparcnet module
scilpy.ml.bundleparc.encodings module
scilpy.ml.bundleparc.labels module
- scilpy.ml.bundleparc.labels.post_process_labels_continuous(bundle_label, bundle_mask, bundle_name)[source]
Don’t discretize the labels, just apply a mask to the bundle.
- Parameters:
bundle_label (np.ndarray) – Predicted continuous labels for the bundle.
bundle_mask (np.ndarray) – Binary mask of the bundle.
bundle_name (str) – Name of the bundle, used for logging.
- Returns:
bundle_label – Predicted labels for the bundle.
- Return type:
np.ndarray
- scilpy.ml.bundleparc.labels.post_process_labels_discrete(nb_labels, bundle_label, bundle_mask, bundle_name)[source]
Discretize the labels and apply a mask to the bundle. Labels are discretized to integers in the range [1, nb_labels] uniformly.
- Parameters:
nb_labels (int) – Number of labels to discretize to.
bundle_label (np.ndarray) – Predicted continuous labels for the bundle.
bundle_mask (np.ndarray) – Binary mask of the bundle.
bundle_name (str) – Name of the bundle, used for logging.
- Returns:
bundle_label – Predicted labels for the bundle.
- Return type:
np.ndarray
- scilpy.ml.bundleparc.labels.post_process_labels_mm(labels_mm, voxel_size, bundle_label, bundle_mask, bundle_name)[source]
Discretize the labels and apply a mask to the bundle. Labels are discritezed to integers so that each section is roughly labels_mm mm long To do so, the barycenter of each label is computed to form a centroid streamline. Then, the centroid is resampled to have a number of points such that the step-size is roughly labels_mm mm. Finally, the labels are reassigned to the closest point in the resampled centroid.
- Parameters:
labels_mm (float) – Length of each section in mm.
voxel_size (np.ndarray) – Voxel size of the bundle image.
bundle_label (np.ndarray) – Predicted continuous labels for the bundle.
bundle_mask (np.ndarray) – Binary mask of the bundle.
bundle_name (str) – Name of the bundle, used for logging.
- Returns:
bundle_label – Predicted labels for the bundle.
- Return type:
np.ndarray
scilpy.ml.bundleparc.predict module
- scilpy.ml.bundleparc.predict.post_process_mask(mask, bundle_name, min_blob_size=100, keep_biggest_blob=False)[source]
Post-process the mask. This function binarizes the mask. In a future release, it will also remove small blobs and fill holes (this is why the bundle name is passed).
- Parameters:
mask (np.ndarray) – Predicted mask for the bundle.
bundle_name (str) – Name of the bundle.
scilpy.ml.bundleparc.utils module
- scilpy.ml.bundleparc.utils.download_weights(path, chunk_size=1024, verbose=True)[source]
Download the weights for BundleParcNet.
- Parameters:
path (str) – Path to the file where the weights will be saved.
chunk_size (int, optional) – Size of the chunks to download the file.
- scilpy.ml.bundleparc.utils.get_data(fodf, n_coefs)[source]
Get the data from the input files and prepare it for the model. This function truncates or pad the number of coefficients to fit the model’s input and z-score normalizes the fODF data.
- Parameters:
fodf (numpy.ndarray) – fODF data.
n_coefs (int) – Number of SH coefficients to use.
- Returns:
fodf_data – fODF data.
- Return type:
np.ndarray