Pore2Chip
Pore2Chip: All-in-one python tool for soil microstructure analysis and micromodel design - Published in JOSS (2025)
Science Score: 98.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 13 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org, zenodo.org -
○Academic email domains
-
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Scientific Fields
Repository
A python package that takes XCT images of porous materials and generates representative digital twin micromodels
Basic Info
- Host: GitHub
- Owner: EMSL-Computing
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://www.emsl.pnnl.gov/science/instruments-resources/terraforms-pore2chip
- Size: 32.2 MB
Statistics
- Stars: 8
- Watchers: 4
- Forks: 3
- Open Issues: 1
- Releases: 4
Topics
Metadata Files
README.md
Pore2Chip: All-in-One Python Tool for Soil Microstructure Analysis and Micromodel Design
What is Pore2Chip?
Pore2Chip is a Python module designed to streamline the process of analyzing X-ray computed tomography (XCT) images of soil and creating 2D micromodel designs based on that analysis. It leverages the power of open-source libraries like OpenPNM, PoreSpy, and drawsvg to extract key information about the soil's porous structure and translate it into a blueprint for microfluidic simulations or physical lab-on-a-chip devices developed using additive manufacturing.
Documentation Quick Link: https://emsl-computing.github.io/Pore2Chip/
A workflow for model-data-experiment (ModEx) design:
Below is a conceptual figure, workflow, and vision for this all-in-one Python tool. The working principle starts with XCT imaging files, which will be characterized for soil structure-property relationships and then transformed into a 2D rendering applicable to pore-scale micromodel building. Micromodel experiments will then be used with PFLOTRAN/OpenFOAM/PINNs process models to simulate flow and reactive transport for calibration and V&V.
ModEx for SoilChip: Lab-on-a-chip designs to accelerate ModEx workflows informed by soil datasets. Key Steps in the ModEx loop include:
(1) XCT Imaging of Soil Core and Aggregates (Pore2Chip): High-resolution X-ray computed tomography (XCT) imaging captures detailed 3D structures, providing a foundational understanding of the physical characteristics.
(2) 3D Pore Network Characterization (Pore2Chip): The 3D pore network is analyzed to determine pore size frequency and distribution, which is critical for understanding flow and transport properties.
(3) Transform 3D Pore Network into 2D Rendering (Pore2Chip): The complex 3D network is simplified into a 2D rendering for easier analysis and visualization.
(4) Build Micromodels for Experiments (Pore2Chip): Micromodels replicate environmental conditions, enabling controlled experiments to observe fluid flow and chemical species degradation.
(5) Microscale Experimental Data on Chemical Hotspots (Chip2Flow): Detailed experiments using techniques like ToF-SIMS and SEM-EDS provide data on chemical hotspots within the porous media.
(6a) Pore-Scale Multi-Physics Modeling (Chip2Flow): Simulations model fluid flow, heat transfer, and chemical reactions at the pore scale, which is needed to predict system behavior under different environmental conditions.
(6b) Calibration and Validation (Chip2Flow): Predictive AI/ML-enabled models are calibrated and validated using experimental data for accuracy and reliability.
(7a) Understanding Fluid Flow and Reactive-Transport in Soil Core Experiments (Chip2Flow): Experiments on soil cores provide vital information on fluid flow and chemical species degradation, connecting back to micromodel generation.
(7b) Upscaled Properties (Chip2Flow): Properties and behaviors observed at smaller scales are upscaled to larger scales (mm to cm) for real-world application.
Conclusion: The iterative ModEx loop continuously improves multi-physics process models through integration with experimental data, leading to more accurate predictions for system evolution and rhizosphere function applications. Additional specifics on extending this to Critical Minerals and Material (CMM) science applications is here Download the SoilTwin poster pdf

