File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1
- # Copyright 2021-2023 MONAI Consortium
1
+ # Copyright 2021-2025 MONAI Consortium
2
2
# Licensed under the Apache License, Version 2.0 (the "License");
3
3
# you may not use this file except in compliance with the License.
4
4
# You may obtain a copy of the License at
@@ -234,11 +234,17 @@ def prepare_series(self, series):
234
234
series ._sop_instances [slice_index ].distance = distance
235
235
series ._sop_instances [slice_index ].first_pixel_on_slice_normal = point
236
236
else :
237
- print ( "going to removing slice " , slice_index )
237
+ logging . debug ( f"Slice index to remove: { slice_index } " )
238
238
slice_indices_to_be_removed .append (slice_index )
239
239
240
- for sl_index , _ in enumerate (slice_indices_to_be_removed ):
240
+ logging .debug (f"Total slices before removal (if applicable): { len (series ._sop_instances )} " )
241
+
242
+ # iterate in reverse order to avoid affecting subsequent indices after a deletion
243
+ for sl_index in sorted (slice_indices_to_be_removed , reverse = True ):
241
244
del series ._sop_instances [sl_index ]
245
+ logging .info (f"Removed slice index: { sl_index } " )
246
+
247
+ logging .debug (f"Total slices after removal (if applicable): { len (series ._sop_instances )} " )
242
248
243
249
series ._sop_instances = sorted (series ._sop_instances , key = lambda s : s .distance )
244
250
series .depth_direction_cosine = copy .deepcopy (last_slice_normal )
You can’t perform that action at this time.
0 commit comments