Ejemplo n.º 1
0
 def test_StandardTransformer(self):
     config = {
         'raw': [{
             'name': 'Standardize'
         }, {
             'name': 'RandomContrast',
             'execution_probability': 0.5
         }, {
             'name': 'RandomFlip'
         }, {
             'name': 'RandomRotate90'
         }, {
             'name': 'ToTensor',
             'expand_dims': True
         }],
         'label': [{
             'name': 'RandomFlip'
         }, {
             'name': 'RandomRotate90'
         }, {
             'name': 'ToTensor',
             'expand_dims': False,
             'dtype': 'long'
         }]
     }
     base_config = {'mean': 0, 'std': 1}
     transformer = Transformer(config, base_config)
     raw_transforms = transformer.raw_transform().transforms
     assert raw_transforms[0].mean == 0
     assert raw_transforms[0].std == 1
     assert raw_transforms[1].execution_probability == 0.5
     assert raw_transforms[4].expand_dims
     label_transforms = transformer.label_transform().transforms
     assert len(label_transforms) == 3
Ejemplo n.º 2
0
 def test_BaseTransformer(self):
     config = {
         'raw': [{
             'name': 'Standardize'
         }, {
             'name': 'ToTensor',
             'expand_dims': True
         }],
         'label': [{
             'name': 'ToTensor',
             'expand_dims': False,
             'dtype': 'long'
         }],
         'weight': [{
             'name': 'ToTensor',
             'expand_dims': False
         }]
     }
     base_config = {'mean': 0, 'std': 1}
     transformer = Transformer(config, base_config)
     raw_transforms = transformer.raw_transform().transforms
     assert raw_transforms[0].mean == 0
     assert raw_transforms[0].std == 1
     assert raw_transforms[1].expand_dims
     label_transforms = transformer.label_transform().transforms
     assert not label_transforms[0].expand_dims
     assert label_transforms[0].dtype == 'long'
     weight_transforms = transformer.weight_transform().transforms
     assert not weight_transforms[0].expand_dims
Ejemplo n.º 3
0
 def test_LabelToBoundaryTransformer(self):
     config = {
         'raw': [
             {'name': 'Standardize'},
             {'name': 'RandomContrast', 'execution_probability': 0.5},
             {'name': 'RandomFlip'},
             {'name': 'RandomRotate90'},
             {'name': 'RandomRotate', 'angle_spectrum': 17, 'axes': [[2, 1]], 'mode': 'reflect'},
             {'name': 'ToTensor', 'expand_dims': True}
         ],
         'label': [
             {'name': 'RandomFlip'},
             {'name': 'RandomRotate90'},
             {'name': 'RandomRotate', 'angle_spectrum': 17, 'axes': [[2, 1]], 'mode': 'reflect'},
             {'name': 'LabelToAffinities', 'offsets': [2, 4, 6, 8]},
             {'name': 'ToTensor', 'expand_dims': False, 'dtype': 'long'}
         ]
     }
     base_config = {'mean': 0, 'std': 1}
     transformer = Transformer(config, base_config)
     raw_transforms = transformer.raw_transform().transforms
     assert raw_transforms[0].mean == 0
     assert raw_transforms[0].std == 1
     assert raw_transforms[1].execution_probability == 0.5
     assert raw_transforms[4].angle_spectrum == 17
     assert raw_transforms[4].axes == [[2, 1]]
     assert raw_transforms[4].mode == 'reflect'
     label_transforms = transformer.label_transform().transforms
     assert label_transforms[2].angle_spectrum == 17
     assert label_transforms[2].axes == [[2, 1]]
     assert label_transforms[2].mode == 'reflect'
     # 3 conv kernels per offset
     assert len(label_transforms[3].kernels) == 12
Ejemplo n.º 4
0
 def test_AnisotropicRotationTransformer(self):
     config = {
         'raw': [
             {'name': 'Standardize'},
             {'name': 'RandomContrast', 'execution_probability': 0.5},
             {'name': 'RandomFlip'},
             {'name': 'RandomRotate90'},
             {'name': 'RandomRotate', 'angle_spectrum': 17, 'axes': [[2, 1]]},
             {'name': 'ToTensor', 'expand_dims': True}
         ],
         'label': [
             {'name': 'RandomFlip'},
             {'name': 'RandomRotate90'},
             {'name': 'RandomRotate', 'angle_spectrum': 17, 'axes': [[2, 1]]},
             {'name': 'ToTensor', 'expand_dims': False, 'dtype': 'long'}
         ]
     }
     base_config = {'mean': 0, 'std': 1}
     transformer = Transformer(config, base_config)
     raw_transforms = transformer.raw_transform().transforms
     assert raw_transforms[0].mean == 0
     assert raw_transforms[0].std == 1
     assert raw_transforms[1].execution_probability == 0.5
     assert raw_transforms[4].angle_spectrum == 17
     assert raw_transforms[4].axes == [[2, 1]]
     label_transforms = transformer.label_transform().transforms
     assert len(label_transforms) == 4
Ejemplo n.º 5
0
 def test_RandomLabelToBoundaryTransformer(self):
     config = {
         'raw': [{
             'name': 'Normalize'
         }, {
             'name': 'RandomContrast',
             'execution_probability': 0.5
         }, {
             'name': 'RandomFlip'
         }, {
             'name': 'RandomRotate90'
         }, {
             'name': 'RandomRotate',
             'angle_spectrum': 17,
             'axes': [[2, 1]],
             'mode': 'reflect'
         }, {
             'name': 'ToTensor',
             'expand_dims': True
         }],
         'label': [{
             'name': 'RandomFlip'
         }, {
             'name': 'RandomRotate90'
         }, {
             'name': 'RandomRotate',
             'angle_spectrum': 17,
             'axes': [[2, 1]],
             'mode': 'reflect'
         }, {
             'name': 'RandomLabelToAffinities',
             'max_offset': 4
         }, {
             'name': 'ToTensor',
             'expand_dims': False,
             'dtype': 'long'
         }]
     }
     base_config = {'mean': 0, 'std': 1}
     transformer = Transformer(config, base_config)
     label_transforms = transformer.label_transform().transforms
     assert label_transforms[3].offsets == (1, 2, 3, 4)