代码拉取完成,页面将自动刷新
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。