1 Star 0 Fork 0

Unluckyless / U-NET-for-LocalBrainAge-prediction-pytorch

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
dataloader.py 1.04 KB
一键复制 编辑 原始数据 按行查看 历史
import os
import torch
import numpy as np
from torch.utils.data.dataset import Dataset
from collections import defaultdict
import nibabel as nib
class UnetDataset(Dataset):
def __init__(self, location_metadata, list_subjects ,dirpath_gm, num_voxels):
super(UnetDataset, self).__init__()
self.location_metadata = location_metadata
self.list_subjects = list_subjects
self.dirpath_gm = dirpath_gm
self.num_voxels = num_voxels
def __len__(self):
return len(self.list_subjects)
def __getitem__(self, index):
current_subject = self.list_subjects[index]
current_row_of_interrst = self.location_metadata.loc[current_subject]
subject_age = current_row_of_interrst.Age / 100
subject_gender = current_row_of_interrst.Gender
subject_name = current_subject
temporar_object = nib.load(self.dirpath_gm+'/'+subject_name)
temporar_data = temporar_object.get_data()
temporar_object.uncache()
#x_training_data = np.expand_dims(temporar_data,axis=0)
x_training_data = temporar_data
return x_training_data,subject_age,subject_gender
1
https://gitee.com/unluckyless/u-net-for-local-brain-age-prediction-pytorch.git
git@gitee.com:unluckyless/u-net-for-local-brain-age-prediction-pytorch.git
unluckyless
u-net-for-local-brain-age-prediction-pytorch
U-NET-for-LocalBrainAge-prediction-pytorch
master

搜索帮助