def write_tvl_direction_pairs(tvl_filename, tvl_header, direction_pairs):
"""Write the given directions to TVL.
The direction pairs should be a list with lists containing the vector and value to write. For example:
((vec, val), (vec1, val1), ...) up to three pairs are allowed.
Args:
tvl_filename (str): the filename to write to
tvl_header (:class:`list` or tuple): the header for the TVL file. This is a list of either 4 or 10 entries.
4 entries: [version, res, gap, offset]
10 entries: [version, x_res, x_gap, x_offset, y_res, y_gap, y_offset, z_res, z_gap, z_offset]
direction_pairs (list of ndarrays): The list with direction pairs, only three are used.
This is a list with (vector, magnitude) tuples in which the vectors are 4d volumes with for
every voxel a 3d coordinate.
"""
direction_pairs = direction_pairs[0:3]
dir_matrix = np.zeros(direction_pairs[0][0].shape[0:3] + (12,))
for ind, dirs in enumerate(direction_pairs):
dir_matrix[..., ind*3:ind*3+3] = np.ascontiguousarray(TrackMark._ensure_3d(np.squeeze(dirs[0])))
dir_matrix[..., 9 + ind] = np.ascontiguousarray(TrackMark._ensure_3d(np.squeeze(dirs[1])))
TrackMark.write_tvl_matrix(tvl_filename, tvl_header, dir_matrix)
评论列表
文章目录