in activemri/baselines/simple_baselines.py [0:0]
def _get_new_mask(self, current_mask: np.ndarray) -> np.ndarray:
# The code below assumes mask in non centered
new_mask = (
np.fft.ifftshift(current_mask, axes=1)
if self.centered
else current_mask.copy()
)
if self.bottom_side:
idx = np.arange(new_mask.shape[1], 0, -1)
else:
idx = np.arange(new_mask.shape[1])
if self.alternate_sides:
self.bottom_side = not self.bottom_side
# Next line finds the first non-zero index (from edge to center) and returns it
indices = (np.logical_not(new_mask) * idx).argmax(axis=1)
indices = np.expand_dims(indices, axis=1)
new_mask[range(new_mask.shape[0]), indices] = 1
if self.centered:
new_mask = np.fft.ifftshift(new_mask, axes=1)
return new_mask