neurocarto.main_app
- class neurocarto.main_app.CartoApp
Application of neural probe channelmap editor.
The layout of this application is split into:
left: channelmap manipulating button groups.
center: figure that contains probe/electrodes, image and curves.
right: controls of image, curves that shown in center panel.
- user_views_config: dict[str, Any] = {}
user view configuration
- right_panel_views_config: dict[str, Any] = {}
view configuration, channelmap depended
- __init__(config, *, logger='neurocarto.editor')
- Parameters:
config (CartoConfig)
logger (str)
- property title: str
Application title (shown in web page title)
- current_resource_root()
get current resource root.
- Returns:
path
- See:
- Return type:
Path
- change_resource_root(root)
change resource root.
- Parameters:
root (str | Path) – path
- See:
- load_user_config(*, reset=False)
load user config.
- Parameters:
reset – reset user config. Otherwise, just update dict.
- Returns:
- See:
- Return type:
dict[str, Any]
- save_user_config(direct=False)
save user config.
- Parameters:
direct – Do not update configurations from
GlobalStateView.- See:
- get_editor_userconfig()
get editor config from user config.
- Returns:
- Return type:
- list_chmap_files(recursive=True)
List channelmap files under chmap-dir (
-C,--chmap-dir).- Parameters:
recursive (bool) – recursive search the files in folders.
- Returns:
list of files
- See:
- Return type:
list[Path]
- get_chmap_file(name)
Get channelmap file path.
- Parameters:
name (str) – filename. it should be the filename under chmap-dir. Otherwise, it needs to contain ‘/’ to load from/save into other place.
- Returns:
saving path.
- See:
{files#get_channelmap_file()}
- Return type:
Path
- load_chmap(name)
Load channelmap from file with name.
- Parameters:
name (str | Path) – filename. See
get_chmap_file()for more details.- Returns:
channelmap instance.
- Return type:
M
- save_chmap(name, chmap)
Save channelmap into file.
- Parameters:
name (str) – filename. See
get_chmap_file()for more details.chmap (M) – channelmap instance.
- Returns:
saved path.
- Return type:
Path
- get_blueprint_file(chmap)
Get corresponded blueprint file from channelmap path.
A blueprint is a numpy array, and saved with a suffix ‘.blueprint.npy’. Sometimes, we encode the channelmap type code inside, e.g. ‘.CODE.blueprint.npy’, when the blueprint file does not have the corresponding channelmap file.
- Parameters:
chmap (str | Path) – filename. See
get_chmap_file()for more details.- Returns:
saving path.
- See:
- Return type:
Path
- load_blueprint(chmap)
Load channelmap chmap corresponded blueprint.
- Parameters:
chmap (str | Path) – filename. See
get_blueprint_file()for more details.- Returns:
True on success.
- Return type:
bool
- save_blueprint(chmap)
Save channelmap chmap corresponded blueprint.
- Parameters:
chmap (str | Path) – filename. See
get_blueprint_file()for more details.- Returns:
saving path. None on failure.
- Return type:
Path | None
- get_view_config_file(chmap)
Get view components’ configurations saving path.
- Parameters:
chmap (str | Path) – filename. See
get_chmap_file()for more details.- Returns:
saving path.
- See:
- Return type:
Path
- load_view_config(chmap, *, reset=False, error=False)
Load view components’ configurations.
- Parameters:
chmap (str | Path) – filename. See
get_view_config_file()for more details.reset – reset right_view_config or update.
error – raise FileNotFoundError if chmap does not exist, instead of warning.
- Returns:
configuration dict {type_name: Any}.
- Return type:
dict[str, Any]
- save_view_config(chmap, *, direct=False)
Save view components’ configurations.
- Parameters:
chmap (str | Path) – filename. See
get_view_config_file()for more details.direct – Do not update configurations from view components.
- probe_fig: figure
- input_imro: Select
- output_imro: AutocompleteInput
- message_area: TextAreaInput
- auto_btn: Toggle
- index()
Web-page document content
- install_right_panel_views(config)
- Parameters:
config (CartoConfig)
- Returns:
list of item that recognised by
init_view()- Return type:
list
- start()
Invoked when session set
- cleanup(context)
Invoked when session destroyed
- Parameters:
context (SessionContext)
- on_new(e)
callback function on new a probe instance.
- Parameters:
e (int | str | MenuItemClick) – probe code, name. It could be an event but for internal using.
- on_load()
callback function on loading a channelmap file.
- load_file(name)
load a channelmap file.
- Parameters:
name (str | Path) – channelmap filename or filepath. Could be a view config json file (
*.config.json).
- reload_input_file_list(preselect=None)
reload the channelmap file list and update the UI components, including
input_imro’s options list and selected filename, andoutput_imro’s completion list.- Parameters:
preselect (str | None) – selected filename
- on_save()
callback function on saving a channelmap file.
This saving also save accompanying files with the channelmap file, like blueprint file and view configuration file.
Note
Only valid channelmap can be saved, as well as its accompanying files.
The user config “always_save_blueprint_file” allow the blueprint file can be saved even if the channelmap is invalid.
- on_state_change(state)
callback function on any state button is pressed.
This callback changes the state of captured electrodes.
- Parameters:
state (int) – state code
- on_category_change(category)
callback function on any category button is pressed.
This callback changes the category of captured electrodes.
- Parameters:
category (int) – category code
- on_probe_update()
callback function to notify the
DynamicViewthat the probe has updated.
- on_autoupdate(active)
callback function on the state of the
auto_btnchanged.- Parameters:
active (bool) – Does the auto trigger enable?
- on_refresh()
callback function to refresh the electrode selection.
- log_message(*message, reset=False)
print messages at log area.
- Parameters:
message – messages.
reset – reset text area.
- log_clear()
Clear log text area.
- neurocarto.main_app.main(config=None)
Start application.
- Parameters:
config (CartoConfig | None)
- class neurocarto.main_app.CartoUserConfig
User config for
CartoApp.All key are optional.
{ "CartoApp": { "theme": "", "views": [], "history": false, "overwrite_chmap_file": false, "always_save_blueprint_file": false, "selected_as_pre_selected": false, } }
- theme: str | dict[str, Any] | None
Bokeh theme. see https://docs.bokeh.org/en/latest/docs/reference/themes.html#theme
- views: list[str]
Extra {ViewBase} list
- history: bool
Enable History. Default False
- overwrite_chmap_file: bool
overwrite channelmap file by default. Default False
- always_save_blueprint_file: bool
always save the blueprint file even if the channelmap still invalid.
- selected_as_pre_selected: bool
set selected electrode as pre-select category when constructing on blank (or only preselect category) blueprint. Default False.