File size: 4,204 Bytes
ecf08bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Setting up Paths

nnU-Net relies on environment variables to know where raw data, preprocessed data and trained model weights are stored. 
To use the full functionality of nnU-Net, the following three environment variables must be set:

1) nnUNet_raw_data_base: This is where nnU-Net finds the raw data and stored the cropped data. The folder located at 
nnUNet_raw_data_base must have at least the subfolder nnUNet_raw_data, which in turn contains one subfolder for each Task. 
It is the responsibility of the user to bring the raw data into the appropriate format - nnU-Net will then take care of 
the rest ;-) For more information on the required raw data format, see [here](dataset_conversion.md).

    Example tree structure:
    ```
    nnUNet_raw_data_base/nnUNet_raw_data/Task002_Heart
    β”œβ”€β”€ dataset.json
    β”œβ”€β”€ imagesTr
    β”‚Β Β  β”œβ”€β”€ la_003_0000.nii.gz
    β”‚Β Β  β”œβ”€β”€ la_004_0000.nii.gz
    β”‚Β Β  β”œβ”€β”€ ...
    β”œβ”€β”€ imagesTs
    β”‚Β Β  β”œβ”€β”€ la_001_0000.nii.gz
    β”‚Β Β  β”œβ”€β”€ la_002_0000.nii.gz
    β”‚Β Β  β”œβ”€β”€ ...
    └── labelsTr
        β”œβ”€β”€ la_003.nii.gz
        β”œβ”€β”€ la_004.nii.gz
        β”œβ”€β”€ ...
    nnUNet_raw_data_base/nnUNet_raw_data/Task005_Prostate/
    β”œβ”€β”€ dataset.json
    β”œβ”€β”€ imagesTr
    β”‚Β Β  β”œβ”€β”€ prostate_00_0000.nii.gz
    β”‚Β Β  β”œβ”€β”€ prostate_00_0001.nii.gz
    β”‚Β Β  β”œβ”€β”€ ...
    β”œβ”€β”€ imagesTs
    β”‚Β Β  β”œβ”€β”€ prostate_03_0000.nii.gz
    β”‚Β Β  β”œβ”€β”€ prostate_03_0001.nii.gz
    β”‚Β Β  β”œβ”€β”€ ...
    └── labelsTr
        β”œβ”€β”€ prostate_00.nii.gz
        β”œβ”€β”€ prostate_01.nii.gz
        β”œβ”€β”€ ...
    ```

2) nnUNet_preprocessed: This is the folder where the preprocessed data will be saved. The data will also be read from 
this folder during training. Therefore it is important that it is located on a drive with low access latency and high 
throughput (a regular sata or nvme SSD is sufficient).

3) RESULTS_FOLDER: This specifies where nnU-Net will save the model weights. If pretrained models are downloaded, this 
is where it will save them.

### How to set environment variables
(nnU-Net was developed for Ubuntu/Linux. The following guide is intended for this operating system and will not work on 
others. We do not provide support for other operating systems!)

There are several ways you can do this. The most common one is to set the paths in your .bashrc file, which is located 
in your home directory. For me, this file is located at /home/fabian/.bashrc. You can open it with any text editor of 
choice. If you do not see the file, that may be because it is hidden by default. You can run `ls -al /home/fabian` to 
ensure that you see it. In rare cases it may not be present and you can simply create it with `touch /home/fabian/.bashrc`.

Once the file is open in a text editor, add the following lines to the bottom:
```
export nnUNet_raw_data_base="/media/fabian/nnUNet_raw"
export nnUNet_preprocessed="/media/fabian/nnUNet_preprocessed"
export RESULTS_FOLDER="/media/fabian/nnUNet_trained_models"
```

(of course adapt the paths to your system and remember that nnUNet_preprocessed should be located on an SSD!)

Then save and exit. To be save, make sure to reload the .bashrc by running `source /home/fabian/.bashrc`. Reloading 
needs only be done on terminal sessions that were already open before you saved the changes. Any new terminal you open 
after will have these paths set. You can verify that the paths are set up properly by typing `echo $RESULTS_FOLDER` 
etc and it should print out the correct folder.

### An alternative way of setting these paths
The method above sets the paths permanently (until you delete the lines from your .bashrc) on your system. If you wish 
to set them only temporarily, you can run the export commands in your terminal:

```
export nnUNet_raw_data_base="/media/fabian/nnUNet_raw"
export nnUNet_preprocessed="/media/fabian/nnUNet_preprocessed"
export RESULTS_FOLDER="/media/fabian/nnUNet_trained_models"
```

This will set the paths for the current terminal session only (the variables will be lost if you close the terminal 
and need to be reset every time).