Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toy data question #41

Open
Xiao-R-Y opened this issue Mar 11, 2024 · 1 comment
Open

toy data question #41

Xiao-R-Y opened this issue Mar 11, 2024 · 1 comment

Comments

@Xiao-R-Y
Copy link

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,
T1_image_0
T2_image_0
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.

@muzafferozbey
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants