arista.constants
Constants, palettes, stimulus + strain catalogues, and helpers.
Module Attributes
Regex matching every Fiji ROI filename convention observed in the corpus: |
|
Map every observed spelling to its canonical entry in |
|
Half-width of the sensor-T tolerance window around a step's target, in °C. |
|
Where to start the exponential-decay fit for HotAdapt / ColdAdapt recordings, in seconds. |
Functions
|
Return the palette colour for a numbered cell of the given type. |
Convenience: return just the canonical CC/HC/WC code, or |
|
|
Return True if |
|
Return the matplotlib marker glyph for the given arista side. |
|
Functional NompC dosage for a strain, |
|
Resolve any observed spelling of a stimulus to its canonical name. |
|
Resolve any observed spelling of a strain to its canonical name. |
|
Pull (hemisphere, cell_type, cell_number) out of a Fiji ROI filename. |
|
Export |
Classes
|
One row in the |
|
One row in the |
- 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:
objectOne row in the
cell_typesdimension table.
- 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 beNone),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 (coldadapvsColdAdapt); 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:
objectOne row in the
stimulus_protocolsdimension table.Target sequences for the four
*Amp*andadaptationprotocols are lifted verbatim from_legacy/pytci/tempFileIO.pyso the new pipeline and the legacy one agree on what target each step held. Mechanical and long-duration adaptation protocols carry no sequence.- Parameters:
- arista.constants.colour_for_cell(cell_type, index=0)[source]
Return the palette colour for a numbered cell of the given type.
- Parameters:
- Returns:
A hex colour string. Falls back to a neutral grey if the
cell_typeis unrecognised, so unknown labels are visible but don’t crash plotting.- Return type:
- arista.constants.infer_cell_type_from_filename(name)[source]
Convenience: return just the canonical CC/HC/WC code, or
None.
- arista.constants.is_fiji_filename(name)[source]
Return True if
namematches any accepted Fiji ROI filename pattern.
- 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.
- arista.constants.nompc_dosage(strain_name)[source]
Functional NompC dosage for a strain,
Nonewhen unknown.Accepts both canonical names and cross-student aliases. Returns
Nonefor unrecognised strains and for non-string / NaN input.
- 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
nameis unknown. Add it toSTIMULUS_SYNONYMSrather than silently mapping it.- Return type:
- 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
nameis unknown.- Return type:
- arista.constants.parse_fiji_filename(name)[source]
Pull (hemisphere, cell_type, cell_number) out of a Fiji ROI filename.
Returns
Noneif the name does not match.
- arista.constants.save_figure(fig, stem, output_dir, csv_data=None)[source]
Export
figas 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>.csvfor reviewer verification (CLAUDE.md § 7.2).
- Returns:
Triple of (svg_path, png_path, csv_path_or_None).
- Return type:
tuple[Path, Path, Path | None]