# Path: MEHI/paralleled/IO.py
# @exeTime
# def load_tiff(sc, pwd, start_index=None, end_index=None):
#     '''
#     Usage:
#      - just read all the image under the pwd
#     '''
#     if os.path.isdir(pwd):
#         img_stack = []
#         names = []
#         for imgname in os.listdir(pwd):
#             if imgname.endswith('.tif'):
#                 names.append(imgname)
#         names = sorted(names, key = lambda x: int(filter(str.isdigit, x)))
#         if (start_index) and (end_index) and (0 <= start_index < end_index) and (start_index < end_index <= len(names)):
#             names = names[start_index:end_index]
#         n = len(names)
#         def func(name):
#             img_pwd = os.path.join(pwd, name)
#             if img_pwd.endswith('.tif'):
#                 img = tiff.imread(img_pwd)
#             return img
#         rdd_file = sc.parallelize(names)
#         return np.squeeze(np.array(rdd_file.map(func).collect()))
#     else:
#         return tiff.imread(pwd)


from MEHI.paralleled.fusion import *
from MEHI.paralleled.IO import load_tiff
from test_utils import PySparkTestCase
import numpy as np
import os
################################
# Author   : septicmk
# Date     : 2015/07/24 20:08:44
# FileName : test_p_fusion.py
################################


L_pwd = os.path.abspath('.') + '/test_data/L_side/'
R_pwd = os.path.abspath('.') + '/test_data/R_side/'

class PySparkTestFusionCase(PySparkTestCase):
    def setUp(self):
        super(PySparkTestFusionCase, self).setUp()
        self.L_imgs = load_tiff(self.sc, L_pwd)

# Path: MEHI/paralleled/IO.py
# @exeTime
# def load_tiff(sc, pwd, start_index=None, end_index=None):
#     '''
#     Usage:
#      - just read all the image under the pwd
#     '''
#     if os.path.isdir(pwd):
#         img_stack = []
#         names = []
#         for imgname in os.listdir(pwd):
#             if imgname.endswith('.tif'):
#                 names.append(imgname)
#         names = sorted(names, key = lambda x: int(filter(str.isdigit, x)))
#         if (start_index) and (end_index) and (0 <= start_index < end_index) and (start_index < end_index <= len(names)):
#             names = names[start_index:end_index]
#         n = len(names)
#         def func(name):
#             img_pwd = os.path.join(pwd, name)
#             if img_pwd.endswith('.tif'):
#                 img = tiff.imread(img_pwd)
#             return img
#         rdd_file = sc.parallelize(names)
#         return np.squeeze(np.array(rdd_file.map(func).collect()))
#     else:
#         return tiff.imread(pwd)


# Path: test/test_p_fusion.py
from MEHI.paralleled.fusion import *
from MEHI.paralleled.IO import load_tiff
from test_utils import PySparkTestCase
import numpy as np
import os

################################
# Author   : septicmk
# Date     : 2015/07/24 20:08:44
# FileName : test_p_fusion.py
################################


L_pwd = os.path.abspath('.') + '/test_data/L_side/'
R_pwd = os.path.abspath('.') + '/test_data/R_side/'

class PySparkTestFusionCase(PySparkTestCase):
    def setUp(self):
        super(PySparkTestFusionCase, self).setUp()
        self.L_imgs = load_tiff(self.sc, L_pwd)

        self.R_imgs = load_tiff(self.sc, R_pwd)