def vtkReformat(inPath, outPath, dimension=3):
    """
    Reformats vtk file so that it can be read by CIS software.
    """
    inFile = open(inPath, 'rb')
    lineList = inFile.readlines()
    for line in lineList:
        if line.lower().strip().startswith('dimensions'):
            size = map(int, line.split(' ')[1:dimension + 1])
            break
    inFile.close()
    if dimension == 2:
        size += [0]
    outFile = open(outPath, 'wb')
    for i, line in enumerate(lineList):
        if i == 1:
            newline = line.lstrip(line.rstrip('\n'))
            line = 'lddmm 8 0 0 {0} {0} 0 0 {1} {1} 0 0 {2} {2}'.format(
                size[2] - 1, size[1] - 1, size[0] - 1) + newline
        outFile.write(line)
