sanitize_label

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

sanitize_label(value: Any) → str[source]

Return value as a printable ASCII string safe for a figure.

The transformation is: fold common typographic characters onto ASCII, strip accents via NFKD normalisation, then replace any remaining run of non-ASCII characters (e.g. CJK, which has no accent to strip) with a single "?" so its presence is VISIBLE rather than silently lost.

Parameters:

value – The label to sanitise; typically a feature or group name. Non-strings are converted with str first.

Returns:

An ASCII string. ASCII input passes through unchanged apart from the typographic folding, so English labels are never altered.

Examples

>>> sanitize_label("MSI_score")
'MSI_score'
>>> sanitize_label("T1加权")
'T1?'
>>> sanitize_label("CAFé")
'CAFe'

Examples using habit.viz.sanitize_label

Supervoxel feature extraction and acceleration

Supervoxel feature extraction and acceleration

Precise voxel features

Precise voxel features