You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for your excellent work.
I have a question when transform the .mat data to the .png data and found the slices are not correspond.
There are 25 images in T1 and T2 each, however ,with the same index, the corresponding images are not the same location,
The transform code are as follows:
`
import torch.utils.data
import numpy as np, h5py
import random
f = h5py.File(load_dir,'r')
if np.array(f[variable]).ndim==3:
data=np.expand_dims(np.transpose(np.array(f[variable]),(0,2,1)),axis=1)
else:
data=np.transpose(np.array(f[variable]),(1,0,3,2))
data=data.astype(np.float32)
if padding:
pad_x=int((256-data.shape[2])/2)
pad_y=int((256-data.shape[3])/2)
print('padding in x-y with:'+str(pad_x)+'-'+str(pad_y))
data=np.pad(data,((0,0),(0,0),(pad_x,pad_x),(pad_y,pad_y)))
if Norm:
data=(data-0.5)/0.5
from PIL import Image
import numpy as np
data = ((data + 1) * 0.5 * 255).astype(np.uint8)
print(data.shape)
for i, sample in enumerate(data):
# print(sample.shape,sample)
# image = Image.fromarray(sample.transpose(1, 2, 0))
image = Image.fromarray(sample[0])
image.save(f'show/vT1_image_{i}.png')
`
I would like to know after registration, should the data not correspond?
Thank you.
The text was updated successfully, but these errors were encountered:
SynDiff was proposed for Unsupervised Medical Image Translation with unpaired source-target images. Hence, training data doesn't have to be matched/registered. However, you can still employ SynDiff with paired images.
Thanks for your excellent work.
I have a question when transform the .mat data to the .png data and found the slices are not correspond.
There are 25 images in T1 and T2 each, however ,with the same index, the corresponding images are not the same location,
The transform code are as follows:
`
import torch.utils.data
import numpy as np, h5py
import random
load_dir = 'SynDiff-main/SynDiff_sample_data/data_val_T1.mat'
padding = True
Norm = True
variable = 'data_fs'
f = h5py.File(load_dir,'r')
if np.array(f[variable]).ndim==3:
data=np.expand_dims(np.transpose(np.array(f[variable]),(0,2,1)),axis=1)
else:
data=np.transpose(np.array(f[variable]),(1,0,3,2))
data=data.astype(np.float32)
if padding:
pad_x=int((256-data.shape[2])/2)
pad_y=int((256-data.shape[3])/2)
print('padding in x-y with:'+str(pad_x)+'-'+str(pad_y))
data=np.pad(data,((0,0),(0,0),(pad_x,pad_x),(pad_y,pad_y)))
if Norm:
data=(data-0.5)/0.5
from PIL import Image
import numpy as np
data = ((data + 1) * 0.5 * 255).astype(np.uint8)
print(data.shape)
for i, sample in enumerate(data):
# print(sample.shape,sample)
# image = Image.fromarray(sample.transpose(1, 2, 0))
image = Image.fromarray(sample[0])
image.save(f'show/vT1_image_{i}.png')
`
I would like to know after registration, should the data not correspond?
Thank you.
The text was updated successfully, but these errors were encountered: