@@ -99,11 +99,11 @@ def _apply_misalignment_translation(
9999
100100 output = np .zeros (out_shape , img .dtype )
101101 if mode == "slip" :
102- output = img [:, y0 : y0 + out_shape [1 ], x0 : x0 + out_shape [2 ]]
103- output [idx ] = img [idx , y1 : y1 + out_shape [1 ], x1 : x1 + out_shape [2 ]]
102+ output = img [:, y0 : y0 + out_shape [1 ], x0 : x0 + out_shape [2 ]]
103+ output [idx ] = img [idx , y1 : y1 + out_shape [1 ], x1 : x1 + out_shape [2 ]]
104104 else :
105- output [:idx ] = img [:idx , y0 : y0 + out_shape [1 ], x0 : x0 + out_shape [2 ]]
106- output [idx :] = img [idx :, y1 : y1 + out_shape [1 ], x1 : x1 + out_shape [2 ]]
105+ output [:idx ] = img [:idx , y0 : y0 + out_shape [1 ], x0 : x0 + out_shape [2 ]]
106+ output [idx :] = img [idx :, y1 : y1 + out_shape [1 ], x1 : x1 + out_shape [2 ]]
107107
108108 if is_tensor :
109109 output = torch .from_numpy (output ).to (device )
@@ -299,7 +299,7 @@ def _apply_missing_parts(
299299 x_start = self .R .randint (0 , img .shape [2 ] - hole_w + 1 )
300300
301301 # Create hole (set to 0 or mean value)
302- img [section_idx , y_start : y_start + hole_h , x_start : x_start + hole_w ] = 0
302+ img [section_idx , y_start : y_start + hole_h , x_start : x_start + hole_w ] = 0
303303
304304 return img
305305
@@ -452,24 +452,24 @@ def _apply_cut_noise(
452452 noise = self .R .uniform (- self .noise_scale , self .noise_scale , noise_shape )
453453 region = img [
454454 :,
455- z_start : z_start + z_len ,
456- y_start : y_start + y_len ,
457- x_start : x_start + x_len ,
455+ z_start : z_start + z_len ,
456+ y_start : y_start + y_len ,
457+ x_start : x_start + x_len ,
458458 ]
459459 noisy_region = np .clip (region + noise , 0 , 1 )
460460 img [
461461 :,
462- z_start : z_start + z_len ,
463- y_start : y_start + y_len ,
464- x_start : x_start + x_len ,
462+ z_start : z_start + z_len ,
463+ y_start : y_start + y_len ,
464+ x_start : x_start + x_len ,
465465 ] = noisy_region
466466 else :
467467 # (C, H, W) - 2D with channels
468468 noise_shape = (img .shape [0 ], y_len , x_len )
469469 noise = self .R .uniform (- self .noise_scale , self .noise_scale , noise_shape )
470- region = img [:, y_start : y_start + y_len , x_start : x_start + x_len ]
470+ region = img [:, y_start : y_start + y_len , x_start : x_start + x_len ]
471471 noisy_region = np .clip (region + noise , 0 , 1 )
472- img [:, y_start : y_start + y_len , x_start : x_start + x_len ] = noisy_region
472+ img [:, y_start : y_start + y_len , x_start : x_start + x_len ] = noisy_region
473473 elif img .ndim == 3 :
474474 # 3D case: (Z, Y, X) or (C, H, W)
475475 # Heuristic: if first dim is small (<=4), assume it's channel (2D with channels)
@@ -478,29 +478,29 @@ def _apply_cut_noise(
478478 # (C, H, W) - 2D with channels
479479 noise_shape = (img .shape [0 ], y_len , x_len )
480480 noise = self .R .uniform (- self .noise_scale , self .noise_scale , noise_shape )
481- region = img [:, y_start : y_start + y_len , x_start : x_start + x_len ]
481+ region = img [:, y_start : y_start + y_len , x_start : x_start + x_len ]
482482 noisy_region = np .clip (region + noise , 0 , 1 )
483- img [:, y_start : y_start + y_len , x_start : x_start + x_len ] = noisy_region
483+ img [:, y_start : y_start + y_len , x_start : x_start + x_len ] = noisy_region
484484 else :
485485 # (Z, Y, X) - 3D
486486 z_len = max (1 , int (self .length_ratio * img .shape [0 ])) # Ensure at least 1
487487 z_start = self .R .randint (0 , max (1 , img .shape [0 ] - z_len + 1 ))
488488 noise_shape = (z_len , y_len , x_len )
489489 noise = self .R .uniform (- self .noise_scale , self .noise_scale , noise_shape )
490490 region = img [
491- z_start : z_start + z_len , y_start : y_start + y_len , x_start : x_start + x_len
491+ z_start : z_start + z_len , y_start : y_start + y_len , x_start : x_start + x_len
492492 ]
493493 noisy_region = np .clip (region + noise , 0 , 1 )
494494 img [
495- z_start : z_start + z_len , y_start : y_start + y_len , x_start : x_start + x_len
495+ z_start : z_start + z_len , y_start : y_start + y_len , x_start : x_start + x_len
496496 ] = noisy_region
497497 else :
498498 # 2D case: (H, W)
499499 noise_shape = (y_len , x_len )
500500 noise = self .R .uniform (- self .noise_scale , self .noise_scale , noise_shape )
501- region = img [y_start : y_start + y_len , x_start : x_start + x_len ]
501+ region = img [y_start : y_start + y_len , x_start : x_start + x_len ]
502502 noisy_region = np .clip (region + noise , 0 , 1 )
503- img [y_start : y_start + y_len , x_start : x_start + x_len ] = noisy_region
503+ img [y_start : y_start + y_len , x_start : x_start + x_len ] = noisy_region
504504
505505 if is_tensor :
506506 img = torch .from_numpy (img ).to (device )
@@ -886,7 +886,7 @@ def _find_best_paste(
886886 neuron_tensor .flip (0 ) if neuron_tensor .ndim == 3 else neuron_tensor .flip (1 )
887887 )
888888
889- label_paste = labels [best_idx : best_idx + 1 ]
889+ label_paste = labels [best_idx : best_idx + 1 ]
890890
891891 if best_angle != 0 :
892892 label_paste = self ._rotate_3d (label_paste , best_angle )
0 commit comments