File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -324,9 +324,31 @@ def complete_structure_mask(
324
324
image_repeat ,
325
325
exclusion_repeat ,
326
326
)
327
- # Stack mask arrays to give the desired output format
327
+ # Filter duplicates and stack mask arrays to give the desired output format
328
+ expanded_split_mask_arrays = filter_duplicate_masks (expanded_split_mask_arrays )
328
329
mask_array = np .stack (expanded_split_mask_arrays , - 1 )
329
330
return mask_array
330
331
else :
331
332
print ("No masks found." )
332
333
return mask_array
334
+
335
+
336
+ def filter_duplicate_masks (array_list : List [np .array ]) -> List [np .array ]:
337
+ """
338
+ This function takes a list of arrays and returns a list of unique arrays.
339
+
340
+ Args:
341
+ array_list (List[np.array]): Masks
342
+
343
+ Returns:
344
+ List[np.array]: Unique masks
345
+ """
346
+ seen = set ()
347
+ unique_list = []
348
+ for arr in array_list :
349
+ # Convert the array to a hashable tuple
350
+ arr_tuple = tuple (arr .ravel ())
351
+ if arr_tuple not in seen :
352
+ seen .add (arr_tuple )
353
+ unique_list .append (arr )
354
+ return unique_list
You can’t perform that action at this time.
0 commit comments