Add output generation for histograms.

This commit is contained in:
jmsgrogan 2017-09-28 10:47:15 +01:00
parent 26c823fa9b
commit f220a4470d

View file

@ -104,6 +104,7 @@ def skeleton_to_csv(skeleton, output_path):
f.write("P0 - x, P0 - y, P0 - z, P1 - x, P1 - y, P1 - z, diameter")
for _, _, branch in skeleton.skeleton_branch_iter():
print ('length', branch.length)
for idx, p1 in enumerate(branch.points):
if idx > 0:
p0 = branch.points[idx-1]
@ -112,6 +113,21 @@ def skeleton_to_csv(skeleton, output_path):
f.write(p0_s + "," + p1_s + "," + str(branch.diameter) + "\n")
f.close()
def skeleton_lengths(skeleton, output_path):
"""
Convert the skeleton's network description to csv format
"""
# if os.path.isabs(output_path) and not os.path.exists(output_path):
# os.makedirs(output_path)
f = open(output_path, "w")
for _, _, branch in skeleton.skeleton_branch_iter():
f.write(str(branch.length) + "," + str(branch.diameter) + "\n")
f.close()
if __name__ == "__main__":
@ -129,8 +145,10 @@ if __name__ == "__main__":
args = parser.parse_args()
skeleton = load_skeleton(args.input)
print(skeleton.pix_dim)
if "csv" in args.format:
skeleton_to_csv(skeleton, args.output)
skeleton_lengths(skeleton, args.output)
#skeleton_to_csv(skeleton, args.output)
elif "mat" in args.format:
skeleton_to_matlab(skeleton, args.field, args.output)