Skip to main content

Interactive toolkit for analyzing hair fiber morphology with GUI and CLI

Project description

Test PyPI version

fibermorph

Interactive toolkit for analyzing hair fiber morphology

fibermorph provides powerful image analysis tools for studying hair curvature and cross-sections, with both an intuitive graphical interface and a command-line interface for advanced users.

🚀 Quick Start with the GUI (Recommended)

The easiest way to use fibermorph is through the interactive web interface:

# Create a conda environment with Python 3.11
conda create -n fibermorph_env python=3.11
conda activate fibermorph_env

# Install fibermorph with the GUI
pip install "fibermorph[gui]"

# Launch the interactive GUI
fibermorph-gui

This opens an interactive web interface where you can:

  • 📤 Upload images: Single or multiple TIFF files, or provide a URL to download
  • 🔬 Choose analysis type: Curvature or Section analysis
  • ⚙️ Configure parameters: Adjust settings with interactive controls
  • 💾 Download results: Get CSV summary data and ZIP file with all analysis outputs

✨ Try it online: https://fibermorph.streamlit.app/

📦 Installation

Recommended: Conda + GUI

# Create environment (Python 3.10-3.12 supported)
conda create -n fibermorph_env python=3.11
conda activate fibermorph_env

# Install with GUI
pip install "fibermorph[gui]"

Alternative: pip with virtual environment

# Create virtual environment
python3.11 -m venv fibermorph_env

# Activate the environment
# On macOS/Linux:
source fibermorph_env/bin/activate
# On Windows:
fibermorph_env\Scripts\activate

# Install fibermorph with GUI
pip install "fibermorph[gui]"

Supported Python versions: 3.10, 3.11, 3.12. We recommend Python 3.11 for the best compatibility.

Note: Python 3.13 support is planned but not yet available due to dependency compatibility issues.

Optional extras

pip install "fibermorph[raw]"    # enable RAW image conversion via rawpy
pip install "fibermorph[viz]"    # install matplotlib-based visualization helpers
pip install "fibermorph[gui]"    # install Streamlit GUI (recommended!)

Extras can be combined, e.g. pip install "fibermorph[raw,viz,gui]".

🖥️ Command Line Interface (Advanced Users)

For automation, scripting, and batch processing, fibermorph provides a powerful CLI:

Quick test with demo data

fibermorph --demo_real_curv --output_directory ~/fibermorph_demo_curv
fibermorph --demo_real_section --output_directory ~/fibermorph_demo_section

Analyze your own data

Curvature analysis:

fibermorph --curvature \
  --input_directory /path/to/images \
  --output_directory /path/to/results \
  --resolution_mm 132 \
  --jobs 2

Section analysis:

fibermorph --section \
  --input_directory /path/to/images \
  --output_directory /path/to/results \
  --minsize 30 \
  --maxsize 180 \
  --resolution_mu 4.25 \
  --jobs 2

Install the package

  1. After having activated your new virtual environment, you can simply run pip install fibermorph. You can find the latest release here on this GitHub page and on the fibermorph PyPI page.
  2. You have successfully installed fibermorph. The package is now ready for use. Enter fibermorph -h or fibermorph --help to see all the flags. You can keep reading to try out the demos and read instructions on the various modules within the package.

Demo data

Before using this on any of your own data, it's recommended that you test that you test whether fibermorph is working properly on your machine. There are a few demo modules you can use to check whether fibermorph is running correctly.

Testing with real data

You can test both the curvature and section modules with real data that is downloaded automatically when you run the --demo_real modules.

In both cases, all you need to do is specify a folder path where the images and results can be created with ---output_directory or -o. This folder can be existing, but you can also establish a new folder by including it in the new path.

Both modules will download the demo data into a new folder tmpdata within the path you gave. Then, fibermorph will run the curvature or section analysis, and the results will be saved in a new folder results_cache at this same location. It is recommended that you specify a path with a new folder name to keep everything organized.

Testing curvature analysis

--demo_real_curv

This flag will run a demo of fibermorph curvature analysis with real data. You will need to provide a folder for the demo data to be downloaded.

To run the demo, you will input something like: fibermorph --demo_real_curv --output_directory /Users/<UserName>/<ExistingPath>/<NewFolderName

