A python package for the extraction and analysis of graphs from 2D and 3D experimental micrographs. Image processing techniques taken from StructuralGT. StructuralGT is available as an API-based or GUI-based package. Use conda-forge or the main GitHub branch for the API version, and the GUI branch for the GUI version.
StructuralGT (API version only) is available on conda-forge for the linux-64, osx-64, and win-64 platforms. Install with
conda install conda-forge::structuralgtStructuralGT can also be built from source via the public repository. Prior to install, you will need to install some dependencies into your conda environment. Note that installation will most likely be successful if carried out in a new conda environment. While it is posisble to obtain some of these dependencies with pip, installation is most likely to be sucessful when all dependencies are obtained with conda.
git clone https://github.com/compass-stc/StructuralGT.git
conda install -c conda-forge numpy scipy scikit-image matplotlib networkx opencv pandas gsd python-igraph pytest ipywidgets freud eigen cython igraph
cd StructuralGT
python3 setup.py build_ext
python3 -m pip install . --no-depsAlternatively, if building from source gives errors related to igraph, you can build a python-only version of StructuralGT that skips compiling some of the C modules used for fast calculations (AverageNodalConnectivity and Betweenness).
git clone https://github.com/compass-stc/StructuralGT.git
conda install -c conda-forge numpy scipy scikit-image matplotlib networkx opencv pandas gsd python-igraph pytest ipywidgets freud igraph cython eigen
cd StructuralGT
export C_FLAG=FALSE
python3 -m pip install . --no-depsYou can verify successful installation by installing pytest and running the included tests:
conda install pytest
pytestTo showcase the API, here is a simple example script used to predict the sheet resistance of silver nanowires, used in our recent publication :cite:`WuKadar2025`. To learn how to implement this yourself, consult our examples repository.
from StructuralGT.electronic import Electronic
from StructuralGT.networks import Network
agnwn_options = {"Thresh_method": 0, "gamma": 1.001, "md_filter": 0,
"g_blur":0, "autolvl": 0, "fg_color": 0, "laplacian": 0,
"scharr": 0, "sobel": 0, "lowpass": 0, "asize": 3,
"bsize": 1, "wsize": 1, "thresh": 128.0}
AgNWN = Network('AgNWN')
AgNWN.binarize(options=agnwn_options)
AgNWN.img_to_skel()
AgNWN.set_graph(weight_type= ['FixedWidthConductance'])
width = AgNWN.image.shape[0]
elec_properties = Electronic()
elec_properties.compute(AgNWN, 0, 0, [[0,50],[width-50, width]])To extend the above examples to novel analysis in your own work, you should consult our documentation. You can also build the documentation from source, which requires the following dependencies:
You can install these dependencies using conda:
conda install -c conda-forge sphinx furo nbsphinx jupyter_sphinx sphinxcontrib-bibtexor pip:
pip install sphinx sphinx-rtd-theme nbsphinx jupyter-sphinx sphinxcontrib-bibtexTo build the documentation, run the following commands in the source directory:
cd doc
make html
# Then open build/html/index.htmlor
sphinx-build -b html doc html