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_path,aux_task=False,margin_size=32):
    '''
    Load data denotes by path in data_paths and concatenate them together
    '''
    print(data_path)
    if len(data_path.split('/')[-1].split('.')[0].split('_')) == 3:
        mode_1, mode_2,_ =  data_path.split('/')[-1].split('.')[0].split('_')
    else:
        mode_1, mode_2 =  data_path.split('/')[-1].split('.')[0].split('_')
    if mode_2 == 'info':
        data = np.load(data_path, allow_pickle=True)
    else:
        data = np.load(data_path)
    print ('{}_{} shape is {}'.format(mode_1, mode_2, data.shape))
    # if len(temp_data.shape)==2 and (not aux_task):
    #     temp_data = temp_data
    # elif len(temp_data.shape)==4:
    #     center = int(temp_data.shape[1]/2)
    #     margin_size = margin_size
    #     temp_data = temp_data[:,center-margin_size:center+margin_size,
    #                         center-margin_size:center+margin_size,
    #                         center-margin_size:center+margin_size]

    return data


def load_data(paths_list,aux_task=False,margin_size=32): 
    result_list = [load_single_data(data_paths,aux_task=aux_task,margin_size=margin_size) for data_paths in paths_list]

    return result_list