Testing section analysis

--demo_real_section

This flag will run a demo of fibermorph section analysis with real data. You will need to provide a folder for the demo data to be downloaded.

To run the demo, you will input something like: fibermorph --demo_real_section --output_directory /Users/<UserName>/<ExistingPath>/<NewFolderName

Curvature

To calculate curvature from grayscale TIFF images of hair fibers, the flag --curvature is used with the following flags in addition to input and output directories:

--resolution_mm       	Integer. Number of pixels per mm for
						curvature analysis.
						Default is 132.
--window_size  [ ...] 	Float or integer or None. Desired size for
						window of measurement
						for curvature analysis in pixels or mm (given
						the flag --window_unit). If nothing is entered, the default
						is None and the entire hair will be used to for the curve fitting."
--window_unit {px,mm}	String. Unit of measurement for window of
						measurement for curvature
                      	analysis. Can be 'px' (pixels) or 'mm'. Default is 'px'.
-W, --within_element  	Boolean. Default is False. Will create
						an additional directory with
                      	spreadsheets of raw curvature measurements for each hair if the
                      	--within_element flag is included.
-s, --save_image      	Default is False. Will save intermediate
						curvature/section processing images if
						--save_image flag is included.

So, to run a curvature analysis, you would enter e.g.

fibermorph --curvature --input_directory /Users/<UserName>/<ImageFolderPath> --output_directory /Users/<UserName>/<ExistingPath>/ --window_size 0.5 --window_unit mm --resolution_mm 132 --save_image --within_element --jobs 2

Section

To calculate cross-sectional properties from grayscale TIFF images of hair fibers, the flag --section is used with the following flags:

--resolution_mu       Float. Number of pixels per micron for section analysis. Default is 4.25.
--minsize             Integer. Minimum diameter in microns for sections. Default is 20.
--maxsize             Integer. Maximum diameter in microns for sections. Default is 150.

An example command would be:

fibermorph --section --input_directory /Users/<UserName>/<ImageFolderPath> --output_directory /Users/<UserName>/<ExistingPath>/ --minsize 20 --maxsize 150 --resolution_mu 4.25 --jobs 2

Converting raw images to grayscale TIFF

This package features an additional auxiliary module to convert raw images to grayscale TIFF files if necessary: --raw2gray

In addition to the input and output directories, the module needs the user to specify what file extension it should be looking for.

--file_extension      Optional. String. Extension of input files to use in input_directory when
                      using raw2gray function. Default is .RW2.

A user could enter, for example:

fibermorph --raw2gray --input_directory /Users/<UserName>/<ImageFolderPath> --output_directory /Users/<UserName>/<ExistingPath>/<NewFolderName> --file_extension .RW2 --jobs 4

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fibermorph-1.0.1.tar.gz (110.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fibermorph-1.0.1-py3-none-any.whl (123.8 kB view details)

Uploaded Python 3

File details

Details for the file fibermorph-1.0.1.tar.gz.

File metadata

  • Download URL: fibermorph-1.0.1.tar.gz
  • Upload date:
  • Size: 110.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fibermorph-1.0.1.tar.gz
Algorithm Hash digest
SHA256 7c7cee959abaca8cade389f98791b7b220be58be7140a6f8d5e09b0683ee9285
MD5 acc04a1d774b1f21d891038896f5ab75
BLAKE2b-256 9785862269a1a069fff7a633f0fa65638d89b649036cdb2eeea9f398f9bb7316

See more details on using hashes here.

Provenance

The following attestation bundles were made for fibermorph-1.0.1.tar.gz:

Publisher: publish.yml on lasisilab/fibermorph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fibermorph-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: fibermorph-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 123.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fibermorph-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c659867ede8656d0b0f04a5c4c5a0b8b209176703efe38a96042de35a44a1b17
MD5 ecec81fa2ce3a136418d4ef21ca46a14
BLAKE2b-256 446011bccec361a1cf780943ced75c308e0fd3e89ad051f0f083f34359093d68

See more details on using hashes here.

Provenance

The following attestation bundles were made for fibermorph-1.0.1-py3-none-any.whl:

Publisher: publish.yml on lasisilab/fibermorph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page