Bits & Flames bitsandflames/fyron

Module Overview

Fyron is a set of small healthcare workflow modules. You do not need the whole package for every project. A FHIR integration can use only fyron.fhir; an imaging QC script can use only fyron.imaging; a clinical modeling project can use fyron.cohort, fyron.descriptive, fyron.survival, and fyron.ml.

Use this page to choose the right module from your task, input type, and expected output.

For a study-oriented path through cohort definition, validation, reporting, and provenance, start with the Clinical AI Study Workflow.

For runnable synthetic tutorials, see the Example Gallery. For citation, privacy, and research-use guidance, see Using Fyron In Research. For terminal workflows, see Unified CLI.

How To Think About Fyron

Most Fyron functions follow the same pattern:

ConceptMeaning
InputDataFrame, array, file path, FHIR JSON, DICOM/NIfTI file, or explicit parameter dictionary.
ParametersNamed clinical or technical assumptions such as duration_col, event_col, group_col, save_path, or max_pages.
OutputInspectable DataFrame, dict/dataclass, fitted model, Matplotlib figure, file path, or JSON manifest.
ResponsibilityFyron computes structured artifacts; the researcher still reviews clinical meaning.

Prefer explicit column names even when defaults match your table. A call with duration_col="time" and event_col="event" is easier to review than one that relies on hidden conventions.

Choose By Workflow Stage

StageTypical inputUseTypical output
Acquire FHIR resourcesFHIR REST endpointfyron.fhir.FHIRRestClientresource DataFrame
Query FHIR warehouseSQL-backed FHIR tablesfyron.fhir.FHIRSQLClientquery DataFrame
Build FHIR JSONreviewed DataFrame or measurementsfyron.fhir.builder, fyron.fhir.mappingFHIR resources/bundles
Download imagingStudy/Series Instance UIDsfyron.dicom.DICOMDownloaderDICOM/NIfTI files and result table
Read local imagingDICOM/NIfTI pathsfyron.imagingSimpleITK images, arrays, QC tables
Visualize aligned image differencesCT/MR volumesfyron.visualizationslice figure and difference summary table
Prepare training datasetsNIfTI, DICOM, PNG/JPG, box tablesfyron.datasetsnnU-Net v2 and YOLO folders
Extract BOA featuresBOA case foldersfyron.boa_extraction, fyron.boa_radiomicspatient-level feature DataFrame
Download reportsURLs or file tablefyron.documents.DocumentDownloaderdownloaded files and metadata
Store tabular dataCSV/Excel/JSON/S3/Teablefyron.coreDataFrames and storage metadata
Derive clinical table featuresICD-10/OPS/code/date columnsfyron.dataframeindicators, prevalence tables, interval columns
Build cohortsfeature and outcome tablesfyron.cohort, fyron.phenotypingpatient-level cohort
Prepare featurescohort tablefyron.preprocessingmissingness, imputation, encoding, leakage tables
Summarize cohortcohort tablefyron.descriptive, fyron.reportingTable 1, endpoint summary, flow table
Explain cohort filterssequential cohort DataFramesfyron.flowconsole summary, Markdown flow, flow table
Analyze endpointssurvival cohortfyron.survival, fyron.statisticssurvival curves, model tables, tests
Train classifiersfeature matrix and labelsfyron.mlmodel, predictions, metrics, figures
Select featuresX, yfyron.feature_selectionselected features and consensus tables
Validate modelslabels, probabilities, predictionsfyron.validationcalibration, thresholds, subgroup, DCA tables
Explain modelsfitted sklearn-style modelfyron.explainabilityimportance, PDP, SHAP-style tables
Publish artifactstables, metrics, imagesfyron.plotting, fyron.reporting, fyron.auditfigures, tables, manifests
Run repeatable jobsterminal parametersfyron CLICSV, JSON, DICOM, NIfTI, manifests

Choose By Question

