@@ -97,7 +97,7 @@ def create_dataset(
9797 image = os .path .abspath (image )
9898 label = os .path .abspath (label ) if label else None
9999
100- logging .info ("Image: {}; Label: {}" . format ( image , label if label else None ) )
100+ logging .info (f "Image: { image } ; Label: { label if label else None } " )
101101 data = transforms ({image_key : image , label_key : label })
102102 if dimension == 2 :
103103 data = _save_data_2d (
@@ -154,7 +154,7 @@ def _save_data_2d(vol_idx, vol_image, vol_label, dataset_dir, relative_path):
154154 if vol_label is not None and np .sum (label ) == 0 :
155155 continue
156156
157- image_file_prefix = "vol_idx_{:0>4d}_slice_{:0>3d}" . format ( vol_idx , sid )
157+ image_file_prefix = f "vol_idx_{ vol_idx :0>4d} _slice_{ sid :0>3d} "
158158 image_file = os .path .join (dataset_dir , "images" , image_file_prefix )
159159 image_file += ".npy"
160160
@@ -177,7 +177,7 @@ def _save_data_2d(vol_idx, vol_image, vol_label, dataset_dir, relative_path):
177177 unique_labels_count = max (unique_labels_count , len (unique_labels ))
178178
179179 for idx in unique_labels :
180- label_file_prefix = "{ }_region_{:0>2d}". format ( image_file_prefix , int ( idx ))
180+ label_file_prefix = f" { image_file_prefix } _region_{ int ( idx ) :0>2d} "
181181 label_file = os .path .join (dataset_dir , "labels" , label_file_prefix )
182182 label_file += ".npy"
183183
@@ -226,7 +226,7 @@ def _save_data_3d(vol_idx, vol_image, vol_label, dataset_dir, relative_path):
226226 label_count = 0
227227 unique_labels_count = 0
228228
229- image_file_prefix = "vol_idx_{:0>4d}" . format ( vol_idx )
229+ image_file_prefix = f "vol_idx_{ vol_idx :0>4d} "
230230 image_file = os .path .join (dataset_dir , "images" , image_file_prefix )
231231 image_file += ".npy"
232232
@@ -248,7 +248,7 @@ def _save_data_3d(vol_idx, vol_image, vol_label, dataset_dir, relative_path):
248248 unique_labels_count = max (unique_labels_count , len (unique_labels ))
249249
250250 for idx in unique_labels :
251- label_file_prefix = "{ }_region_{:0>2d}". format ( image_file_prefix , int ( idx ))
251+ label_file_prefix = f" { image_file_prefix } _region_{ int ( idx ) :0>2d} "
252252 label_file = os .path .join (dataset_dir , "labels" , label_file_prefix )
253253 label_file += ".npy"
254254
0 commit comments