-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
61 lines (57 loc) · 2.73 KB
/
config.py
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
'''
File created by Reza Kalantar - 29/11/2022
'''
import torch
from monai.transforms import (
EnsureChannelFirstd,
EnsureTyped,
Compose,
CropForegroundd,
LoadImaged,
Invertd,
Orientationd,
MapTransform,
NormalizeIntensityd,
RandCropByPosNegLabeld,
RandSpatialCropSamplesd,
CenterSpatialCropd,
RandSpatialCropd,
SpatialPadd,
ScaleIntensityRanged,
Spacingd,
ToTensord,
)
params = {
'num_pool': 100, #number of images generated in image pool
'roi_size': [128,128,128], #determines the patch size
'pixdim':(0.8,0.8,0.8), #resampling pixel dimensions
'imgA_intensity_range': (-1000,1000), #range of intensities for nomalization to range [-1,1]
'imgB_intensity_range': (0,1500),
}
# Transformations for dynamic loading and sampling of Nifti files
train_transforms = Compose([
LoadImaged(keys=['imgA', 'imgB']),
EnsureChannelFirstd(keys=['imgA', 'imgB']),
# Orientationd(keys=['imgA', 'imgB'], axcodes='RAS'),
CropForegroundd(keys=['imgA'], source_key='imgA'),
CropForegroundd(keys=['imgB'], source_key='imgB'),
Spacingd(keys=['imgA', 'imgB'], pixdim=params['pixdim'], mode=("bilinear", "bilinear")),
ScaleIntensityRanged(keys=['imgA'], a_min=params['imgA_intensity_range'][0], a_max=params['imgA_intensity_range'][1], b_min=-1.0, b_max=1.0, clip=True),
ScaleIntensityRanged(keys=['imgB'], a_min=params['imgB_intensity_range'][0], a_max=params['imgB_intensity_range'][1], b_min=-1.0, b_max=1.0, clip=False),
RandSpatialCropd(keys=['imgA'], roi_size=params['roi_size'], random_size=False, random_center=True),
RandSpatialCropd(keys=['imgB'], roi_size=params['roi_size'], random_size=False, random_center=True),
SpatialPadd(keys=["imgA", "imgB"], spatial_size=params['roi_size']),
])
test_transforms = Compose([
LoadImaged(keys=['imgA', 'imgB']),
EnsureChannelFirstd(keys=['imgA', 'imgB']),
# Orientationd(keys=['imgA', 'imgB'], axcodes='RAS'),
CropForegroundd(keys=['imgA'], source_key='imgA'),
CropForegroundd(keys=['imgB'], source_key='imgB'),
Spacingd(keys=['imgA', 'imgB'], pixdim=params['pixdim'], mode=("bilinear", "bilinear")),
ScaleIntensityRanged(keys=['imgA'], a_min=params['imgA_intensity_range'][0], a_max=params['imgA_intensity_range'][1], b_min=-1.0, b_max=1.0, clip=True),
ScaleIntensityRanged(keys=['imgB'], a_min=params['imgB_intensity_range'][0], a_max=params['imgB_intensity_range'][1], b_min=-1.0, b_max=1.0, clip=False),
RandSpatialCropd(keys=['imgA'], roi_size=params['roi_size'], random_size=False, random_center=True),
RandSpatialCropd(keys=['imgB'], roi_size=params['roi_size'], random_size=False, random_center=True),
SpatialPadd(keys=["imgA", "imgB"], spatial_size=params['roi_size']),
])