arista.constants

Constants, palettes, stimulus + strain catalogues, and helpers.

Module Attributes

FIJI_NAME_PATTERN

Regex matching every Fiji ROI filename convention observed in the corpus: l_CC01.csv / r_HC02.csv (flat layout); CC_01.csv / HC_02.csv (HCS exp01); CC01.csv / HC03.csv (HCS exp02); plus lower-case variants.

STIMULUS_SYNONYMS

Map every observed spelling to its canonical entry in STIMULUS_PROTOCOLS.

STIMULUS_RESPONSE_WINDOW_C

Half-width of the sensor-T tolerance window around a step's target, in °C.

ADAPTATION_FIT_START_S

Where to start the exponential-decay fit for HotAdapt / ColdAdapt recordings, in seconds.

Functions

colour_for_cell(cell_type[, index])

Return the palette colour for a numbered cell of the given type.

infer_cell_type_from_filename(name)

Convenience: return just the canonical CC/HC/WC code, or None.

is_fiji_filename(name)

Return True if name matches any accepted Fiji ROI filename pattern.

marker_for_hemisphere(hemisphere)

Return the matplotlib marker glyph for the given arista side.

nompc_dosage(strain_name)

Functional NompC dosage for a strain, None when unknown.

normalise_stimulus(name)

Resolve any observed spelling of a stimulus to its canonical name.

normalise_strain(name)

Resolve any observed spelling of a strain to its canonical name.

parse_fiji_filename(name)

Pull (hemisphere, cell_type, cell_number) out of a Fiji ROI filename.

save_figure(fig, stem, output_dir[, csv_data])

Export fig as SVG + PNG with an optional CSV data companion.

Classes

CellTypeInfo(code, name, description)

One row in the cell_types dimension table.

StimulusProtocol(name, family, description, ...)

One row in the stimulus_protocols dimension table.

arista.constants.ADAPTATION_FIT_START_S: float = 75.0

Where to start the exponential-decay fit for HotAdapt / ColdAdapt recordings, in seconds. Skips the pre-stimulus baseline so the fit only sees the post-onset relaxation. 75 s matches the protocol design in pytci’s tempFileIO (75 s baseline + step), the same on Robert’s and Laurin’s rigs.

class arista.constants.CellTypeInfo(code, name, description)[source]

Bases: object

One row in the cell_types dimension table.

Parameters:
code: Literal['CC', 'HC', 'WC']
description: str
name: str
arista.constants.FIJI_NAME_PATTERN: Pattern[str] = re.compile('\n    ^\n    (?:(?P<hemisphere>[lr])_)?              # optional hemisphere prefix\n    (?P<cell_type>CC|HC|WC|cc|hc|wc)\n    _?(?P<cell_number>\\d+)\n    \\.csv$\n    ', re.VERBOSE)

Regex matching every Fiji ROI filename convention observed in the corpus: l_CC01.csv / r_HC02.csv (flat layout); CC_01.csv / HC_02.csv (HCS exp01); CC01.csv / HC03.csv (HCS exp02); plus lower-case variants. Three named groups: hemisphere (may be None), cell_type, cell_number.

arista.constants.STIMULUS_RESPONSE_WINDOW_C: float = 0.5

Half-width of the sensor-T tolerance window around a step’s target, in °C. Matches Kossen 2019’s self.offset = 0.5.

arista.constants.STIMULUS_SYNONYMS: dict[str, str] = {'AristaBending': 'Bending', 'Bending': 'Bending', 'ColdAdapt': 'ColdAdapt', 'HotAdapt': 'HotAdapt', 'adaptation': 'adaptation', 'ascAmp': 'ascAmp', 'ascAmpFlip': 'ascAmpFlip', 'bending': 'Bending', 'cold_adap': 'ColdAdapt', 'coldadap': 'ColdAdapt', 'coldadaptation': 'ColdAdapt', 'descAmp': 'descAmp', 'descAmpFlip': 'descAmpFlip', 'hot_adap': 'HotAdapt', 'hotadap': 'HotAdapt', 'hotadaptation': 'HotAdapt', 'long': 'long', 'long_neg': 'long_neg', 'step': 'step', 'step_neg': 'step_neg'}

