Skip to content
Bits & Flames Fyron Documentation GitHub
DocsBOA Reference

BOA Reference

Body-and-Organ-Analysis feature extraction, radiomics, experimental aortic calcification, and visual collages.

For workflow context, see BOA module guide.

Functions And Classes

fyron.boa_extraction.experimental_aortic_calcification.extract_experimental_aortic_calcification_features

Extract experimental aortic calcification burden from BOA-style masks.

Import path: fyron.boa_extraction.experimental_aortic_calcification.extract_experimental_aortic_calcification_features

python
extract_experimental_aortic_calcification_features(case_folder_or_masks_dir: str | Path, *, ct_path: str | Path | None = None, masks_dir: str | Path | None = None, download_id: str | None = None, hu_threshold: float = 130.0, prefix: str = 'aortic_calcification', aorta_mask_filenames: str | Sequence[str] = DEFAULT_AORTA_MASK_FILENAMES, total_mask_filenames: str | Sequence[str] = DEFAULT_TOTAL_MASK_FILENAMES, total_aorta_labels: Sequence[int] = DEFAULT_TOTAL_AORTA_LABELS, thoracic_mask_filename: str = 'thoracic_cavity.nii.gz', abdominal_mask_filename: str = 'abdominal_cavity.nii.gz', body_region_mask_filename: str = DEFAULT_BODY_REGION_MASK_FILENAME, body_region_labels: Mapping[str, int] | None = DEFAULT_BODY_REGION_LABELS, iliac_glob: str = '*iliac*.nii.gz', include_iliac: bool = True, missing_value: float | None = np.nan) -> dict[str, Any] | None

Parameters

ParameterRequiredTypeDefaultDescription
case_folder_or_masks_diryesstr or PathPatient folder or mask folder.
ct_pathnostr or Path or NoneNoneCT NIfTI in Hounsfield units. If omitted, common filenames are searched in the case folder.
masks_dirnostr or Path or NoneNoneFolder containing BOA masks. Defaults to `case_folder_or_masks_dir`.
download_idnostr or NoneNoneOptional explicit case identifier. Defaults to the folder name.
hu_thresholdnofloat130.0Voxels inside the vascular mask with HU >= this value are counted as calcification.
prefixnostr'aortic_calcification'Prefix for all generated feature columns.
aorta_mask_filenamesnostr or Sequence[str]DEFAULT_AORTA_MASK_FILENAMESBinary aorta mask filenames to try first.
total_mask_filenamesnostr or Sequence[str]DEFAULT_TOTAL_MASK_FILENAMESFallback multiclass total segmentation filenames.
total_aorta_labelsnoSequence[int]DEFAULT_TOTAL_AORTA_LABELSLabel values counted as aorta in `total.nii.gz. Defaults to 52` and should be verified against the local label map.
thoracic_mask_filenamenostr'thoracic_cavity.nii.gz'See signature.
abdominal_mask_filenamenostr'abdominal_cavity.nii.gz'Optional binary body-region masks used to split the aorta.
body_region_mask_filenamenostrDEFAULT_BODY_REGION_MASK_FILENAMEOptional multiclass body-region mask fallback.
body_region_labelsnoMapping[str, int] or NoneDEFAULT_BODY_REGION_LABELSMapping of output region names to labels in `body_region_mask_filename`.
iliac_globnostr'*iliac*.nii.gz'Glob used to discover iliac masks for aortoiliac burden.
include_iliacnoboolTrueWhether to include iliac-extension and total-aortoiliac features.
missing_valuenofloat or Nonenp.nanValue used for unavailable optional regions.

Returns

dict or None - One flat feature row, or `None` when CT/aorta inputs are unavailable.

See also: BOA module guide.

fyron.boa_extraction.experimental_aortic_calcification.extract_experimental_cohort_aortic_calcification_features

Extract experimental aortic calcification features for many BOA cases.

Import path: fyron.boa_extraction.experimental_aortic_calcification.extract_experimental_cohort_aortic_calcification_features

python
extract_experimental_cohort_aortic_calcification_features(cohort_folder_or_cases: str | Path | Iterable[str | Path], *, num_workers: int = 1, show_progress: bool = True, return_report: bool = False, **kwargs: Any) -> pd.DataFrame | dict[str, Any]

Parameters

