fabrictensor
fabrictensor is a Python library for estimating second- and fourth-order fabric tensors from three-dimensional binary micro-CT image stacks. Five independent stereological methods are implemented, each probing a distinct positive orientation measure on the unit sphere S².
Methods
| Key | Method | M2 | M4 PSD |
|---|---|---|---|
MIL |
Mean Intercept Length (Harrigan & Mann 1984) | approx. | projected |
SVD |
Star Volume Distribution | approx. | exact |
SKELETON |
Trabecular skeletonization | exact | exact |
INTERCEPTS |
Second moment of intercept length distribution | approx. | exact |
S2 |
Two-point correlation function via FFT | approx. | projected |
Installation
pip install fabrictensor
Or from source:
git clone https://github.com/salsessa/fabrictensor.git
cd fabrictensor
pip install -e .
Dependencies
numpy
scipy
scikit-image
Pillow
matplotlib
pydicom # only for DICOM input
Quick start
from fabrictensor import (
load_stack, threshold_stack,
centered_sphere_mask, icosahedral_directions, add_random_spin,
compute_intercept_moments_all,
fit_fabric_tensor, fit_fabric_tensor_M4_intercepts,
fabric_eigendecomposition, fabric_indices,
)
# Load a folder of TIFF slices
vol, _ = load_stack("path/to/rve/")
binary, thr, bvtv = threshold_stack(vol, method="otsu")
# Direction grid
mask = centered_sphere_mask(binary.shape)
dirs = add_random_spin(icosahedral_directions(subdivisions=3), seed=42)
# Compute M2 and M4 (INTERCEPTS method)
mil_vals, mil2_vals = compute_intercept_moments_all(
binary, mask, dirs, n_rays=5000, seed=42)
M2 = fit_fabric_tensor(dirs, mil_vals, method="MIL-H")
M4 = fit_fabric_tensor_M4_intercepts(dirs, mil2_vals)
ev, _ = fabric_eigendecomposition(M2)
print("M2 eigenvalues:", ev)
print("DA =", fabric_indices(ev)["DA"])
See the examples/ folder for complete annotated scripts, including
DICOM input (single multi-frame file and folder of single-frame slices)
and TIFF stacks (grayscale and binary).
Repository structure
fabrictensor/
├── fabrictensor.py # library (all public functions)
├── pyproject.toml
├── LICENSE
├── README.md
├── examples/
│ ├── template_fabrictensor.py # general-purpose template
│ ├── run_DCM_Palanca_et_al.py # multi-frame DICOM example
│ └── run_StereomTest.py # TIFF stack example
├── tests/
│ └── test_fabrictensor.py # 80-test suite (no external data)
└── data/
└── palanca/ # sample micro-CT data
└── ... # CC BY 4.0 Palanca et al. (2025)
Citation
If you use fabrictensor in your research, please cite:
Sessa, S. (in preparation). fabrictensor: a Python library for second- and fourth-order fabric tensor estimation from micro-CT images. SoftwareX. (manuscript submitted)
The theoretical framework implemented in this library is described in:
Sessa, S. (2026). Symmetry classes of linear elasticity induced by fabric tensors. (manuscript in press)
These entries will be updated with full bibliographic details (volume, pages, DOI) upon publication.
Sample data
The data/palanca/ folder contains a subset of the micro-CT dataset
published by Palanca et al. (2016) on figshare, distributed under
CC BY 4.0.
Palanca, M., Tozzi, G., Cristofolini, L., Dall'Ara, E. (2016). microCT scans of bone and cement-bone microstructures. figshare. Dataset. https://doi.org/10.6084/m9.figshare.4308926
The MIT License of fabrictensor does not apply to those files. See NOTICE and data/palanca/README.md for full attribution details.
License
fabrictensor is released under the MIT License.
Contact
Salvatore Sessa
Università degli Studi di Napoli Federico II
salvatore.sessa2@unina.it
https://github.com/salsessa/fabrictensor
Metadata
Release files for fabrictensor 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fabrictensor-1.0.2.tar.gz | 46.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fabrictensor-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 75.0 kB
Release files / fabrictensor-1.0.2.tar.gz
| Download URL | fabrictensor-1.0.2.tar.gz |
|---|---|
| Size | 46.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2fe1a554f7d1b2958a367305aada801fac1a3ce838773f7b8798913ede2ead43
|
|
BLAKE2b-256 checksum How to use checksums |
939f35c46c0b82627c7baf7d1e0af905693ede18c4a6624019390b9251c79114
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.3
|
Release files / fabrictensor-1.0.2-py3-none-any.whl
| Download URL | fabrictensor-1.0.2-py3-none-any.whl |
|---|---|
| Size | 28.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3cca562966f15610cc6cf60fac0dde853850f687666da71c5784f0709b2a4c37
|
|
BLAKE2b-256 checksum How to use checksums |
3cce73815c248af882725c7766275e898d1c45401256c9d9e1adc1a65da1914b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.3
|