Add output generation for histograms.
This commit is contained in:
parent
26c823fa9b
commit
f220a4470d
1 changed files with 19 additions and 1 deletions
|
@ -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")
|
f.write("P0 - x, P0 - y, P0 - z, P1 - x, P1 - y, P1 - z, diameter")
|
||||||
|
|
||||||
for _, _, branch in skeleton.skeleton_branch_iter():
|
for _, _, branch in skeleton.skeleton_branch_iter():
|
||||||
|
print ('length', branch.length)
|
||||||
for idx, p1 in enumerate(branch.points):
|
for idx, p1 in enumerate(branch.points):
|
||||||
if idx > 0:
|
if idx > 0:
|
||||||
p0 = branch.points[idx-1]
|
p0 = branch.points[idx-1]
|
||||||
|
@ -111,6 +112,21 @@ def skeleton_to_csv(skeleton, output_path):
|
||||||
p1_s = str(p1.x) + "," + str(p1.y) + "," + str(p1.z)
|
p1_s = str(p1.x) + "," + str(p1.y) + "," + str(p1.z)
|
||||||
f.write(p0_s + "," + p1_s + "," + str(branch.diameter) + "\n")
|
f.write(p0_s + "," + p1_s + "," + str(branch.diameter) + "\n")
|
||||||
f.close()
|
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__":
|
if __name__ == "__main__":
|
||||||
|
@ -129,8 +145,10 @@ if __name__ == "__main__":
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
skeleton = load_skeleton(args.input)
|
skeleton = load_skeleton(args.input)
|
||||||
|
print(skeleton.pix_dim)
|
||||||
if "csv" in args.format:
|
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:
|
elif "mat" in args.format:
|
||||||
skeleton_to_matlab(skeleton, args.field, args.output)
|
skeleton_to_matlab(skeleton, args.field, args.output)
|
||||||
|
|
Loading…
Reference in a new issue