Description
Dear Seung lab:
I apologize for asking a question that may not be directly related to your expertise. Despite searching through numerous research papers on Google Scholar, I am still unable to complete my work. As a novice in learning Python for only two months, there are many foundational papers on skeletonization algorithms, but I am struggling to translate the concepts from the papers into actual code. Most skeletonization algorithms have been extended to fields like medicine and botany, but there are scarce Python libraries available to assist me in completing my work.
Here is my problem: I have included a screenshot of a commercial finite element software called "Abaqus". As you can see, this structure resembles a topology structure. Since this software is designed for computations, it does not provide various images like those available in medical instruments. Currently, using the Python interface of this software, I have written snippets of code to obtain the center coordinates of each voxel in this structure (in the software, each voxel has a fixed value, and it is a regular cube with equal length, width, and height). Additionally, I have obtained the size of the voxels (e.g., 30.). I have tried several Python libraries, most of which require images as input, while only a few accept numpy arrays. I have written some immature code to extract a binary array from these center coordinates, which would allow me to apply skeletonization algorithms using some Python libraries.
import numpy as np
def ske(mesh, x, y, z, openfile):
me = int(mesh)
# The total size of the canvas
depth = int(x//me)
height = int(y//me)
width = int(z//me)
# Create an empty array with the same size as voxel data
voxels = np.zeros((depth, height, width), dtype=np.uint8)
# Reading data source files (file: coord_26_cube.txt)
with open(openfile, 'r') as file:
# Read the coordinates line by line, convert them into integers, and store them in the center point list
centers = [tuple(map(int, line.split())) for line in file]
print(len(centers))
# Traverse each center point
for center in centers:
# Map the center point coordinates to the corresponding positions on voxel data
z = center[0] // me
y = center[2] // me
x = center[1] // me
# Set the corresponding voxel points to white
voxels[z, y, x] = 255
return voxels
v = ske(30, 90, 90, 90, 'coord_26point_cube.txt')
coord_26_cube.txt
Here, I have attached a simple test file that can demonstrate the effectiveness of my code under normal conditions. The file represents a 90x90x90 cube with voxel size 30. It has been subdivided into 27 parts, with one small cube removed, resulting in 26 remaining small cubes. The coordinates in the file represent the positions of the center points.
Although I achieved some good results in smaller libraries, my next step is to obtain the endpoints of these skeletons and accurately connect them. As many Python libraries only cover certain aspects of this task, I am unable to find a single library that provides the desired results. However, changing libraries poses the problem of inconsistent data formats. With limited time left until the final deadline, I cannot afford to spend more time trying each library one by one.
I sincerely hope that you can provide me with some assistance, even if it is just a little guidance or inspiration. To be honest, GitHub is one of the best communities I have come across, which is why I dare to ask you directly. Thank you for taking the time to read this lengthy passage. I truly appreciate your help.
Activity