Skip to main content

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 Banner

Python License FHIR DICOM Survival ML Docs

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


Download files

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

Source Distribution

fyron-0.2.4.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

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

fyron-0.2.4-py3-none-any.whl (212.9 kB view details)

Uploaded Python 3

File details

Details for the file fyron-0.2.4.tar.gz.

File metadata

  • Download URL: fyron-0.2.4.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for fyron-0.2.4.tar.gz
Algorithm Hash digest
SHA256 1471bf817f56d06191acd040b3070d66a5bd6ba77f545372adfb90a78fb78329
MD5 84a514051c6ee3783de7355e7a331e82
BLAKE2b-256 3d3c344351da0bfa15f39988e9c64d0861b383144c3262544d1908b13b68f3f7

See more details on using hashes here.

File details

Details for the file fyron-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: fyron-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 212.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for fyron-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f2f571fb905e9b1e48247b3ac1e1493d71b3455ab1069d527b8597e36fef1b01
MD5 67cd9466f71309ace20d56bbc62c42ea
BLAKE2b-256 0e844d91ccc9c6f72399cc8ab3fafe52bb3095e76c58a5af0f536e28d346d221

See more details on using hashes here.

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