コード例 #1
0
 def test_process_before_load(self):
     '''
     Cannot process before loading data
     '''
     feat = DVHFeature('test')
     self.assertFalse(feat.loaded)
     self.assertRaises(ValueError, lambda: feat.process())
コード例 #2
0
 def test_process_dose(self):
     '''
     DVH feature class computes mean, min, max, and dvh
     '''
     feat = DVHFeature('test', mask=self.mask, dose=self.dg)
     feat.process_dose()
     self.assertTrue(isinstance(feat.feature_dosemask, DoseMask))
コード例 #3
0
 def test_process_mask(self):
     '''
     DVH feature class has trivial mask processing
     '''
     feat = DVHFeature('test', mask=self.mask, dose=self.dg)
     feat.process_mask()
     self.assertTrue(isinstance(feat.feature_mask, Mask))
コード例 #4
0
 def test_load_feature(self):
     '''
     Can initialize with mask and dose grid
     '''
     feat = DVHFeature('test')
     feat.load(self.mask, self.dg)
     self.assertTrue(feat.mask is not None)
     self.assertTrue(feat.dose is not None)
     self.assertTrue(feat.loaded)
コード例 #5
0
 def test_create_with_featuretype(self):
     '''
     Can specify a certain feature type
     '''
     feat = DVHFeature('test', feature_type='sample_type')
     self.assertFalse(feat.loaded)
     self.assertEqual(feat.type, 'sample_type')
コード例 #6
0
 def test_create_feature_with_values(self):
     '''
     Can initialize with mask and dose grid
     '''
     feat = DVHFeature('test', mask=self.mask, dose=self.dg)
     self.assertTrue(feat.mask is not None)
     self.assertTrue(feat.dose is not None)
     self.assertTrue(feat.loaded)
コード例 #7
0
 def test_process(self):
     '''
     Process values for DVHFeature
     '''
     # Set up a schema validator
     dvh_schema = {
         'mean': And(float),
         'min': And(float),
         'max': And(float),
         'dvh': And(np.ndarray)
     }
     validator = Schema(dvh_schema)
     # Compute features
     feat = DVHFeature('test', 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')
コード例 #8
0
 def test_check_elements(self):
     '''
     Make sure the Feature object has all the required attributes
     '''
     feat = DVHFeature('test')
     elem_list = [
         'id', 'type', 'output', 'dose', 'mask', 'feature_mask',
         'feature_dosemask', 'loaded'
     ]
     self.assertTrue(isinstance(feat, DVHFeature))
     for elem in elem_list:
         self.assertTrue(hasattr(feat, elem))
コード例 #9
0
 def test_process_with_dvh(self):
     '''
     Can list specific DVH values to compute
     '''
     # Set up a schema validator
     dvh_schema = {
         'mean': float,
         'min': float,
         'max': float,
         'dvh': And(np.ndarray, lambda x: x.shape == (6, 2))
     }
     validator = Schema(dvh_schema)
     # Compute features
     dvh_vals = [0, 0.2, 0.4, 0.6, 0.8, 1]
     feat = DVHFeature('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')
コード例 #10
0
 def test_values_before_load(self):
     '''
     Cannot get values before loading data
     '''
     feat = DVHFeature('test')
     self.assertRaises(ValueError, lambda: feat.values)