ParameterRequiredTypeDefaultDescription
cohort_folder_or_casesyesstr or Path or Iterable[str or Path]Case path, cohort directory, or iterable of case paths; names must be unique.
num_workersnoint1Number of extraction processes; use one for sequential execution.
show_progressnoboolTrueDisplay completed case progress.
return_reportnoboolFalseIf True, return data plus rows and summary report tables; otherwise return the DataFrame.
kwargsyesAnyAdditional keyword arguments passed to the corresponding single-case extractor.

Returns

pd.DataFrame | dict[str, Any]

See also: BOA module guide.

fyron.boa_extraction.features.discover_boa_cases

Discover BOA patient folders below a cohort directory.

Import path: fyron.boa_extraction.features.discover_boa_cases

python
discover_boa_cases(cohort_folder: str | Path, *, measurement_filename: str = 'bca-measurements.json') -> list[Path]

Parameters

ParameterRequiredTypeDefaultDescription
cohort_folderyesstr or PathRoot folder containing patient subfolders such as `patient0001`.
measurement_filenamenostr'bca-measurements.json'File used to identify completed BOA cases.

Returns

list[pathlib.Path] - Sorted patient folders that contain the measurement file.

See also: BOA module guide.

fyron.boa_extraction.features.extract_boa_features

Extract and merge available BOA feature families by `download_id`.

Import path: fyron.boa_extraction.features.extract_boa_features

python
extract_boa_features(cohort_folder_or_cases: str | Path | Iterable[str | Path], *, include_body_regions: bool = True, include_total: bool = True, num_workers: int = 1, show_progress: bool = True, body_region_kwargs: Mapping[str, Any] | None = None, total_kwargs: Mapping[str, Any] | None = None, return_report: bool = False) -> pd.DataFrame | dict[str, Any]

Parameters

ParameterRequiredTypeDefaultDescription
cohort_folder_or_casesyesstr or Path or Iterable[str or Path]Case path, cohort directory, or iterable of case paths; names must be unique.
include_body_regionsnoboolTrueInclude body-composition measurements.
include_totalnoboolTrueInclude total-organ measurements.
num_workersnoint1Number of extraction processes; use one for sequential execution.
show_progressnoboolTrueDisplay completed case progress.
body_region_kwargsnoMapping[str, Any] or NoneNoneOptions forwarded to body-region extraction.
total_kwargsnoMapping[str, Any] or NoneNoneOptions forwarded to total-organ extraction.
return_reportnoboolFalseIf True, return data plus rows and summary report tables; otherwise return the DataFrame.

Returns

pd.DataFrame | dict[str, Any]

See also: BOA module guide.

fyron.boa_extraction.features.extract_body_region_features

Extract body-region tissue volumes and vertebral SMA features.

Import path: fyron.boa_extraction.features.extract_body_region_features

python
extract_body_region_features(case_folder_or_measurements: str | Path, *, body_regions: Sequence[str] = BODY_REGIONS, tissues: Sequence[str] = TISSUES, vertebrae: Sequence[str] = VERTEBRAE, measurement_filename: str = 'bca-measurements.json', sma_segmentation_filename: str | Sequence[str] = ('tissues.nii.gz',), sma_label: int | None = None, slice_levels: Sequence[str] = ('l3',), slice_tissue_labels: Mapping[str, int] | None = None, height_m: float | None = None, include_derived_markers: bool = True, derived_markers: Sequence[Mapping[str, Any]] = DEFAULT_BODY_REGION_DERIVED_MARKERS, download_id: str | None = None, include_sma: bool = True, missing_value: float | None = np.nan) -> dict[str, Any] | None

Parameters

