neurocarto.views.blueprint_script
- class neurocarto.views.blueprint_script.BlueprintScriptView
Blueprint script manager view.
Check whether the
ProbeDespimplement protocolProbePlotElectrodeProtocol.- BUILTIN_ACTIONS: ClassVar[dict[str, str]] = {'1-eighth': 'neurocarto.util.edit._actions:npx24_one_eighth_density', 'exchange': 'neurocarto.util.edit._actions:exchange_shank', 'half': 'neurocarto.util.edit._actions:npx24_half_density', 'inside': 'neurocarto.util.edit._actions:highlight_electrode_inside_region', 'label': 'neurocarto.util.edit._actions:atlas_label', 'load': 'neurocarto.util.edit._actions:load_blueprint', 'move': 'neurocarto.util.edit._actions:move_blueprint', 'optimize': 'neurocarto.util.edit._actions:optimize_channelmap', 'probe-coor': 'neurocarto.util.edit._actions:adjust_atlas_mouse_brain_to_probe_coordinate', 'quarter': 'neurocarto.util.edit._actions:npx24_quarter_density', 'single': 'neurocarto.util.edit._actions:npx24_single_shank', 'stripe': 'neurocarto.util.edit._actions:npx24_stripe'}
Builtin scripts
- __init__(config)
- Parameters:
config (CartoConfig)
- actions: dict[str, str | BlueprintScriptInfo]
all scripts
- property name: str
view name
- script_select: Select
- script_input: TextInput
- script_run: Button
- script_document: Div
- reset_blueprint()
Reset blueprint.
- restore_state(state)
Restore state from state.
- Parameters:
state (BlueprintScriptState) – json-deserializable instance.
- add_script(name, script)
- Parameters:
name (str)
script (str)
- start()
Invoked when figure is ready.
- cache_chmap: Any | None = None
- cache_blueprint: list[ElectrodeDesp] | None = None
- cache_data: NDArray[np.float64] | None = None
- on_probe_update(probe, chmap, electrodes)
Invoked when channelmap is changed or electrode’s category is changed.
- Parameters:
probe – probe interface.
chmap – channelmap instance.
electrodes – all electrodes.
- update_actions_select()
Update
script_select’s content that only keep probe-suitable blueprint scripts.
- on_data_update(probe, data)
- Parameters:
probe (ProbeDesp)
data (ndarray[tuple[int, ...], dtype[float64]] | None)
- get_script(name)
Get and load
BlueprintScript.If the corresponding module has changed, this function will try to reload it.
- Parameters:
name (str | BlueprintScript | BlueprintScriptInfo) – script name.
- Returns:
- Raises:
TypeError – not callable.
ImportError – unable to load the script.
ValueError – incorrect script module path
- Return type:
- interrupt_script(script)
- Parameters:
script (str) – script name
- Raises:
ValueError – This script is not interruptable, maybe not exist or not running.
- run_script(script, script_input=None, *, interrupt_at=None)
Run a blueprint script.
- Parameters:
script (str | BlueprintScript | BlueprintScriptInfo) – script name, script path or a
BlueprintScriptscript_input (str | None) – script input text.
interrupt_at (int | None) – Do not use. Record replay used parameter.
- filter_records(records, *, reset=False)
Filter records which source came from itself.
It is also used to modify the records and return the equivalence steps.
- Parameters:
records (list[RecordStep])
reset – reset view to the initial state? If so, you can add extra action in return.
- Returns:
filtered records
- Return type:
list[RecordStep]
- replay_record(record)
Replay the record step.
Warning
Do not call this method directly, because it might cause
add_record()be invoked during the replay. Use RecordManager.replay()instead.- Parameters:
record (RecordStep)
- class neurocarto.views.blueprint_script.BlueprintScriptState
BlueprintScriptView stored user configuration.
- actions: dict[str, str]
extra actions dict {name: module_path}
- class neurocarto.views.blueprint_script.ProbePlotElectrodeProtocol
ProbeDespextension protocol for plotting electrode data beside probe.- view_ext_blueprint_plot_categories(ax, chmap, blueprint, color=None, **kwargs)
plot electrode categories along the probe.
Note
BlueprintScriptViewdoes not use this method for any UI actions, but used by BlueprintFunctions.plot_channelmap()and BlueprintFunctions.plot_blueprint().- Parameters:
ax (Axes) – matplotlib.Axes
chmap (Any)
blueprint (NDArray[np.int_]) – Array[category:int, E], where E means all electrodes
color (dict[int, Any]) – categories color {category: color}, where color is used by matplotlib.
kwargs
- view_ext_blueprint_plot_electrode(ax, chmap, data, **kwargs)
plot electrode data along the probe.
Note
BlueprintScriptViewuses this method for any UI actions via BlueprintFunctions.draw(),- Parameters:
ax (Axes) – matplotlib.Axes
chmap (Any)
data (NDArray[np.float64]) – Array[float, E], where E means all electrodes
kwargs
- Raises:
KeyboardInterrupt – interrupt plotting
- __init__(*args, **kwargs)