ibl_alignment_gui.plugins.channel_prediction

Functions

_aligned_shanks

Return the shanks a prediction is shown on: the aligned ones, in shank_loop's order.

_all_predictions_done

Keep and draw what each model computed, and report all problems once (main thread).

_all_predictions_task

Run each loaded model on its shanks, one after the other (background thread, no Qt).

_busy_warning

Tell the user another background task is still running.

_cache

Return the shank's cached prediction views, by option.

_draw

Draw the shank's cached view of option on a prediction figure, or clear the figure.

_draw_all

Draw option on each shank that has it.

_draw_all_predictions

Draw every option on its own figure of each shank, saying which models are not loaded.

_enable_menu

Enable the plugin's menu, or grey it out with a hint saying a features file is needed.

_fraction_progress

Adapt the worker's (message, current, total) to the models' (fraction, message).

_keep

Keep the model a task loaded and the views it computed (main thread).

_load_done

Keep the loaded model and show its first option, or report the failure (main thread).

_load_model

Load a release of spec's model chosen in its dialog, then show its first option.

_load_task

Load source (background thread, no Qt).

_on_data_loaded

Data-load hook: reset per-session plugin state.

_predict

Show option on every aligned shank, computing the missing views in the background.

_predict_all

Show every option of the loaded models on every aligned shank, side by side.

_prediction_done

Keep and draw what the task computed, and report its warnings and errors once (main thread).

_prediction_task

Load spec's model if needed, then run it on each shank (background thread, no Qt).

_report

Show the warnings queued by the task and its errors in one dialog, if there are any.

_show_first_option

Select the model's first prediction option, which shows its predictions.

_task_failed

Report a task that failed outside its own error handling (the worker logged it).

_unexpected

Return the message for an unexpected error, whose traceback is logged.

available_models

Return the models offered: those needing torch only when it is installed.

has_torch

Return whether torch is installed, without importing it.

panel_title

Return the title shown above a prediction panel, e.g. 'XGBoost prediction'.

setup

Register the Channel Prediction plugin and (when available) its menu.

Classes

ChannelPrediction

Plugin loader that computes and plots per-channel region predictions.

_Outcome

What a background task did, handed back to the main thread when it ends.

class ibl_alignment_gui.plugins.channel_prediction.ChannelPrediction(controller)[source]

Bases: object

Plugin loader that computes and plots per-channel region predictions.

Registered as the Channel Prediction plugin’s loader; plot_predictions() shows the selected model option (MODEL_FOR_OPTION) on each shank’s prediction panel, computed in the background.

__init__(controller)[source]

Store the controller.

Parameters:

controller (AlignmentGUIController) – The main application controller.

plot_all_predictions()[source]

Show every option of the loaded models side by side on every aligned shank.

The options of models that are not loaded say so; their models are not loaded here. The missing views are computed first, for all models in one background task (_predict_all()).

Return type:

None

plot_predictions(option)[source]

Show the selected model option on every aligned shank.

A model’s predictions are drawn from the cache, or computed first in the background (_predict()). Problems are reported in one warning for all shanks.

Parameters:

option (str) – Prediction option (e.g. ‘Auto-alignment’, ‘XGBoost region prediction’, ‘XGBoost region prediction (cumulative)’). Unknown options are ignored.

Return type:

None

ready()[source]

Return whether there are features to predict on, warning when there are none.

Returns:

True when a shank has features (or a features file was chosen), else False after showing a warning that says how to load a features file.

Return type:

bool

ibl_alignment_gui.plugins.channel_prediction.available_models()[source]

Return the models offered: those needing torch only when it is installed.

Return type:

list[ModelSpec]

ibl_alignment_gui.plugins.channel_prediction.has_torch()[source]

Return whether torch is installed, without importing it.

Return type:

bool

ibl_alignment_gui.plugins.channel_prediction.panel_title(option)[source]

Return the title shown above a prediction panel, e.g. ‘XGBoost prediction’.

Return type:

str

ibl_alignment_gui.plugins.channel_prediction.setup(controller)[source]

Register the Channel Prediction plugin and (when available) its menu.

Always installs the plugin state and its ChannelPrediction loader. When ephysatlas is importable, also adds the “Channel Prediction” menu (load inference/spatial models, load a features file), offers the models’ options in Prediction Plots and registers a data-loaded callback that resets the per-session plugin state.

Parameters:

controller (AlignmentGUIController) – The main application controller.

Return type:

None