Map every observed spelling to its canonical entry in STIMULUS_PROTOCOLS. Filenames in Robert’s tree mix case (coldadap vs ColdAdapt); the ingester normalises via this table and fails loudly if a string is not present.

class arista.constants.StimulusProtocol(name, family, description, target_sequence, baseline_t_c=22.0, step_duration_s=60.0, baseline_duration_s=75.0)[source]

Bases: object

One row in the stimulus_protocols dimension table.

Target sequences for the four *Amp* and adaptation protocols are lifted verbatim from _legacy/pytci/tempFileIO.py so the new pipeline and the legacy one agree on what target each step held. Mechanical and long-duration adaptation protocols carry no sequence.

Parameters:
  • name (str)

  • family (Literal['thermal_step', 'thermal_adapt', 'mechanical'])

  • description (str)

  • target_sequence (tuple[float, ...] | None)

  • baseline_t_c (float)

  • step_duration_s (float)

  • baseline_duration_s (float)

baseline_duration_s: float = 75.0
baseline_t_c: float = 22.0
description: str
family: Literal['thermal_step', 'thermal_adapt', 'mechanical']
name: str
step_duration_s: float = 60.0
target_sequence: tuple[float, ...] | None
arista.constants.colour_for_cell(cell_type, index=0)[source]

Return the palette colour for a numbered cell of the given type.

Parameters:
  • cell_type (str) – "CC" / "HC" / "WC" (case-insensitive).

  • index (int) – 0-based position within the type. Clamps to the last palette entry once the gradient is exhausted, so a fifth CC cell in some hypothetical session still gets a sensible colour rather than raising.

Returns:

A hex colour string. Falls back to a neutral grey if the cell_type is unrecognised, so unknown labels are visible but don’t crash plotting.

Return type:

str

arista.constants.infer_cell_type_from_filename(name)[source]

Convenience: return just the canonical CC/HC/WC code, or None.

Parameters:

name (str)

Return type:

Literal[‘CC’, ‘HC’, ‘WC’] | None

arista.constants.is_fiji_filename(name)[source]

Return True if name matches any accepted Fiji ROI filename pattern.

Parameters:

name (str)

Return type:

bool

arista.constants.marker_for_hemisphere(hemisphere)[source]

Return the matplotlib marker glyph for the given arista side.

Accepts None, pandas-NaN, or arbitrary non-string values and falls back to "o" in those cases so a real-world Series loaded from SQL (where NULLs surface as NaN floats) is safe to iterate without preprocessing.

Parameters:

hemisphere (str | None | float)

Return type:

str

arista.constants.nompc_dosage(strain_name)[source]

Functional NompC dosage for a strain, None when unknown.

Accepts both canonical names and cross-student aliases. Returns None for unrecognised strains and for non-string / NaN input.

Parameters:

strain_name (str | None)

Return type:

float | None

arista.constants.normalise_stimulus(name)[source]

Resolve any observed spelling of a stimulus to its canonical name.

Parameters:

name (str) – The string as it appears in a filename or file header.

Returns:

The canonical key in STIMULUS_PROTOCOLS.

Raises:

ValueError – If name is unknown. Add it to STIMULUS_SYNONYMS rather than silently mapping it.

Return type:

str

arista.constants.normalise_strain(name)[source]

Resolve any observed spelling of a strain to its canonical name.

Parameters:

name (str) – The string as it appears in a filename or directory.

Returns:

The canonical entry in CANONICAL_STRAINS.

Raises:

ValueError – If name is unknown.

Return type:

str

arista.constants.parse_fiji_filename(name)[source]

Pull (hemisphere, cell_type, cell_number) out of a Fiji ROI filename.

Returns None if the name does not match.

Parameters:

name (str)

Return type:

dict[str, str | None] | None

arista.constants.save_figure(fig, stem, output_dir, csv_data=None)[source]

Export fig as SVG + PNG with an optional CSV data companion.

Parameters:
  • fig (Figure) – Matplotlib figure to save.

  • stem (str) – Filename stem (no extension).

  • output_dir (Path) – Target directory (created if needed).

  • csv_data (pd.DataFrame | None) – Optional dataframe with the numeric values behind the figure. Written alongside as <stem>.csv for reviewer verification (CLAUDE.md § 7.2).

Returns:

Triple of (svg_path, png_path, csv_path_or_None).

Return type:

tuple[Path, Path, Path | None]