Nnunet
nnunet
#
Functions:
Name | Description |
---|---|
generate_dataset_json |
Generates a dataset.json file in the output folder |
generate_nnunet_scripts |
Creates two bash scripts: |
generate_dataset_json
#
generate_dataset_json(
output_folder: pathlib.Path | str,
channel_names: typing.Dict[str, str],
labels: typing.Dict[str, int | list[int]],
num_training_cases: int,
file_ending: str,
regions_class_order: (
typing.Tuple[int, ...] | None
) = None,
dataset_name: str | None = None,
reference: str | None = None,
release: str | None = None,
usage_license: str = "hands off!",
description: str | None = None,
overwrite_image_reader_writer: str | None = None,
**kwargs: object
) -> None
Generates a dataset.json file in the output folder
Code from: https://github.com/MIC-DKFZ/nnUNet/blob/master/nnunetv2/dataset_conversion/generate_dataset_json.py
channel_names: Channel names must map the index to the name of the channel, example: { 0: 'T1', 1: 'CT' } Note that the channel names may influence the normalization scheme!! Learn more in the documentation.
labels: This will tell nnU-Net what labels to expect. Important: This will also determine whether you use region-based training or not. Example regular labels: { 'background': 0, 'left atrium': 1, 'some other label': 2 } Example region-based training: { 'background': 0, 'whole tumor': (1, 2, 3), 'tumor core': (2, 3), 'enhancing tumor': 3 }
Remember that nnU-Net expects consecutive values for labels! nnU-Net also expects 0 to be background!
num_training_cases: is used to double check all cases are there!
file_ending: needed for finding the files correctly. IMPORTANT! File endings must match between images and segmentations!
dataset_name, reference, release, license, description: self-explanatory and not used by nnU-Net. Just for completeness and as a reminder that these would be great!
overwrite_image_reader_writer: If you need a special IO class for your dataset you can derive it from BaseReaderWriter, place it into nnunet.imageio and reference it here by name
kwargs: whatever you put here will be placed in the dataset.json as well
Source code in src/imgtools/utils/nnunet.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
generate_nnunet_scripts
#
Creates two bash scripts:
1. nnunet_preprocess.sh
for running nnUNet preprocessing.
2. nnunet_train.sh
for running nnUNet training.
Parameters: - output_directory (str): The directory where the output and subdirectories are located. - dataset_id (int): The ID of the dataset to be processed.