vol_file = raw_input('volume file: ')
surf = raw_input('surface file: ')
out = raw_input('output file: ')

# load information from volume
vol = nb.load(vol_file)
vol_data = vol.get_data()
vol_hdr = vol.get_header()
vol_affine = vol.get_affine()

# read vertices from surface
if surf[-3:] == 'vtk':
    v, f = read_vtk(surf)
elif surf[-3:] == 'ply':
    v, f = read_ply(surf)
else:
    print "only vtk and ply format supported yet"

# scale and translate surface into volume space
pixdims = list(vol_hdr['pixdim'][1:4])

v_scaled = np.empty_like(v)
v_scaled[:, 0] = ((1. / pixdims[0]) * v[:, 0])
v_scaled[:, 1] = (-(1. / pixdims[1]) * v[:, 1])
v_scaled[:, 2] = (-(1. / pixdims[2]) * v[:, 2])

trans = [0, (vol.shape[1] - 1), (vol.shape[2] - 1)]

v_trans = np.empty_like(v_scaled)
v_trans[:, 0] = v_scaled[:, 0] + trans[0]
vol_file = raw_input('volume file: ')
surf = raw_input('surface file: ') 
out = raw_input('output file: ')  


# load information from volume
vol = nb.load(vol_file)
vol_data = vol.get_data()
vol_hdr = vol.get_header()
vol_affine = vol.get_affine()

# read vertices from surface
if surf[-3:] == 'vtk':
    v, f = read_vtk(surf)
elif surf[-3:] == 'ply':
    v, f = read_ply(surf)
else:
    print "only vtk and ply format supported yet"


# scale and translate surface into volume space
pixdims = list(vol_hdr['pixdim'][1:4])

v_scaled = np.empty_like(v)
v_scaled[:, 0] = ((1. / pixdims[0]) * v[:, 0])
v_scaled[:, 1] = (-(1. / pixdims[1]) * v[:, 1])
v_scaled[:, 2] = (-(1. / pixdims[2]) * v[:, 2])

trans = [0, (vol.shape[1] - 1), (vol.shape[2] - 1)]

v_trans = np.empty_like(v_scaled)
from ply_rw import read_ply
from vtk_rw import write_vtk

'''
Meta script to convert ply to vtk file
'''

in_ply = raw_input("input ply file: ")
out_vtk = raw_input("output vtk file: ")
comment = raw_input("comment (optional): ")

if comment == "":
    comment = 'vtk format converted from ply'

v, f = read_ply(in_ply)
write_vtk(out_vtk, v, f, comment)