ParameterRequiredTypeDefaultDescription
case_folder_or_measurementsyesstr or PathPatient folder or path to `bca-measurements.json`.
body_regionsnoSequence[str]BODY_REGIONSBody-region keys expected in the BOA aggregated measurements.
tissuesnoSequence[str]TISSUESTissue keys read from `measurements_no_extremities`.
vertebraenoSequence[str]VERTEBRAEVertebral level keys used to select the middle axial slice.
measurement_filenamenostr'bca-measurements.json'Measurement filename when a patient folder is passed.
sma_segmentation_filenamenostr or Sequence[str]('tissues.nii.gz',)Segmentation file used for skeletal muscle area calculation. Pass a sequence to try multiple filenames in order.
sma_labelnoint or NoneNoneExplicit muscle label override. By default, use label 1 in BOA tissues. Custom masks require explicit labels; anatomical body-region masks are not a substitute for HU-filtered tissue masks.
slice_levelsnoSequence[str]('l3',)Vertebral levels used for richer axial area markers, e.g. `("l3",)`.
slice_tissue_labelsnoMapping[str, int] or NoneNoneMapping from marker names to segmentation label values. Defaults to `{"sma": 1, "imat": 5, "vat": 4, "sat": 3} for tissues.nii.gz`. For other filenames, only explicitly supplied labels are measured.
height_mnofloat or NoneNoneOptional patient height in meters. Area-based `smi, imati, vati, and sati do not require height. When height is provided, additional *_cm2_per_m2` columns are calculated.
include_derived_markersnoboolTrueCalculate body-region volume ratios such as muscle/bone and IMAT/TAT.
derived_markersnoSequence[Mapping[str, Any]]DEFAULT_BODY_REGION_DERIVED_MARKERSMarker definitions with `name, numerator, denominator, and optional regions` keys.
download_idnostr or NoneNoneOptional explicit case identifier. Defaults to the patient folder name.
include_smanoboolTrueCalculate `<vertebra>_sma` when the segmentation file is present.
missing_valuenofloat or Nonenp.nanValue used when a measurement key is missing.

Returns

dict or None - One row of features. `None` is returned when the JSON file is missing or malformed.

See also: BOA module guide.

fyron.boa_extraction.features.extract_cohort_body_region_features

Extract body-region features for all completed BOA cases in a cohort.

Import path: fyron.boa_extraction.features.extract_cohort_body_region_features

python
extract_cohort_body_region_features(cohort_folder_or_cases: str | Path | Iterable[str | Path], *, num_workers: int = 1, show_progress: bool = True, measurement_filename: str = 'bca-measurements.json', return_report: bool = False, **kwargs: Any) -> pd.DataFrame | dict[str, Any]

Parameters

ParameterRequiredTypeDefaultDescription
cohort_folder_or_casesyesstr or Path or Iterable[str or Path]Case path, cohort directory, or iterable of case paths; names must be unique.
num_workersnoint1Number of extraction processes; use one for sequential execution.
show_progressnoboolTrueDisplay completed case progress.
measurement_filenamenostr'bca-measurements.json'Measurement JSON filename used for discovery and extraction.
return_reportnoboolFalseIf True, return data plus rows and summary report tables; otherwise return the DataFrame.
kwargsyesAnyAdditional keyword arguments passed to the corresponding single-case extractor.

Returns

pd.DataFrame | dict[str, Any]

See also: BOA module guide.

fyron.boa_extraction.features.extract_cohort_total_features

Extract total-segmentation features for all BOA cases in a cohort.

Import path: fyron.boa_extraction.features.extract_cohort_total_features

python
extract_cohort_total_features(cohort_folder_or_cases: str | Path | Iterable[str | Path], *, num_workers: int = 1, show_progress: bool = True, measurement_filename: str = 'total-measurements.json', return_report: bool = False, **kwargs: Any) -> pd.DataFrame | dict[str, Any]

Parameters

ParameterRequiredTypeDefaultDescription
cohort_folder_or_casesyesstr or Path or Iterable[str or Path]Case path, cohort directory, or iterable of case paths; names must be unique.
num_workersnoint1Number of extraction processes; use one for sequential execution.
show_progressnoboolTrueDisplay completed case progress.
measurement_filenamenostr'total-measurements.json'Measurement JSON filename used for discovery and extraction.
return_reportnoboolFalseIf True, return data plus rows and summary report tables; otherwise return the DataFrame.
kwargsyesAnyAdditional keyword arguments passed to the corresponding single-case extractor.

Returns

pd.DataFrame | dict[str, Any]

See also: BOA module guide.

fyron.boa_extraction.features.extract_total_segmentation_features

Extract organ volume, HU, CNR, and ratio features from total measurements.

Import path: fyron.boa_extraction.features.extract_total_segmentation_features

python
extract_total_segmentation_features(case_folder: str | Path, *, labels: Mapping[str, int] = TOTAL_LABELS, ratios: Sequence[tuple[str, str]] = TOTAL_RATIOS, measurement_filename: str = 'total-measurements.json', download_id: str | None = None, round_digits: int | None = 2, missing_value: float | None = np.nan) -> dict[str, Any] | None

