forked from Project-MONAI/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.yaml
57 lines (48 loc) · 1.48 KB
/
example.yaml
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
---
imports:
- $import glob
- $import matplotlib.pyplot as plt
# download and extract dataset (60MB):
url: "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/MedNIST.tar.gz"
downloading: "$monai.apps.utils.download_and_extract(@url, './mednist.tar.gz')"
# construct the input paired data (moving and fixed images)
dataset_dir: "MedNIST/Hand"
datalist: $list(sorted(glob.glob(@dataset_dir + '/*.jpeg')))
paired_dataset: "$[{'f_img': item, 'm_img': item} for item in @datalist]"
# define preprocessing (additional randomization on the moving image)
preprocessing:
_target_: Compose
transforms:
- _target_: LoadImaged
keys: [f_img, m_img]
image_only: True
- _target_: EnsureChannelFirstd
keys: [f_img, m_img]
- _target_: ScaleIntensityRanged
keys: [f_img, m_img]
a_min: 0.
a_max: 255.
b_min: 0.0
b_max: 1.0
- _target_: RandRotated
keys: [m_img]
range_x: $np.pi/4
prob: 1.0
mode: "bicubic"
keep_size: True
- _target_: RandZoomd
keys: [m_img]
min_zoom: 0.9
max_zoom: 1.1
prob: 1.0
mode: "bicubic"
# display the first pair of moving and fixed images
first_pair: $@preprocessing(@paired_dataset[0])
display:
- _requires_: "@downloading"
- $print("displaying images:")
- $plt.subplot(1,2,1)
- $plt.imshow(@first_pair['f_img'][0], cmap="gray")
- $plt.subplot(1,2,2)
- $plt.imshow(@first_pair['m_img'][0], cmap="gray")
- $plt.show()