Open prefectmoon opened 11 months ago
I've made modifications to the code, and now the HR and LR dimensions match. However, I'm uncertain about the correctness of my implementation, and I'm still puzzled by the discrepancy between the generated HR dataset and the one you provided, even though their file sizes are now the same. Below is the modified code I've been using for generating the IXI dataset.
def getLR(hr_data, scaling_factor):
imgfft = np.fft.fftn(hr_data)
imgfft = np.fft.fftshift(imgfft)
x, y, z = imgfft.shape
diff_x = x // (scaling_factor * 2)
diff_y = y // (scaling_factor * 2)
diff_z = z // (scaling_factor * 2)
x_centre = x // 2
y_centre = y // 2
z_centre = z // 2
mask = np.zeros(imgfft.shape)
mask[x_centre - diff_x: x_centre + diff_x, y_centre - diff_y: y_centre + diff_y, z_centre - diff_z: z_centre + diff_z] = 1
imgfft = imgfft * mask
imgifft = np.fft.ifftshift(imgfft)
imgifft = np.fft.ifftn(imgifft)
img_out = abs(imgifft)
return img_out
def create_npy_dataset(path, modality, output_path, data_shape, scaling_factor, transform=None):
print("scaling_factor", scaling_factor)
folder_names = os.listdir(path)
print("'.DS_Store' in folder_names", '.DS_Store' in folder_names)
training_hr, training_lr = get_hr_lr(0, 500, folder_names, path, data_shape, scaling_factor, transform)
with open(output_path + f'/IXI_training_hr_{modality}_scale_by_{scaling_factor}_imgs.npy', 'wb') as f:
np.save(f, training_hr)
with open(output_path + f'/IXI_training_lr_{modality}_scale_by_{scaling_factor}_imgs_small.npy', 'wb') as f:
np.save(f, training_lr)
if __name__ == "__main__":
modality = 't1'
data_shape = (224, 224, 96)
transforms = torchvision.transforms.Compose([CenterCrop(data_shape)])
create_npy_dataset(modality=modality,
path='IXI-T1/',
output_path='ours_new_dataset/',
data_shape=data_shape,
scaling_factor=4,
transform=transforms)
Hello, I appreciate your inquiry. Indeed, your corrected code can generate HR T2 images for training DisC-Diff properly. The prior version of the code was tailored towards dataset preparation for certain benchmark Super-Resolution algorithms (e.g., EDSR). Those particular algorithms necessitated inconsistencies in image dimensions between HR and LR images. However, it's important to highlight that DisC-Diff is primarily proposed for the MCSR challenge. As a result, it's essential to also prepare corresponding HR T1 data that's registered to the T2 brain images. Please do not hesitate to ask if you require further clarification.
Hello, I appreciate your inquiry. Indeed, your corrected code can generate HR T2 images for training DisC-Diff properly. The prior version of the code was tailored towards dataset preparation for certain benchmark Super-Resolution algorithms (e.g., EDSR). Those particular algorithms necessitated inconsistencies in image dimensions between HR and LR images. However, it's important to highlight that DisC-Diff is primarily proposed for the MCSR challenge. As a result, it's essential to also prepare corresponding HR T1 data that's registered to the T2 brain images. Please do not hesitate to ask if you require further clarification.
Thank you for your clarification. However, I'm still puzzled by the fact that even the HR results are inconsistent with the dataset you provided. I would greatly appreciate it if you could provide more implementation details, and if possible, some clear code snippet, to help me better understand the process.
I've made modifications to the code, and now the HR and LR dimensions match. However, I'm uncertain about the correctness of my implementation, and I'm still puzzled by the discrepancy between the generated HR dataset and the one you provided, even though their file sizes are now the same. Below is the modified code I've been using for generating the IXI dataset.
def getLR(hr_data, scaling_factor): imgfft = np.fft.fftn(hr_data) imgfft = np.fft.fftshift(imgfft) x, y, z = imgfft.shape diff_x = x // (scaling_factor * 2) diff_y = y // (scaling_factor * 2) diff_z = z // (scaling_factor * 2) x_centre = x // 2 y_centre = y // 2 z_centre = z // 2 mask = np.zeros(imgfft.shape) mask[x_centre - diff_x: x_centre + diff_x, y_centre - diff_y: y_centre + diff_y, z_centre - diff_z: z_centre + diff_z] = 1 imgfft = imgfft * mask imgifft = np.fft.ifftshift(imgfft) imgifft = np.fft.ifftn(imgifft) img_out = abs(imgifft) return img_out def create_npy_dataset(path, modality, output_path, data_shape, scaling_factor, transform=None): print("scaling_factor", scaling_factor) folder_names = os.listdir(path) print("'.DS_Store' in folder_names", '.DS_Store' in folder_names) training_hr, training_lr = get_hr_lr(0, 500, folder_names, path, data_shape, scaling_factor, transform) with open(output_path + f'/IXI_training_hr_{modality}_scale_by_{scaling_factor}_imgs.npy', 'wb') as f: np.save(f, training_hr) with open(output_path + f'/IXI_training_lr_{modality}_scale_by_{scaling_factor}_imgs_small.npy', 'wb') as f: np.save(f, training_lr) if __name__ == "__main__": modality = 't1' data_shape = (224, 224, 96) transforms = torchvision.transforms.Compose([CenterCrop(data_shape)]) create_npy_dataset(modality=modality, path='IXI-T1/', output_path='ours_new_dataset/', data_shape=data_shape, scaling_factor=4, transform=transforms)
Hey,do you know how the data processed?what's the effect of your code to process the data?Have you process the data succesffully?Can you share it if you did it?I would be so much appreciate if you can do it,I am confused about the data for a long time.(Crying!)
Hello, I hope this message finds you well. I have been using your pre-processing code for generating datasets, and I noticed that the output differs from the one you provided. Specifically, the high-resolution (HR) image dimensions are larger than the low-resolution (LR) ones. Furthermore, the generated HR dataset doesn't match the dataset you uploaded. I've been using the IXI dataset for the preprocessing, just as you did. Could you please help me understand why there is this disparity between the generated dataset and the one you shared?