Parameters

ParameterRequiredTypeDefaultDescription
case_folderyesstr or PathPatient folder containing `total-measurements.json`.
labelsnoMapping[str, int]TOTAL_LABELSOrgan labels to extract from `segmentations.total`.
ratiosnoSequence[tuple[str, str]]TOTAL_RATIOSOrgan volume ratios to compute as `organ_a / organ_b`.
measurement_filenamenostr'total-measurements.json'Total segmentation measurements filename.
download_idnostr or NoneNoneOptional explicit case identifier. Defaults to the patient folder name.
round_digitsnoint or None2Number of digits used for rounded numeric features. Set to `None` to keep original precision.
missing_valuenofloat or Nonenp.nanValue used when a metric or organ is missing.

Returns

dict or None - One row of total-segmentation features, or `None` when no valid JSON is available.

See also: BOA module guide.

fyron.boa_extraction.features.read_json_file

Read a JSON file and return parsed content.

Import path: fyron.boa_extraction.features.read_json_file

python
read_json_file(file_path: str | Path) -> dict[str, Any] | list[Any]

Parameters

ParameterRequiredTypeDefaultDescription
file_pathyesstr or PathJSON file path.

Returns

dict or list - Parsed JSON content.

See also: BOA module guide.

fyron.boa_radiomics.features.discover_boa_radiomics_cases

Discover BOA patient folders with a target segmentation file.

Import path: fyron.boa_radiomics.features.discover_boa_radiomics_cases

python
discover_boa_radiomics_cases(cohort_folder: str | Path, *, segmentation_filename: str | Path = 'total.nii.gz') -> list[Path]

Parameters

ParameterRequiredTypeDefaultDescription
cohort_folderyesstr or PathSee signature.
segmentation_filenamenostr or Path'total.nii.gz'See signature.

Returns

list[Path]

See also: BOA module guide.

fyron.boa_radiomics.features.extract_boa_radiomics_features

Extract BOA radiomics features for a cohort of patient folders.

Import path: fyron.boa_radiomics.features.extract_boa_radiomics_features

python
extract_boa_radiomics_features(cohort_folder_or_cases: str | Path | Iterable[str | Path], *, image_filename: str | Path | Sequence[str | Path] = DEFAULT_IMAGE_FILENAMES, segmentation_kind: SegmentationKind = 'total', segmentation_filename: str | Path | None = None, labels: Mapping[str, int] | Sequence[int] | None = None, extractor_settings: Mapping[str, Any] | None = None, feature_prefix: str = 'radiomics', include_paths: bool = True, exclude_diagnostics: bool = True, minimum_voxels: int = 1, resample_mask: bool = True, on_error: OnError = 'skip', num_workers: int = 1, show_progress: bool = True, return_report: bool = False) -> pd.DataFrame | dict[str, Any]

Parameters

ParameterRequiredTypeDefaultDescription
cohort_folder_or_casesyesstr or Path or Iterable[str or Path]Case path, cohort directory, or iterable of case paths; names must be unique.
image_filenamenostr or Path or Sequence[str or Path]DEFAULT_IMAGE_FILENAMESImage filename or ordered candidate filenames.
segmentation_kindnoSegmentationKind'total'Label convention: total or body_regions.
segmentation_filenamenostr or Path or NoneNoneExplicit mask filename; defaults to the selected convention.
labelsnoMapping[str, int] or Sequence[int] or NoneNoneMapping of label names to integer values, or a sequence of integers.
extractor_settingsnoMapping[str, Any] or NoneNoneSettings passed to the PyRadiomics extractor.
feature_prefixnostr'radiomics'Prefix for extracted feature columns.
include_pathsnoboolTrueInclude sensitive source paths in the feature table.
exclude_diagnosticsnoboolTrueOmit PyRadiomics diagnostic feature columns.
minimum_voxelsnoint1Skip feature extraction for masks smaller than this voxel count.
resample_masknoboolTrueResample masks to the image grid when needed; this is not registration.
on_errornoOnError'skip'Use skip to retain partial results, or raise to propagate extraction failures.
num_workersnoint1Number of extraction processes; use one for sequential execution.
show_progressnoboolTrueDisplay completed case progress.
return_reportnoboolFalseIf True, return data plus rows and summary report tables; otherwise return the DataFrame.

