Handle package sknw in python - python

Is there any official documentation for building graphes associated to skeletons of images in python in the SKNW package? I found this package that I've installed, however, since I'm new in python, it's not easy for me to handle the latter: https://github.com/yxdragon/sknw .

Thanks for using sknw:
just load your 2d/3d image, you can use skimage.morphology.skeletonize_3d(img) to get a 3d skeleton from volume data.
graph = sknw.build_sknw(skeļ¼Œ multi=False) to got the skeleton structure, which is a networkx object.
do your analysis
graph.node[id]['pts'] : Numpy(x, n), coordinates of nodes points
graph.node[id]['o']: Numpy(n), centried of the node
graph.edge(id1, id2)['pts']: Numpy(x, n), sequence of the edge point
graph.edge(id1, id2)['weight']: float, length of this edge
and you can do some graph analysis use networkx.
I think you would be intrested in my another project ImagePy, which you can do many image processing operation in a UI framework, just like imagej

Related

Import mesh in python

I'm trying to import a mesh as vertices and faces (connectivity list) in python. Possibly supporting mixed tri/quad meshes.
I don't have any particular requirement on the format of the mesh, as from the CAD software (Rhino) I can export several different formats, including *.stl, *.obj, *.fbx, etc.
I tried different packages as numpy-stl, trimesh, pymesh, but couldn't find any one working. Some of these are completely bugged, other does not allow you (or I couldn't find how) generate the connectivity list.
Is there any package for python that allows to do so?

Plot vertex as image in Igraph

I'm wondering if it is possible to plot a vertex as image (loaded from a file or directly) in Igraph. Any ideas?
This is definitley possible in the R version of iGraph using the raster function, however a brief search did not reveal any implementation of this function in Python (it's not in the igraph documentation anyway).
If this is essential to your work, then I would consider switching to R, or possibly another tool such as Gephi. For Python, however, you might consider using something like pyvis. This package is small but powerful in terms of visualization. I've been playing around with it over the past few days and its very easy to display a graph with pictures as nodes, and it comes with the added benefit of providing interactive functioning. Take a look at the tutorial here, which will highlight what this package can provide.

Generating Network graph in python

I am trying to generate a network graph for 200+ nodes and 300+ edges using networkx using python from a file. I was able to generate and plot the graph using matplotlib in my Juypter Notebook, but its not looking good and nodes are so tightly packed.
Is there any other python package help to generate network graph ??.
My aim is to generate graph for whole data set so that I can find dependency between nodes.
If nodes being too close together is the issue, try using the draw_spring()function of networkx.
https://networkx.github.io/documentation/networkx-2.0/reference/generated/networkx.drawing.nx_pylab.draw_spring.html#networkx.drawing.nx_pylab.draw_spring
It simulates what would happen if each edge were a spring and the network were picked up and spun around, seperating the nodes, especially the ones which are not connected via many paths.
If this does not work initially, you can use the parameters of the function that draw_spring() wraps, the spring_layout() function. Try adjusting the k value parameter. This should allow you to manipulate the rough distance between nodes.
https://networkx.github.io/documentation/networkx-2.0/reference/generated/networkx.drawing.layout.spring_layout.html#networkx.drawing.layout.spring_layout
Alternatively, there are additional draw functions you might find more useful than draw_spring(). You can find them in the draw section here: https://networkx.github.io/documentation/networkx-2.0/reference/drawing.html
I can recommend using Netwulf. Input a networkx.Graph object to netwulf.visualize, and launch the visualization in a new browser window. The result and data can be posted back to Python.
Disclaimer: I co-author Netwulf.

Artificially incorporate non-rigid motions in Images for generating data using Python/Matlab

The main challenges in Medical Imaging is Data acquisition. There are different types of motions (Rigid & Non Rigid) possible during acquitions(Body movement,breathing etc).
Suppose I want to generate different types of motion artificially in an Image(eg. 3D NIFTI MRI image).
Motions can be global rigid motions or elastic deformation or bspline based local deformations. Input will be an 3D image and output will be a newly generated data incorporated the desired motion.
I was wondering if there is any package or software available to do this, but didn't find any. Using this type of feature we can validate our registration methods or simulate different deformation models.
I want some help in generating such artificial data using python or matlab for NIFTI/DICOM 3D images.
Within Python, there are a couple options. The first is using the pydicom module for I/O along with numpy to represent/process the layers. In order to use this, you may additionally have to use matplotlib, scipy/scikit-image, or Pillow to visualize the input and generated output.
However there is also VTK, which comes with both a Python interface and a DICOM reader/writer. Using vtkpython will allow you to create a fairly simple application for viewing and interacting with the data. For generating the motion layers, I think numpy may still be the best option with this route.
This page has a good introduction to using both of these methods: https://pyscience.wordpress.com/2014/09/08/dicom-in-python-importing-medical-image-data-into-numpy-with-pydicom-and-vtk/

Tool to create a python GUI for graph construction

I need to create a GUI for graph construction ("graph" as an abstract representation of a set of objects, not a visual representation of data). The interface will provide a choice of ~5 vertex types and of ~5 edge types. Each vertex will have two data fields: a text label and a file name, which need to be easily editable.
I'm familiar with igraph and have a lot of code written in it. I will use igraph to manipulate the graphs created with this GUI.
Since this will be my first GUI, I'm completely ignorant of what tools are available. Can you please suggest a free library, knowing that eventually the program will need to work on Windows?
EDIT
it seems from the answers I get that I wasn't clear enough. I'm not looking for a way to visualize a graph, but rather for a way to visually create one. By visually, I mean not needing to manually create text files or writing code.
Take a look at xdot.py.
From the homepage
xdot.py is an interactive viewer for graphs written in Graphviz's
dot language.
It uses internally the graphviz's xdot output format as an
intermediate format, and PyGTK and Cairo for rendering.
xdot.py can be used either as a standalone application from
command line, or as a library embedded in your python application.
I like networkx,
from networkx import draw, Graph
from pylab import show
g = Graph()
g.add_edges_from([(1,2),(1,3),(2,4),(2,5)])
draw(g)
show()
which gives,
The only quirk is the requirement for matplotlib to get builtin plotting to work.
If you use python, I think PyQt is a good selection.
What you have to install is listed below:
install Python from here
install PyQt4 from here
But it takes many lines to write GUI application,
it is sometimes better to generate an image to display with image viewer.

Categories

Resources