Capability summary: What the Pore2Chip module can do?
- Extract pore sizes and pore throat sizes
- Extract pore connectivity numbers
- Get miscellaneous pore information such as feret diameters
- Generate a micromodel design that is representative of input XCT soil data
- Export the design as an SVG file
- Export design as a DXF file (see DXF section)
Unveiling the Hidden World of Soil: Pore Structure Analysis
Pore2Chip empowers you to delve into the intricate details of soil microstructure by:
- Quantifying Pore Sizes and Throats: It precisely measures the size distribution of pores and pore throats within the soil sample. This information is crucial for understanding fluid flow properties and transport phenomena within the soil.
- Mapping Pore Connectivity: Pore2Chip calculates the number of connections between pores, providing valuable insights into how fluids can move through the soil network.
- Extracting Diverse Pore Metrics: In addition to size and connectivity, Pore2Chip can extract various other pore characteristics, such as feret diameters (the greatest distance a pore can span in a specific direction).
Bridging the Gap: From Soil Data to Microfluidic Designs
Pore2Chip goes beyond analysis by translating the extracted data into actionable outputs:
- Micromodel Design Generation: Based on the characterization of the soil's pore network, Pore2Chip generates a 2D blueprint that closely resembles the actual pore structure. This design serves as a foundation for microfluidic simulations or the fabrication of physical micromodels using Photolithography or Laser Etching.
- SVG File Export: The micromodel design is exported in a versatile SVG (Scalable Vector Graphics) format, ensuring compatibility with various simulation software and design tools.
- DXF Export (Optional): For users working with computer-aided design (CAD) programs, Pore2Chip can optionally export the design in DXF (Drawing Exchange Format) facilitating integration into CAD workflows (Note: DXF export functionality may require additional configuration).
In essence, Pore2Chip offers a comprehensive solution for researchers and engineers working with soil microstructures. It efficiently bridges the gap between XCT data and micromodel development, paving the way for a deeper understanding of soil behavior and the creation of advanced microfluidic devices for diverse applications.
Getting Started
Here is a link to the documentation hosted on Github Pages: https://emsl-computing.github.io/Pore2Chip/
The OpenPNM and PoreSpy libraries are required to analyze XCT images. PoreSpy is used to generate a pore network that is used to extract pore size distribution, pore throat size distribution, and pore coordination numbers. OpenPNM is used to construct a new 2D pore network that will be used to create the micromodel design.
Example input images can be found in the "beanbucket100" folder. Full dataset can be found here: https://github.com/EMSL-MONet/CommSciMtg_Nov23/
Install using PiP:
pip install pore2chip
Install from source:
git clone https://github.com/EMSL-Computing/Pore2Chip.git
cd Pore2Chip
python3 -m build
python3 -m pip install pore2chip --no-index --find-links dist/
...or alternatively:
git clone https://github.com/EMSL-Computing/Pore2Chip.git
python3 pip install -e ./Pore2Chip
Creating a Conda environment:
conda create -n pore2chip python=3.9
conda activate pore2chip
pip install pore2chip
Building a Docker Image with Jupyter Notebook:
git clone https://github.com/EMSL-Computing/Pore2Chip.git
cd Pore2Chip
docker build -t pore2chip
docker run -p 8888:8888 pore2chip
This should output URLs that you can copy and paste into a browser so that you can access the Jupyter Notebook server.
Example Usage
In the following examples, pore and throat diameters as well as coordination numbers are hard coded values. These values can be extracted from XCT images using the metrics library.
```
from pore2chip import generate, export
Shape of the micromodel (number of pores n x n).
n = 5
Random values for pore, throat diameters and coordination numbers. Can be any length.
arrpore = [4.0, 9.0, 4.5, 8.4, 14.0, 7.6, 5.0] arrthroat = [7.0, 5.5, 3.5, 1.4, 5.8, 4.3, 8.8, 8.4, 4.0] arr_coord = list(range(0, 4))
network = generate.generatenetwork(n, n, arrpore, arrthroat, arrcoord)
design = export.network2svg(network, n, n, 100, 100)
design.save_svg('network.svg')
```
This package can also generate images without throats and simulate "pores" as "grain" particulates. ``` from pore2chip import generate, export
Shape of the micromodel (number of "grains" n x n).
n = 5
Random values for pore, throat diameters and coordination numbers. Can be any length.
arr_grain = [4.0, 3.0, 4.5, 2.4, 14.0, 7.6, 5.0]
network = generate.generatenetwork(n, n, arrgrain, None, None)
design = export.network2svg(network, n, n, 100, 100)
design.savesvg('grainnetwork.svg')
```
Converting to PNG
There are many ways to convert an SVG image to a rasterized image format using only Python, such as rendering it usingCairoSVG.
The recommended way to do this is to use svglib and reportlab. NOTE: reportlab>=4.0.0 requires pycairo, and by extension, the cairo library, which cannot be installed by PiP by itself. If you are using Windows, it is recommended to install reportlab=3.6.13.
```
from svglib.svglib import svg2rlg
from reportlab.graphics import renderPM
rldrawing = svg2rlg('network.svg') renderPM.drawToFile(rldrawing, 'network.png', fmt='PNG') ```
Micromodel design -- Getting an STL from the SVG for additive manufacturing
This is a generalized workflow for getting an SVG to an STL file:
- Generate the svg using Pore2Chip
- Use a vector image program such as Inkscape to combine all paths into one path. In Inkscape, this would be
Paths -> Union - Export the new image as a .DXF file
- Import the DXF file into the CAD software of your choosing, such as FreeCAD
- Extrude the shape of the pores and use it as a negative to create the micromodel
- Export to STL
Example result in Solidworks:
There are many other methods to print the micromodel design onto physical materials. Another example of fabricating lab-on-chip micromodels is using the design to etch it on a surface. Example:

