import os import sys import time import glob import random import datetime import numpy as np from time import time import SimpleITK as sitk def load_single_data(data_paths,aux_task=False,target_shape=-1): ''' Load data denotes by path in data_paths and concatenate them together ''' data = 0 for path in data_paths: temp_data = np.load(path) print ('temp_data shape is',temp_data.shape) if len(temp_data.shape)==2 and (not aux_task): temp_data = temp_data[:,:7] if len(temp_data.shape)==4 and target_shape>0: center = int(temp_data.shape[1]/2) margin_size = target_shape/2 temp_data = temp_data[:,center-margin_size:center+margin_size, center-margin_size:center+margin_size, center-margin_size:center+margin_size] if type(data) == int: data = np.asarray(temp_data) else: data = np.concatenate([data,temp_data],axis=0) return data def load_data(paths_list,aux_task=False,target_shape=-1): result_list = [load_single_data(data_paths,aux_task=aux_task,target_shape=target_shape) for data_paths in paths_list] return result_list