Closed RobertoLorusso closed 10 months ago
Top images depict the sections of a single MRI without padding. Bottom images depict the sections of a single MRI WITH padding. It's possible to notice how the padding completely changed the first axis fo the image, along with the labels
The code is shown below:
def padding(self,image, labels): n_channels = np.shape(image)[0] max_val = max(np.shape(image)) pad_list = np.zeros([n_channels,max_val,max_val,max_val],dtype=np.float32) for channel in range(0, n_channels): # pad every channel pad_list[channel] = np.pad(image[channel],[(42,43),(0,0),(0,0)],'constant') labels = np.pad(labels, [(42,43),(0,0),(0,0)],'constant') return pad_list, labels
n_channels is set as the first dimension. This is right for the images where originally we have tensors of shape (4,155,240,240) to pad. But the labels are tensors with shape (155,240,240).
Despite this error, the function 'correctly' returns (240,240,240) tensors of labels.