@@ -224,15 +224,16 @@ def generic_vois(generic_ct):
224224
225225    voi1  =  Target (name = "CTV" , mask = mask_image1 , ct_image = generic_ct , overlap_priority = 1 )
226226    voi2  =  Target (name = "PTV" , mask = mask_image2 , ct_image = generic_ct , overlap_priority = 2 )
227-     voi3  =  OAR (name = "OAR" , mask = mask_image3 , ct_image = generic_ct )
228-     voi4  =  ExternalVOI (name = "BODY" , mask = mask_image4 , ct_image = generic_ct )
229-     voi5  =  HelperVOI (name = "HELPER" , mask = mask_image5 , ct_image = generic_ct )
227+     voi3  =  OAR (name = "OAR" , mask = mask_image3 , ct_image = generic_ct ,  overlap_priority = 5 )
228+     voi4  =  ExternalVOI (name = "BODY" , mask = mask_image4 , ct_image = generic_ct ,  overlap_priority = 10 )
229+     voi5  =  HelperVOI (name = "HELPER" , mask = mask_image5 , ct_image = generic_ct ,  overlap_priority = 5 )
230230
231231    return  [voi1 , voi2 , voi3 , voi4 , voi5 ]
232232
233233
234234def  test_apply_overlap_priorities (generic_ct , generic_vois ):
235235    # Create a StructureSet with the VOIs 
236+ 
236237    structure_set  =  StructureSet (ct_image = generic_ct , vois = generic_vois )
237238
238239    # Apply overlap priorities 
@@ -250,19 +251,24 @@ def test_apply_overlap_priorities(generic_ct, generic_vois):
250251    expected_overlap_list  =  np .argsort (p )
251252
252253    ol_mask  =  np .zeros (voi_mask [0 ].shape , dtype = bool )
254+     or_mask  =  np .zeros (voi_mask [0 ].shape , dtype = bool )
255+     last_priority  =  - 1 
253256
254257    for  expected  in  expected_overlap_list :
258+         if  p [expected ] >  last_priority :
259+             ol_mask  =  or_mask .copy ()
260+             last_priority  =  p [expected ]
261+ 
255262        # the mask that the current voi should have 
256263        assert  (
257264            voi_mask_overlapped [expected ][np .logical_and (voi_mask [expected ] >  0 , ~ ol_mask )]
258265        ).all ()
259266
260267        # Accumulate the ol mask 
261-         ol_mask  =  ol_mask  |  voi_mask [expected ] >  0 
268+         or_mask  =  or_mask  |  voi_mask [expected ] >  0 
262269
263270        # we currently should be zero where overlapped 
264-         assert  not  (voi_mask_overlapped [expected ][ol_mask ] ==  0 ).all ()
265-         # the accumulated ol mask 
271+         assert  (voi_mask_overlapped [expected ][ol_mask ] ==  0 ).all ()
266272
267273
268274def  test_apply_overlap_priorities_same_priority (generic_ct , generic_vois ):
0 commit comments