#save_h5(m, "/home/stamylew/volumes/test_cube1a.h5", "rand500_n4", None)

#label number

#labels = read_h5("/home/stamylew/75cube_Labels.h5", "exported_data")
#nol = get_number_of_labels(labels)
#print nol
#limited = limit_label(labels, 499)
#save_h5(limited, "/home/stamylew/75cube_Labels_rand_500.h5", "", None)


#compare gt to predict

##for different number of loops

n = read_h5("/home/stamylew/volumes/test_cube1.h5", "75cube_memb")
o = read_h5("/home/stamylew/volumes/test_cube1a.h5", "bin_n3")
p = read_h5("/home/stamylew/volumes/test_cube1.h5", "bin_n4")
q = read_h5("/home/stamylew/volumes/test_cube1.h5", "bin_n5")
r = read_h5("/home/stamylew/volumes/test_cube1a.h5", "bin_n6")
s = read_h5("/home/stamylew/volumes/test_cube1.h5", "bin_n7")
t = read_h5("/home/stamylew/volumes/test_cube1.h5", "bin_n8")
u = read_h5("/home/stamylew/volumes/test_cube1a.h5", "bin_n9")
v = read_h5("/home/stamylew/volumes/test_cube1a.h5", "bin_n2")
w = read_h5("/home/stamylew/volumes/test_cube1a.h5", "bin_n1")
y = read_h5("/home/stamylew/volumes/test_cube1a.h5", "bin_n10")
z = read_h5("/home/stamylew/volumes/test_cube1a.h5", "bin_n11")
#x = read_h5("/home/stamylew/src/autocontext/training/cache/0000_test_cube1_probs.h5")
#x = np.squeeze(x)
#x = x[:,:,:,0]
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 18 14:45:41 2015

@author: stamylew
"""

from handle_h5 import read_h5
from handle_h5 import save_h5
from quality import precision

def compare(data1, data2):
    comparison = data1 == data2
    return comparison

if __name__ == '__main__':
    f = read_h5("/home/stamylew/volumes/test_cube1.h5", "75cube_memb")
    g = read_h5("/home/stamylew/volumes/test_cube1.h5", "bin_n5")
    print precision(f, g)
    sample = vg.impex.readImage(x)
    #create volume in cubic shape based on first image
    vol = np.zeros((sample.shape[0], sample.shape[1], sample.shape[0]), dtype= np.uint8)
    #get common name of image files
    common_name = x.split(".")[0]
    #find offset of image number
    offset = x.split(".")[-2]
    #find length of image file number
    str_length = len(offset)
    #get filetype of image files
    filetype = x.split(".")[-1]
    #insert images in volume
    for i in range(sample.shape[0]):
        number = int(offset) + i
        sample = common_name + "." + str(number).zfill(str_length) + "." + str(filetype)
        vol[:, :, i] = np.squeeze(vg.impex.readImage(sample))
    return vol

    
if __name__ == '__main__':
#    x = "iso.03490.png"
#    vol = make_volume(x)
#    save_h5(vol, "volumes/volume.hdf5")
    
    f = "/mnt/CLAWS1/stamilev/data/ids_i_c_manualbigignore.h5"
    g = read_h5(f, "data")
    save_h5(g, "/home/stamylew/volumes/ids_i_c_manualbigignore.h5", "raw", None)
    #j = cut_block(g, 316, 492, 464, 640, 1, 177)
    m = cut_block(g, 25, 725, 0, 700, 0, 700)
    save_h5(m, "/home/stamylew/volumes/ids_i_c_manualbigignore.h5", "useful", None)
    print "done"