Hi @ptrblck
I have a question about unfold. I want to extract patches from my dataset. I use medicaltorch libarary to loading data. If i use unfold , It has error, I think when I load data by using dataloader, it doesn’t access to data. what can I do?
Thanks.
ROOT_DIR= “/home/elahe/data/dataset/”
img_list = os.listdir(os.path.join(ROOT_DIR,‘trainnii’))
label_list = os.listdir(os.path.join(ROOT_DIR,‘labelsnii’))
print(img_list[1])
img_list= (i.unfold(2, 32, 32).unfold(1, 32, 32).unfold(0, 32, 32) for i in img_list)
label_list = (i.unfold(2, 32, 32).unfold(1, 32, 32).unfold(0, 32, 32) for i in label_list)
filename_pairs = [(os.path.join(ROOT_DIR,‘trainnii’,x),os.path.join(ROOT_DIR,‘labelsnii’,y)) for x,y in zip(img_list,label_list)]
print(filename_pairs)
train_transform = transforms.Compose([
mt_transforms.Resample(0.25, 0.25),
mt_transforms.ElasticTransform(alpha_range=(40.0, 60.0),
sigma_range=(2.5, 4.0),
p=0.3),
mt_transforms.ToTensor()]
)
train_dataset = mt_datasets.MRI2DSegmentationDataset(filename_pairs,transform=train_transform)
dataloader = DataLoader(train_dataset, batch_size=2,collate_fn=mt_datasets.mt_collate)