This laser etching functionality is available at EMSL. Please contact us for more information as you develop these micromodels for fabrication.
It is highly recommended to try the Python library svglob to combine SVG paths without using an external program:
https://github.com/deckar01/svglob/tree/master
Alternatively, stl_tools can be used to turn a rasterized image into an STL:
https://github.com/thearn/stl_tools
DXF Exporting
While the export module can export a DXF file, it can only create pores as circles. It is recommended to export the micromodel as an SVG file and make desired adjustments to it.
This way, you have more control over the shape and can then convert the SVG to a DXF file.
VTK Exporting
Download ParaView software for VTK file visualization: Viz software download. The dataset for visualizing Pore2Chip VTK files is available at . For more information related to the Pore2Chip VTK file outputs, see
src/pore2chip/io.py. Also, please refer to the following links for additional details on file formats:
* VTK File Formats Documentation or
* VTK File Format User Guide
For EMSL Tahoma Users
To use the library with Tahoma Open OnDemand: 1. Start a Jupyter Notebook instance in the EMSL OnDemand dashboard 2. Create a Python virtual environment in the terminal 3. Install Pore2Chip in the virtual environment 4. In Jupyter Notebook, set your kernel to your python environment
For more information, see user guide for EMSL Open OnDemand
Known Issues
- The coordination algorithm may create pores of coordination of 1, despite the given coordination list not having 1's. This is being worked on.
Work-in-progress
- The ability to import and export pore networks in CSV or VTK file formats needed for multi-physics process modeling (e.g., using PFLOTRAN)
- Physics-informed machine learning needed for flow, thermal, and reactive-transport modeling (e.g., advanced physics-informed neural networks, operator learning methods)
- Meshfiles needed for CFD modeling (e.g., using OpenFOAM)
- GUI for the Docker container
Within the Pore2Chip platform
Our team is developing advanced modeling techniques to simulate complex multi-physics phenomena numerically. These numerical simulations are essential for understanding and predicting fluid flow behavior, chemical species degradation, and nutrient intake within the micromodels for reactive-transport applications.
The micromodels generated by Pore2Chip can be meshed for multi-physics simulations to understand flow and reactive-transport modeling better. Here, we show a structured mesh capability (see ) that can be generated for PFLOTRAN-based multi-physics modeling. The mesh is a grid of points to solve fluid flow and reactive transport within the lab-on-chip.
Key modeling capabilities that we are developing include
Physics-Informed Neural Networks: Deep neural networks integrate physical laws with data, enhancing machine learning models' predictive accuracy and reliability.
PFLOTRAN Input Decks: PFLOTRAN (see PFLOTRAN Documentation) is a massively parallel subsurface flow and reactive transport code. It simulates the movement of fluids and the transport of chemical species in this porous micromodel.
CFD Simulations: Computational Fluid Dynamics (CFD) simulations are utilized to simulate fluid flow within the micromodel, providing insights into the dynamics of fluid movement and interaction with the solid matrix.
Example Jupyter notebooks (basic and advanced usage):
- Example-1: Micromodel Creation from 50 x 50 XCT Data
- Example-2: Micromodel Creation from 100 x 100 XCT Data
- Example-3: Micromodel Pore Stats Using PoreSpy
- Example-4: Flow and transport simulations on micromodels using PoresPy
- Example-5: VTK exports for visualization of micromodel in Paraview
- Example-6: Finite Difference Method (FDM) Numerical Simulation of 2D Steady-State Flow on XCT images
- Example-7: 2D Steady-State Flow on XCT image with Physics-informed Neural Network (PINN)
Video recordings:
Below are some video links explaining Pore2Chip functionalities: * EMSL LEARN Webinar Series * Video on YouTube
Authors
- Aramy Truong (lead developer), EMSL (aramy.truong@pnnl.gov)
- Maruti Mudunuru (co-lead developer), PNNL (maruti@pnnl.gov)
- Erin Rooney, USDA (erin.rooney@usda.gov)
- Arunima Bhattacharjee, EMSL (arunimab@pnnl.gov)
- Tamas Varga, EMSL (tamas.varga@pnnl.gov)
- Lal Mamud (developer), PNNL (lal.mamud@pnnl.gov)
- Xiaoliang (Bryan) He, PNNL (xiaoliang.he@pnnl.gov)
- Anil Krishna Battu, EMSL (anilkrishna.battu@pnnl.gov)
- Satish Karra, EMSL (karra@pnnl.gov)
Development and questions
We welcome your contributions to Pore2Chip! This includes bug reports, bug fixes, improvements to the documentation, feature enhancements, and new ideas.
Copyright Guidelines:
To ensure the project's overall licensing remains compatible, please keep the following in mind:
- Datasets: Avoid including datasets with restricted licenses that don't allow free use or modification. These can create conflicts with the project's license.
- Code snippets: Avoid using code snippets with restricted licenses that don't allow free use or modification.
Contributing to Pore2Chip:
We appreciate all contributions, big or small! Here's how to get involved:
- Fork the repository and create a pull request: This is the preferred method for contributing code changes.
- Formatting the code using yapf:
yapf -i --style=pep8 <my_code>.py
or if you edit multiple files, you can do the following:
yapf -i --style=pep8 --recursive .
- Contact Aramy Truong (aramy.truong@pnnl.gov) and/or Maruti Mudunuru (maruti@pnnl.gov): If you have questions or need help getting started.
Additionally, your contributions can be as simple as:
- Fixing typos
- Implementing a new feature calculator
- Developing a novel feature selection process
No matter your skill level, your help is valuable!
Directory structure for contribution
tree -L 2 . >> tree.txt
``` . ├── CITATION.cff ├── DISCLAIMER.md ├── docs │ ├── make.bat │ ├── Makefile │ └── source ├── exampleoutputs │ ├── cadmockup.PNG │ ├── cadmockup2.PNG │ ├── fabricatedchip.jpg │ ├── flow │ ├── grainnetwork.png │ ├── grainnetwork.svg │ ├── micromodel.npy │ ├── ModExLoopSoilChip.jpg │ ├── networkfromvalues.svg │ ├── network.dxf │ ├── network.png │ ├── network.svg │ ├── network1.png │ ├── network1.svg │ ├── network2.png │ ├── network2.svg │ └── README.md ├── examples │ ├── beanbucket100 │ ├── example150x50tomodel.ipynb │ ├── example2100x100tomodel.ipynb │ ├── example3modelproperties.ipynb │ ├── example4porespyanalysis.ipynb │ ├── example5vtkexporting.ipynb │ ├── example6flow2dnumericalonXCT.ipynb │ ├── example7flow2dpinnonXCT.ipynb │ └── README.md ├── LICENSE.md ├── paper │ ├── figures │ ├── material │ ├── paper.bib │ └── paper.md ├── pyproject.toml ├── README.md ├── requirements.txt ├── src │ ├── flow │ ├── pore2chip │ └── README.md ├── tahoma.sh ├── tests │ ├── README.md │ ├── testcoordination.py │ ├── testexport.py │ ├── testfilterim.py │ ├── testflow.py │ ├── testgenerate.py │ ├── testmetrics.py │ └── testtrainpinn.py └── tree.txt
14 directories, 45 files ```
Acknowledgements
This research was performed on a project award (Award DOIs: 10.46936/ltds.proj.2024.61069/60012423; 10.46936/intm.proj.2023.60674/60008777; 10.46936/intm.proj.2023.60904/60008965) from the Environmental Molecular Sciences Laboratory, a DOE Office of Science User Facility sponsored by the Biological and Environmental Research program under contract no. DE-AC05-76RL01830. The authors acknowledge the contributions of Michael Perkins and Ben Watson at PNNL’s Creative Services, who developed the conceptual graphics in this paper.
PNNL-SA-197910
Disclaimer
This research work was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor any agency thereof, nor any of their employees, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or any agency thereof. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or any agency thereof.
Owner
- Name: EMSL Computing
- Login: EMSL-Computing
- Kind: organization
- Repositories: 16
- Profile: https://github.com/EMSL-Computing
JOSS Publication
Pore2Chip: All-in-one python tool for soil microstructure analysis and micromodel design
Authors
Environmental Molecular Sciences Laboratory (EMSL), Pacific Northwest National Laboratory, Richland, WA, USA
Environmental Molecular Sciences Laboratory (EMSL), Pacific Northwest National Laboratory, Richland, WA, USA
Environmental Molecular Sciences Laboratory (EMSL), Pacific Northwest National Laboratory, Richland, WA, USA
Tags
Micromodel design Model-data-experiment Visualization porous-media flow data-analysisCitation (CITATION.cff)
cff-version: "1.2.0"
authors:
- family-names: Truong
given-names: Aramy
orcid: "https://orcid.org/0009-0002-7467-7957"
- family-names: Mudunuru
given-names: Maruti K.
orcid: "https://orcid.org/0000-0002-2158-7723"
- family-names: Rooney
given-names: Erin C.
orcid: "https://orcid.org/0000-0002-9121-7699"
- family-names: Bhattacharjee
given-names: Arunima
orcid: "https://orcid.org/0000-0001-7482-8722"
- family-names: Varga
given-names: Tamas
orcid: "https://orcid.org/0000-0002-5492-866X"
- family-names: Mamud
given-names: Md Lal
orcid: "https://orcid.org/0000-0002-5764-1058"
- family-names: He
given-names: Xiaoliang
orcid: "https://orcid.org/0000-0003-3835-1917"
- family-names: Battu
given-names: Anil K.
orcid: "https://orcid.org/0000-0001-7724-5100"
- family-names: Karra
given-names: Satish
orcid: "https://orcid.org/0000-0001-7847-6293"
contact:
- family-names: Truong
given-names: Aramy
orcid: "https://orcid.org/0009-0002-7467-7957"
- family-names: Mudunuru
given-names: Maruti K.
orcid: "https://orcid.org/0000-0002-2158-7723"
doi: 10.5281/zenodo.16903861
message: If you use this software, please cite our article in the
Journal of Open Source Software.
preferred-citation:
authors:
- family-names: Truong
given-names: Aramy
orcid: "https://orcid.org/0009-0002-7467-7957"
- family-names: Mudunuru
given-names: Maruti K.
orcid: "https://orcid.org/0000-0002-2158-7723"
- family-names: Rooney
given-names: Erin C.
orcid: "https://orcid.org/0000-0002-9121-7699"
- family-names: Bhattacharjee
given-names: Arunima
orcid: "https://orcid.org/0000-0001-7482-8722"
- family-names: Varga
given-names: Tamas
orcid: "https://orcid.org/0000-0002-5492-866X"
- family-names: Mamud
given-names: Md Lal
orcid: "https://orcid.org/0000-0002-5764-1058"
- family-names: He
given-names: Xiaoliang
orcid: "https://orcid.org/0000-0003-3835-1917"
- family-names: Battu
given-names: Anil K.
orcid: "https://orcid.org/0000-0001-7724-5100"
- family-names: Karra
given-names: Satish
orcid: "https://orcid.org/0000-0001-7847-6293"
date-published: 2025-08-29
doi: 10.21105/joss.08052
issn: 2475-9066
issue: 112
journal: Journal of Open Source Software
publisher:
name: Open Journals
start: 8052
title: "Pore2Chip: All-in-one python tool for soil microstructure
analysis and micromodel design"
type: article
url: "https://joss.theoj.org/papers/10.21105/joss.08052"
volume: 10
title: "Pore2Chip: All-in-one python tool for soil microstructure
analysis and micromodel design"
GitHub Events
Total
- Create event: 11
- Issues event: 11
- Release event: 3
- Watch event: 5
- Delete event: 10
- Issue comment event: 14
- Push event: 86
- Pull request review comment event: 2
- Pull request review event: 3
- Pull request event: 22
- Fork event: 3
Last Year
- Create event: 11
- Issues event: 11
- Release event: 3
- Watch event: 5
- Delete event: 10
- Issue comment event: 14
- Push event: 86
- Pull request review comment event: 2
- Pull request review event: 3
- Pull request event: 22
- Fork event: 3
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 8
- Total pull requests: 12
- Average time to close issues: N/A
- Average time to close pull requests: 7 minutes
- Total issue authors: 2
- Total pull request authors: 2
- Average comments per issue: 0.0
- Average comments per pull request: 0.0
- Merged pull requests: 10
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 8
- Pull requests: 12
- Average time to close issues: N/A
- Average time to close pull requests: 7 minutes
- Issue authors: 2
- Pull request authors: 2
- Average comments per issue: 0.0
- Average comments per pull request: 0.0
- Merged pull requests: 10
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- jgostick (6)
- aramyxt (2)
Pull Request Authors
- aramyxt (6)
- maruti-iitm (6)
- mlmamud (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 122 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 4
- Total maintainers: 1
pypi.org: pore2chip
A package that takes 3D images of porous materials and generates representative micromodels
- Homepage: https://www.emsl.pnnl.gov/science/instruments-resources/terraforms-pore2chip
- Documentation: https://pore2chip.readthedocs.io/
- License: mit
-
Latest release: 0.2.0
published 4 months ago
Rankings
Maintainers (1)
Dependencies
- cairosvg *
- drawsvg *
- ezdxf *
- feret *
- gstools *
- jax *
- jaxlib *
- matplotlib *
- numpy *
- opencv-python *
- openpnm *
- optax *
- porespy *
- pypardiso *
- reportlab *
- scikit-image *
- scipy *
- svglib *
- yapf *
- actions/checkout v4 composite
- actions/upload-artifact v4 composite
- openjournals/openjournals-draft-action master composite