If you need to...Start withThen consider
Pull Observations or Conditions from a live serverFHIR RESTFHIR Paths example
Avoid FHIR server result capssearch_df_partitioned in FHIR RESTsmaller date windows and deduplicate_by
Download CT series from a cohort CSVDICOMDownloaderImaging for QC
Compare two aligned CT/MR volumes visuallyBOA VisualizationImaging for explicit alignment and normalization
Build nnU-Net or YOLO training foldersDatasetsDataset Preparation example
Turn BOA outputs into a feature tableBOA ExtractionBOA Radiomics, BOA Visualization
Join baseline features and outcomesCohort TablesPreprocessing QC
Turn ICD, OPS, or date columns into featuresDataFrame OperationsPhenotyping, Cohort Tables
Create a manuscript Table 1Descriptive AnalysisReporting, Clinical Plotting
Explain inclusion/exclusion filtersFlow ExplainabilityReporting, Clinical Plotting
Plot survival by treatment or risk groupSurvival AnalysisClinical Plotting
Train a random forest or XGBoost modelMachine LearningValidation, Explainability
Record reproducibility metadataAudit & Provenancefyron audit-manifest CLI
Run the same step from terminal or schedulerUnified CLIJSON logs and --no-progress for batch systems
Choose colorblind-safe scientific figure palettesColors And StylesClinical Plotting

Common Data Shapes

ShapeModulesNotes
Long resource tablefhir, documentsOne row per resource, document, or extracted result.
Feature tableboa_extraction, imaging, phenotypingOne row per patient or analysis unit, feature columns wide.
Derived clinical feature tabledataframe, phenotypingRaw code/date columns plus explicit indicators, summaries, and intervals.
Cohort tablecohort, preprocessing, descriptive, survival, mlOne row per patient/analysis unit with endpoint and covariates.
Flow tableflow, reporting, plottingOrdered inclusion/exclusion steps with counts and reasons.
Feature matrix and labelsml, feature_selection, validationX is features; y is endpoint labels.
Figure artifactplotting, survival, mlMatplotlib figure/axes, often with optional save_path.
Image review figurevisualizationSlice panels, overlays, difference heatmaps, and image metadata.
ManifestauditJSON-serializable provenance metadata.

Clinical Defaults To Remember

  • Survival functions expect positive duration values and event indicators where 1 means event and 0 means censored.
  • Classification metrics should be interpreted with sensitivity, specificity, balanced accuracy, AUC when probabilities exist, and confusion counts.
  • Imbalanced binary classification can use sklearn class_weight or XGBoost scale_pos_weight.
  • Correlation heatmaps default to Spearman for clinical exploratory work.
  • BOA body-region tissue volumes are read from measurements_no_extremities.
  • FHIR pagination should be bounded during exploration; partition broad searches by date when server caps appear.
  • Flow tracking should start from the source cohort so retention percentages have a real denominator.

Extras By Module

ExtraModules unlocked or enhanced
nonefyron.fhir, fyron.dicom, fyron.imaging, fyron.documents, fyron.llm, fyron.core, fyron.dataframe, fyron.cohort, fyron.flow
fyron[all]all optional Fyron dependencies for a full local research environment
fyron[excel]Excel I/O via read_excel and write_excel
fyron[s3]S3 and S3-compatible object storage helpers
fyron[survival]lifelines-based survival analysis
fyron[survival-ml]gradient survival boosting with scikit-survival
fyron[statistics]statistical tests and bootstrap confidence intervals
fyron[descriptive]descriptive tables backed by NumPy/SciPy
fyron[dicom-seg]standards-compliant DICOM SEG writing with highdicom
fyron[ml]classification ML and clinical model plots
fyron[feature-selection]univariate, correlation, model, permutation, Boruta, and stability selection
fyron[validation]model validation helpers
fyron[explainability]permutation importance, PDP, and optional SHAP tables
fyron[visualization]BOA/OpenCV collage rendering
fyron[radiomics]BOA/PyRadiomics texture and shape features

End-To-End Composition

python
from fyron.cohort import build_survival_columns, join_cohort_tables
from fyron.survival import fit_multivariate_cox
from fyron import descriptive as fd
from fyron import ml

cohort = join_cohort_tables(features_df, outcomes_df, on="patient_id")
cohort = build_survival_columns(cohort, "index_date", "last_followup", "event")

table_one = fd.create_table_one(
    cohort,
    group_col="risk_group",
    numeric=["age", "risk_score"],
    categorical=["sex", "stage"],
)

cox = fit_multivariate_cox(
    cohort,
    duration_col="time",
    event_col="event",
    covariates=["age", "stage", "risk_score"],
)

clf = ml.run_classification_pipeline(
    cohort[["age", "stage_encoded", "risk_score"]],
    cohort["binary_endpoint"],
    model="xgboost",
    plot=True,
)

Design Principles

  • Keep protocol-specific details visible. FHIR remains FHIR; DICOM remains DICOM.
  • Prefer explicit clinical column names over hidden conventions.
  • Return both computed tables and fitted model objects where useful.
  • Make optional dependencies opt-in.
  • Keep plots manuscript-friendly and reproducible from code.