Fyron is an open-source Python toolkit for interoperable healthcare data and AI workflows. It provides unified access to FHIR data via REST APIs and relational (SQL-backed) FHIR servers, integrates DICOM imaging sources, and enables semantic exploration of clinical narratives using modern language models.
Project description
Fyron
Fyron is a pragmatic Python toolkit for interoperable healthcare data and AI workflows. It provides clean, testable primitives for FHIR, DICOM, imaging, documents, cohort construction, survival analysis, tabular machine learning, LLM-assisted analysis, and BOA visualization.
Full documentation lives at bitsandflames.github.io/fyron.
Install
uv add fyron
Useful extras:
| Extra | Install | Adds |
|---|---|---|
| Excel | uv add "fyron[excel]" |
Excel read/write via openpyxl |
| Survival | uv add "fyron[survival]" |
KM, RMST, Cox, Weibull AFT |
| Survival ML | uv add "fyron[survival-ml]" |
Gradient survival boosting via scikit-survival |
| ML | uv add "fyron[ml]" |
Random Forest, XGBoost, metrics, plots |
| Boruta | uv add "fyron[ml,boruta]" |
Boruta feature selection |
| Visualization | uv add "fyron[visualization]" |
BOA segmentation collages |
For a broad local analysis environment:
uv add "fyron[survival,survival-ml,ml,visualization,excel]"
Quick Examples
Console Easter Egg
Fyron keeps normal imports and CLI jobs quiet. The banner is opt-in:
fyron spark
fyron banner --theme mono --no-version
FHIR Query
from fyron import FHIRRestClient
client = FHIRRestClient("https://hapi.fhir.org/baseR4")
patients = client.search_df("Patient", params={"_count": 10}, max_pages=1)
patients.head()
Cohort Table
from fyron.cohort import build_survival_columns, validate_cohort_table
cohort = build_survival_columns(
cohort,
start_col="diagnosis_date",
end_col="last_followup_or_event_date",
event_col="event",
)
validate_cohort_table(cohort, required_columns=["patient_id", "time", "event"])
Survival Analysis
from fyron.survival import plot_kaplan_meier, fit_multivariate_cox
plot_kaplan_meier(
cohort,
duration_col="time",
event_col="event",
group_col="treatment_group",
at_risk_counts=True,
)
cox = fit_multivariate_cox(
cohort,
duration_col="time",
event_col="event",
covariates=["age", "stage", "risk_score"],
)
Tabular ML
from fyron import ml
result = ml.run_classification_pipeline(
X,
y,
model="random_forest",
n_estimators=300,
random_state=42,
plot=True,
)
result["metrics"]
Clinical Plots
from fyron import ml
fig_corr, _, corr = ml.plot_correlation_heatmap(X, method="spearman")
fig_metrics, _ = ml.plot_metric_bars({"Random Forest": result["metrics"]})
BOA Visualization
from fyron.visualization import create_boa_segmentation_collage
create_boa_segmentation_collage(
["/data/patient_a", "/data/patient_b"],
"boa_collage.png",
orientation="axial",
segmentation_layers=["body_regions", "tissues", "total"],
slice_fraction=0.5,
)
Modules
| Module | Purpose |
|---|---|
fyron.fhir |
FHIR REST, SQL, authentication, and resource utilities |
fyron.dicom |
DICOMweb download workflows |
fyron.imaging |
DICOM/NIfTI I/O and CT/MR normalization |
fyron.documents |
Authenticated document downloads |
fyron.llm |
LLM-assisted prompts over DataFrames and documents |
fyron.core |
Environment loading, local/S3 table I/O, JSON sidecars, Teable cohorts |
fyron.cohort |
Patient-level joins, validation, and survival columns |
fyron.survival |
KM, RMST, Cox, Weibull AFT, survival boosting |
fyron.ml |
Classification models, metrics, plots, feature selection |
fyron.boa_extraction |
BOA cohort feature extraction from measurement JSON and NIfTI masks |
fyron.visualization |
BOA segmentation collages |
See the module documentation for examples for every module.
Development
uv sync --all-extras --dev
uv run pytest
Preview documentation locally:
uv run python scripts/build_docs.py
uv run python -m http.server 8001 --directory site
GitHub Pages is built from the Markdown files in docs/ through the BF-native generator in scripts/build_docs.py. The Pages workflow publishes the generated site/ folder when changes land on main.
License
MIT. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fyron-0.2.3.tar.gz.
File metadata
- Download URL: fyron-0.2.3.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
585e8f6b9209b690bca7f6b699a9a78acf6f7332c14b0d3ac1a10074749e19e9
|
|
| MD5 |
6a9bd32a8a8a901f68a76e77082af234
|
|
| BLAKE2b-256 |
4e8234a6db17c02960f745df5678b74dee30996713ea5d29331ad73f7b5e8241
|
File details
Details for the file fyron-0.2.3-py3-none-any.whl.
File metadata
- Download URL: fyron-0.2.3-py3-none-any.whl
- Upload date:
- Size: 210.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e35eb45565ad06031b0161792f3474cf9555f1f54b971beda574dc66087646f
|
|
| MD5 |
9809fb92c8235d0c68bc90ebf3ed3d13
|
|
| BLAKE2b-256 |
2f16972dcda9502dc1a9cf8ca3d3b16260b69cefb4727b153e906b46e8521cfc
|