Returns

pd.DataFrame | dict[str, Any]

See also: BOA module guide.

fyron.boa_radiomics.features.extract_case_radiomics_features

Extract PyRadiomics features for one BOA case folder.

Import path: fyron.boa_radiomics.features.extract_case_radiomics_features

python
extract_case_radiomics_features(case_folder: str | Path, *, image_filename: str | Path | Sequence[str | Path] = DEFAULT_IMAGE_FILENAMES, segmentation_kind: SegmentationKind = 'total', segmentation_filename: str | Path | None = None, labels: Mapping[str, int] | Sequence[int] | None = None, extractor: Any | None = None, extractor_settings: Mapping[str, Any] | None = None, feature_prefix: str = 'radiomics', download_id: str | None = None, include_paths: bool = True, exclude_diagnostics: bool = True, minimum_voxels: int = 1, resample_mask: bool = True, on_error: OnError = 'skip') -> dict[str, Any] | None

Parameters

ParameterRequiredTypeDefaultDescription
case_folderyesstr or PathSee signature.
image_filenamenostr or Path or Sequence[str or Path]DEFAULT_IMAGE_FILENAMESSee signature.
segmentation_kindnoSegmentationKind'total'See signature.
segmentation_filenamenostr or Path or NoneNoneSee signature.
labelsnoMapping[str, int] or Sequence[int] or NoneNoneSee signature.
extractornoAny or NoneNoneSee signature.
extractor_settingsnoMapping[str, Any] or NoneNoneSee signature.
feature_prefixnostr'radiomics'See signature.
download_idnostr or NoneNoneSee signature.
include_pathsnoboolTrueSee signature.
exclude_diagnosticsnoboolTrueSee signature.
minimum_voxelsnoint1See signature.
resample_masknoboolTrueSee signature.
on_errornoOnError'skip'See signature.

Returns

dict[str, Any] | None

See also: BOA module guide.

fyron.visualization.boa.create_boa_segmentation_collage

Create a multi-patient BOA collage with OpenCV.

Import path: fyron.visualization.boa.create_boa_segmentation_collage

python
create_boa_segmentation_collage(boa_folders: Sequence[StrPath], output_path: StrPath, *, orientation: Orientation = 'axial', segmentation_layers: Sequence[SegmentationLayer | SegmentationKind | str] | None = None, patient_labels: Sequence[str] | None = None, slice_index: int | None = None, slice_indices: Sequence[int] | None = None, slice_fraction: float | None = None, ct_filename: str | None = None, window_center: float = 40.0, window_width: float = 400.0, segmentation_opacity: float = 0.45, overlay_alpha: float | None = None, panel_width: int = 320, row_label_prefix: str | None = None, crop_body_region: int | str | None = None, body_region_padding_mm: float = 15.0, body_region_slices: BodyRegionSliceMode = 'best') -> CollageResult

Parameters

