Example #1
0
 def test_process_with_dvh(self):
     '''
     Can list specific DVH values to compute
     '''
     # Set up a schema validator
     com_schema = {
         'mean':
         And([float], lambda x: len(x) == 2),
         'min':
         And([float], lambda x: len(x) == 2),
         'max':
         And([float], lambda x: len(x) == 2),
         'dvh':
         And([np.ndarray], lambda x: np.all([d.shape == (6, 2) for d in x]),
             lambda x: len(x) == 2)
     }
     validator = Schema(com_schema)
     # Compute features
     dvh_vals = [0, 0.2, 0.4, 0.6, 0.8, 1]
     feat = SliceFeature('test', mask=self.mask, dose=self.dg, dvh=dvh_vals)
     output = feat.process()
     # Check the output schema
     try:
         self.assertTrue(validator.validate(output) is not SchemaError)
     except SchemaError:
         self.fail('Output does not match given schema')
Example #2
0
 def test_process_before_load(self):
     '''
     Cannot process before loading data
     '''
     feat = SliceFeature('test')
     self.assertFalse(feat.loaded)
     self.assertRaises(ValueError, lambda: feat.process())
Example #3
0
 def __helper_test_process(self, n, a):
     '''
     Helper method to validate slice feature
     '''
     com_schema = {
         'mean': And([float], lambda x: len(x) == n),
         'min': And([float], lambda x: len(x) == n),
         'max': And([float], lambda x: len(x) == n),
         'dvh': And([np.ndarray], lambda x: len(x) == n)
     }
     validator = Schema(com_schema)
     # Compute features
     feat = SliceFeature('test',
                         num_slices=n,
                         axis=a,
                         mask=self.mask,
                         dose=self.dg)
     output = feat.process()
     # Check the output schema
     try:
         self.assertTrue(validator.validate(output) is not SchemaError)
     except SchemaError:
         self.fail('Output does not match given schema')