ParameterRequiredTypeDefaultDescription
boa_foldersyesSequence[StrPath]One BOA output directory per patient.
output_pathyesStrPathDestination image path (`.png` recommended).
orientationnoOrientation'axial'`axial, sagittal, or coronal`.
segmentation_layersnoSequence[SegmentationLayer or SegmentationKind or str] or NoneNoneWhich masks to show and how. Pass kinds (`"body_regions", "tissues", "total") or SegmentationLayer objects with display_mode of ct, ct_overlay, or segmentation`.
patient_labelsnoSequence[str] or NoneNonePatient ID shown rotated at the start of each row (e.g. `Patient A`).
slice_indexnoint or NoneNoneAbsolute slice index along the orientation axis.
slice_indicesnoSequence[int] or NoneNoneMultiple slice rows (absolute indices). Not combined with `slice_fraction`.
slice_fractionnofloat or NoneNoneRelative slice position in `[0, 1] per patient (handles different volume depths). Ignored when slice_indices` is set.
ct_filenamenostr or NoneNoneOptional explicit CT filename inside each folder.
window_centernofloat40.0See signature.
window_widthnofloat400.0CT window for grayscale / overlay backgrounds.
segmentation_opacitynofloat0.45Opacity of segmentation colors in `ct_overlay and segmentation panels, in [0, 1]. Per-layer override via SegmentationLayer(opacity=...)`.
overlay_alphanofloat or NoneNoneDeprecated alias for `segmentation_opacity`.
panel_widthnoint320Panel width in pixels; height follows voxel spacing.
row_label_prefixnostr or NoneNoneSee signature.
crop_body_regionnoint or str or NoneNoneBOA body-region label id or name (e.g. `3 or "Abdominal Cavity"). Selects only slices containing this region and crops each panel to its bounding box (plus body_region_padding_mm`).
body_region_padding_mmnofloat15.0Padding around the cropped body region in millimetres.
body_region_slicesnoBodyRegionSliceMode'best'`best (default): slice with largest in-plane region area; center: middle slice of the region extent; all`: every slice that contains the region.

Returns

dict - `output_path, patient_paths, segmentation_layers, slice_indices_used, orientation, image_shape, and when cropping is enabled crop_body_region`.

See also: BOA module guide.

fyron.visualization.curate_previews.PreviewSource

Input source resolved from a directory scan.

Import path: fyron.visualization.curate_previews.PreviewSource

python
PreviewSource()

Parameters

No parameters documented.

Returns

Class constructor.

See also: BOA module guide.

fyron.visualization.curate_previews.discover_preview_sources

Discover DICOM series and image files below a directory.

Import path: fyron.visualization.curate_previews.discover_preview_sources

python
discover_preview_sources(input_dir: StrPath, *, recursive: bool = True, include_dicom: bool = True, include_image_files: bool = True) -> list[PreviewSource]

Parameters

ParameterRequiredTypeDefaultDescription
input_diryesStrPathSee signature.
recursivenoboolTrueSee signature.
include_dicomnoboolTrueSee signature.
include_image_filesnoboolTrueSee signature.

Returns

list[PreviewSource]

See also: BOA module guide.

fyron.visualization.curate_previews.prepare_curate_image_previews

Write Curate-ready PNG previews from medical image folders.

Import path: fyron.visualization.curate_previews.prepare_curate_image_previews

python
prepare_curate_image_previews(input_dir: StrPath, output_dir: StrPath, *, recursive: bool = True, include_dicom: bool = True, include_image_files: bool = True, panel_width: int = 384, window_center: float | None = None, window_width: float | None = None, percentile_clip: tuple[float, float] = (1.0, 99.0), overwrite: bool = False, manifest_csv: StrPath | None = None) -> dict[str, Any]

Parameters

ParameterRequiredTypeDefaultDescription
input_diryesStrPathDirectory containing CT/MRI volumes, DICOM files, or 2-D images.
output_diryesStrPathDestination folder for PNG previews.
recursivenoboolTrueIf True, scan nested folders.
include_dicomnoboolTrueIf True, read DICOM series from directories containing DICOM files.
include_image_filesnoboolTrueIf True, read NIfTI/MHA/NRRD and common 2-D raster image files.
panel_widthnoint384Output width per PNG. Height follows physical spacing for 3-D slices.
window_centernofloat or NoneNoneSee signature.
window_widthnofloat or NoneNoneOptional fixed grayscale window, useful for CT. If omitted, robust percentile normalization is used, which also works for MRI.
percentile_clipnotuple[float, float](1.0, 99.0)Low/high percentiles for automatic normalization when no fixed window is supplied.
overwritenoboolFalseIf False, existing PNG files are left untouched.
manifest_csvnoStrPath or NoneNoneOptional manifest path. Defaults to `output_dir / "manifest.csv"`.

Returns

dict - `input_dir, output_dir, manifest_csv, sources_found, images_written, images_skipped, and rows`.

See also: BOA module guide.

fyron.visualization.segmentation_collage.create_segmentation_collage

Create a generic OpenCV CT/segmentation overlay collage.

Import path: fyron.visualization.segmentation_collage.create_segmentation_collage

python
create_segmentation_collage(image: VolumeInput, segmentation: VolumeInput, output_path: StrPath, *, labels: Sequence[int] | int | None = None, orientation: Orientation = 'axial', slice_strategy: SliceStrategy = 'segmentation_extent', slice_indices: Sequence[int] | None = None, every_n_slices: int | None = None, max_slices: int | None = None, n_cols: int | None = None, window_center: float = 40.0, window_width: float = 400.0, segmentation_opacity: float = 0.4, label_colors: Mapping[int, tuple[int, int, int]] | Sequence[tuple[int, int, int]] | None = None, title: str | None = None, show_slice_labels: bool = True, panel_width: int = 256, spacing: tuple[float, float, float] = (1.0, 1.0, 1.0)) -> CollageResult

Parameters

ParameterRequiredTypeDefaultDescription
imageyesVolumeInputImage volume as NIfTI path, `SimpleITK.Image, or 3-D NumPy array in (z, y, x)` order.
segmentationyesVolumeInputSegmentation volume as NIfTI path, `SimpleITK.Image, or matching 3-D NumPy array in (z, y, x)` order.
output_pathyesStrPathDestination image path, usually `.png`.
labelsnoSequence[int] or int or NoneNoneLabel ids to display. `None` displays all non-zero labels.
orientationnoOrientation'axial'`axial, sagittal, or coronal`.
slice_strategynoSliceStrategy'segmentation_extent'`segmentation_extent selects slices containing the requested labels; full_extent` samples the complete volume.
slice_indicesnoSequence[int] or NoneNoneExplicit absolute slice indices along the selected orientation axis.
every_n_slicesnoint or NoneNoneStep size over the selected extent. The last selected extent slice is included for `segmentation_extent`.
max_slicesnoint or NoneNoneOptional maximum number of selected slices after slice sampling.
n_colsnoint or NoneNoneNumber of columns in the output grid. When omitted, a near-square grid is chosen automatically.
window_centernofloat40.0CT window center used for grayscale background rendering.
window_widthnofloat400.0CT window width used for grayscale background rendering.
segmentation_opacitynofloat0.4Opacity of the colored segmentation overlay in `[0, 1]`.
label_colorsnoMapping[int, tuple[int, int, int]] or Sequence[tuple[int, int, int]] or NoneNoneRGB colors either as `{label: (r, g, b)} mapping or sequence matched to labels` order.
titlenostr or NoneNoneOptional title bar shown above the collage.
show_slice_labelsnoboolTrueIf True, add a small label bar with the orientation axis and slice index to each panel.
panel_widthnoint256Width of each rendered slice panel in pixels.
spacingnotuple[float, float, float](1.0, 1.0, 1.0)Fallback voxel spacing `(sx, sy, sz)` for NumPy array inputs.

Returns

dict - Metadata including `output_path, slice_indices_used, labels, image_shape, and orientation`.

See also: BOA module guide.

fyron.visualization.segmentation_collage.create_segmentation_collages_from_cases

Create one segmentation collage per case folder and return a summary table.

Import path: fyron.visualization.segmentation_collage.create_segmentation_collages_from_cases

python
create_segmentation_collages_from_cases(input_root: StrPath, output_dir: StrPath, *, case_glob: str = 'case-*', image_relpath: StrPath = 'A/image.nii.gz', segmentation_relpath: StrPath = 'A/segmentation.nii.gz', output_suffix: str = '.png', labels: Sequence[int] | int | None = None, orientation: Orientation = 'axial', slice_strategy: SliceStrategy = 'segmentation_extent', every_n_slices: int | None = None, max_slices: int | None = None, n_cols: int | None = None, window_center: float = 40.0, window_width: float = 400.0, segmentation_opacity: float = 0.4, label_colors: Mapping[int, tuple[int, int, int]] | Sequence[tuple[int, int, int]] | None = None, panel_width: int = 256, continue_on_error: bool = True) -> pd.DataFrame

Parameters

ParameterRequiredTypeDefaultDescription
input_rootyesStrPathFolder containing case directories.
output_diryesStrPathDestination folder for generated collage PNGs.
case_globnostr'case-*'Glob pattern used to discover case directories below `input_root`.
image_relpathnoStrPath'A/image.nii.gz'Image path relative to each case directory.
segmentation_relpathnoStrPath'A/segmentation.nii.gz'Segmentation path relative to each case directory.
output_suffixnostr'.png'Suffix for output files; filenames use the case directory name.
labelsnoSequence[int] or int or NoneNoneLabel id or ids to display. `None` displays all non-zero labels.
orientationnoOrientation'axial'`axial, sagittal, or coronal`.
slice_strategynoSliceStrategy'segmentation_extent'`segmentation_extent selects slices containing the requested labels; full_extent` samples the complete volume.
every_n_slicesnoint or NoneNoneStep size over the selected extent.
max_slicesnoint or NoneNoneOptional maximum number of selected slices per case.
n_colsnoint or NoneNoneNumber of columns in each output grid.
window_centernofloat40.0CT window center used for grayscale background rendering.
window_widthnofloat400.0CT window width used for grayscale background rendering.
segmentation_opacitynofloat0.4Opacity of the colored segmentation overlay in `[0, 1]`.
label_colorsnoMapping[int, tuple[int, int, int]] or Sequence[tuple[int, int, int]] or NoneNoneRGB colors either as mapping by label id or sequence matched to labels.
panel_widthnoint256Width of each rendered slice panel in pixels.
continue_on_errornoboolTrueIf True, failed cases are recorded with `status="error"`; otherwise the first failure is raised.

Returns

pandas.DataFrame - One row per case with paths, status, message, selected slices, and slice count.

See also: BOA module guide.

fyron.visualization.volume_difference.plot_volume_difference_heatmap

Plot aligned CT/MR slices with a zero-centered difference heatmap.

Import path: fyron.visualization.volume_difference.plot_volume_difference_heatmap

python
plot_volume_difference_heatmap(volume_a: VolumeInput, volume_b: VolumeInput, *, data_type: DataType = 'ct_hu', orientation: Orientation = 'axial', slice_index: int | None = None, slice_indices: Sequence[int] | None = None, slice_fraction: float | None = None, label_a: str = 'Volume A', label_b: str = 'Volume B', window_center: float = 40.0, window_width: float = 400.0, rescale_slope: float = 1.0, rescale_intercept: float = -1024.0, mr_normalization: str = 'percentile', mr_percentile: float = 99.0, diff_vmax: float | None = None, diff_percentile: float = 99.0, diff_cmap: str = 'fyron_diverging_blue_red', figsize: tuple[float, float] | None = None, title: str | None = None, save_path: StrPath | None = None) -> tuple[plt.Figure, np.ndarray, pd.DataFrame]

Parameters

ParameterRequiredTypeDefaultDescription
volume_ayesVolumeInputSee signature.
volume_byesVolumeInputNIfTI path, `SimpleITK.Image, or NumPy array in (z, y, x)` order. Path and SimpleITK inputs are checked for matching spacing, origin, and direction. NumPy arrays are checked for shape only.
data_typenoDataType'ct_hu'`"ct_hu" assumes arrays are already Hounsfield units. "ct_uint16" converts stored values with arr * rescale_slope + rescale_intercept. "mr" normalizes each volume to a [0, 1]` scale before comparison.
orientationnoOrientation'axial'Slice plane: `"axial", "coronal", or "sagittal"`.
slice_indexnoint or NoneNoneSee signature.
slice_indicesnoSequence[int] or NoneNoneSee signature.
slice_fractionnofloat or NoneNoneSelect one absolute slice, several absolute slices, or one relative slice location in `[0, 1]`. If none is provided, the center slice is shown.
label_anostr'Volume A'See signature.
label_bnostr'Volume B'Column labels for the first two panels.
window_centernofloat40.0See signature.
window_widthnofloat400.0CT display window for `ct_hu and ct_uint16` inputs.
rescale_slopenofloat1.0See signature.
rescale_interceptnofloat-1024.0Conversion from stored CT values to HU for `data_type="ct_uint16"`.
mr_normalizationnostr'percentile'See signature.
mr_percentilenofloat99.0MR normalization mode and percentile passed to `normalize_mr`.
diff_vmaxnofloat or NoneNoneSymmetric absolute limit for the difference map. When omitted, it is estimated from `diff_percentile` of the absolute full-volume difference.
diff_percentilenofloat99.0Percentile used for automatic `diff_vmax`.
diff_cmapnostr'fyron_diverging_blue_red'Matplotlib colormap name or Fyron named diverging colormap.
figsizenotuple[float, float] or NoneNoneOptional figure size. Defaults to a readable size based on slice count.
titlenostr or NoneNoneOptional figure title.
save_pathnoStrPath or NoneNoneOptional output image path. Parent directories are created.

Returns

tuple - `(fig, axes, table) where axes is an n_slices x 3 array and table` contains slice-level difference summary statistics.

See also: BOA module guide.