ibl_alignment_gui.handlers.probe_handler

Classes

ProbeHandler

Abstract base class for handling alignment and data loading for a probe.

ProbeHandlerCSV

ProbeHandler where data from two channel maps has been recorded on the shanks.

ProbeHandlerLocal

Local file system implementation of ProbeHandler.

ProbeHandlerLocalYaml

Local file system implementation of ProbeHandler that uses a yaml file.

ProbeHandlerONE

ONE implementation of ProbeHandler.

class ibl_alignment_gui.handlers.probe_handler.ProbeHandler(brain_atlas)[source]

Bases: ABC

Abstract base class for handling alignment and data loading for a probe.

This class provides access to loader methods that handle different aspects of the alignment process. Where applicable the probe is split into shanks and each shank is handled separately.

It can also handle multiple configurations for each shank, for example if two different channel maps are used to record data.

Parameters:

brain_atlas (AllenAtlas) – An AllenAtlas instance.

property current_idx: int

Return the current index of the alignment stored in the buffer for the selected shank.

Returns:

The index of the current alignment

Return type:

int

abstractmethod download_histology()[source]

Load histology data.

property feature_keys: list[str]

Find the list of available feature plot keys across all shanks and configurations.

Returns:

A tuple of unique probe plot keys.

Return type:

tuple

get_config(idx)[source]

Select a configuration by index.

Parameters:

idx (int) – Index in the list of possible configurations.

Return type:

None

get_current_shank(shank, config)[source]

Return the currently active shank.

Return type:

ShankHandler

get_plot(shank, plot, key, config=None)[source]

Access a specific plot for a specific shank and configuration.

Parameters:
  • shank (str) – The shank label to access.

  • plot (str) – The plot type to access. One of ‘image’, ‘scatter’, ‘line’, ‘probe’ or ‘slice’

  • key (str) – The plot key to access.

  • config (str) – The configuration to access. If None, uses the default configuration.

Returns:

The requested plot, or None if not found.

Return type:

Any

get_plot_keys(plot)[source]

Find a list of available keys across all shanks and configurations for a given plot type.

Parameters:

plot (str) – The plot type to get the keys for. One of ‘image’, ‘scatter’, ‘line’, ‘probe’ or ‘slice’

Returns:

A list of unique plot keys.

Return type:

list

get_previous_alignments()[source]

Get previous alignments for the selected shank.

Always returns the alignments from the default configuration.

Returns:

Previous alignments for the selected shank

Return type:

dict

get_selected_shank()[source]

Return the currently selected shank.

Return type:

Bunch

abstractmethod get_shanks(*args)[source]

Return shank information.

get_starting_alignment(idx)[source]

Set the index of the starting alignment for the selected shank and each configuration.

Parameters:

idx (int) – The index of the previous alignment to load.

Return type:

None

property image_keys: list[str]

Find the list of available image plot keys across all shanks and configurations.

Returns:

A list of unique image plot keys.

Return type:

list

abstractmethod initialise_shanks()[source]

Initialize shank data.

property line_keys: list[str]

Find the list of available line plot keys across all shanks and configurations.

Returns:

A list of unique line plot keys.

Return type:

list

load_data()[source]

Download and load data for all configs and shanks.

Return type:

None

load_plots()[source]

Load plots for all configs and shanks.

load_previous_alignments()[source]

Load previous alignments for the selected shank.

Always returns the alignments from the default configuration.

Returns:

Previous alignments for the selected shank.

Return type:

dict

next_idx()[source]

Return the index of the next available alignment for the selected shank.

Returns:

The index of the next available alignment stored in th circular buffer.

Return type:

int

static normalize_shank_label(shank_label)[source]

Normalize a shank label to the form ‘probe0X’.

Parameters:

shank_label (str) – Input shank label.

Returns:

Normalized label.

Return type:

str

prev_idx()[source]

Return the index of the previously available alignment for the selected shank.

Returns:

The index of the previous available alignment stored in th circular buffer.

Return type:

int

property probe_keys: list[str]

Find the list of available probe plot keys across all shanks and configurations.

Returns:

A tuple of unique probe plot keys.

Return type:

tuple

property scatter_keys: list[str]

Find the list of available scatter plot keys across all shanks and configurations.

Returns:

A list of unique scatter plot keys.

Return type:

list

abstractmethod set_info(*args)[source]

Set probe information.

set_init_alignment()[source]

Initialise the alignment for the selected shank and each configuration.

Return type:

None

property slice_keys: list[str]

Find the list of available slice plot keys across all shanks and configurations.

Returns:

A list of unique slice plot keys.

Return type:

list

property total_idx: int

Return the total index of the alignments stored in the buffer for the selected shank.

Returns:

The total number of alignments stored in the circular buffer

Return type:

int

upload_data()[source]

Upload data for the selected shank for each configuration.

Always returns the upload result from the default configuration.

Returns:

Upload result from the default config.

Return type:

str

class ibl_alignment_gui.handlers.probe_handler.ProbeHandlerCSV(csv_file, one=None, brain_atlas=None)[source]

Bases: ProbeHandler

ProbeHandler where data from two channel maps has been recorded on the shanks.

The data for the dense configuration is available via ONE whereas the data for the quarter configuration is only available on the local file system. Reads in a csv file that contains information about where to read the relevant data from.

download_histology()[source]

Download and load in the histology slice data.

Return type:

NrrdSliceLoader

get_insertion(shank)[source]

Get the alyx probe insertion for the shank.

Return type:

dict

get_sessions(idx)[source]

Find all probes for a given session.

Note if multi-shank data it will return probe00 rather than probe00a, the individual shank is chosen using the shank dropdown.

Parameters:

idx (idx) – The index of the chosen subject

Returns:

All probes with spikesorting data for the chosen session

Return type:

np.ndarray

get_shanks(idx)[source]

Find all shanks for a given probe and initialise the loaders.

Parameters:

idx (idx) – The index of the chosen probe

Returns:

All shanks for the chosen probe

Return type:

np.ndarray

get_subjects()[source]

Find all sessions with spike sorting data.

Returns:

All sessions with spikesorting data.

Return type:

np.ndarray

initialise_shanks()[source]

Initialise each shank and config with the selected loaders.

Return type:

None

set_info(idx)[source]

Set the information about the selected shank.

Parameters:

idx (int) – The index of the selected shank

Return type:

None

class ibl_alignment_gui.handlers.probe_handler.ProbeHandlerLocal(brain_atlas=None)[source]

Bases: ProbeHandler

Local file system implementation of ProbeHandler.

For this ProbeHandler, all ephys and alignment data must be stored in a single folder on disk.

download_histology()[source]

Load in the histology slice data.

Return type:

NrrdSliceLoader

get_shanks(folder_path)[source]

Find the number of shanks on the probes.

Loads the channels or ap meta data from the folder path and initialises the loaders for each shank.

Parameters:

folder_path (Path) – A path to the folder on the local disk that contains the data

Return type:

list[str]

initialise_shanks()[source]

Initialise each shank with the loaders.

Return type:

None

set_info(idx)[source]

Set the information about the selected shank.

Parameters:

idx (int) – The index of the selected shank

Return type:

None

class ibl_alignment_gui.handlers.probe_handler.ProbeHandlerLocalYaml(yaml_file, brain_atlas=None)[source]

Bases: ProbeHandler

Local file system implementation of ProbeHandler that uses a yaml file.

The yaml file contains information about where to read the relevant data from.

download_histology()[source]

Load in the histology slice data.

Return type:

NrrdSliceLoader

get_shanks(_)[source]

Initialise the shanks based on the yaml file.

If only one probe label is given we load in the geometry to see if it is a multi-shank recording. Otherwise, we assume the yaml has specified all shanks and these are treated individually.

Return type:

list[str]

initialise_shanks()[source]

Initialise each shank and config with the selected loaders.

Return type:

None

set_info(idx)[source]

Set the information about the selected shank.

Parameters:

idx (int) – The index of the selected shank

Return type:

None

class ibl_alignment_gui.handlers.probe_handler.ProbeHandlerONE(one=None, brain_atlas=None, spike_collection=None)[source]

Bases: ProbeHandler

ONE implementation of ProbeHandler.

For this ProbeHandler all ephys and alignment data is downloaded and accessed via ONE and Alyx.

The data for all shanks on a probe will be loaded at once.

Parameters:
  • one (ONE) – An ONE instance used to upload results to Alyx

  • brain_atlas (AllenAtlas) – An AllenAtlas object.

  • spike_collection (str, optional) – Spike sorting algorithm to load (e.g. ‘pykilosort’, ‘iblsorter’).

download_histology()[source]

Download and load in the histology slice data.

Return type:

NrrdSliceLoader

get_session_probe_name(ins)[source]

Make a string containing the combination of session information and probe name.

Removes the shank identifiers from the probe names.

Parameters:

ins (dict) – A dict containing insertion data

Returns:

A string with the session info and probe name

Return type:

str

get_sessions(idx)[source]

Find all probes for a given subject.

Note if multi-shank data it will return probe00 rather than probe00a, the individual shank is chosen using the shank dropdown.

Parameters:

idx (idx) – The index of the chosen subject

Returns:

All probes with spikesorting data for the chosen subject

Return type:

np.ndarray

get_shanks(idx)[source]

Find all shanks for a given probe and initialise the loaders.

Parameters:

idx (idx) – The index of the chosen probe

Returns:

All shanks for the chosen probe

Return type:

np.ndarray

get_subjects()[source]

Find all subjects that have probe insertions with spikesorting data.

Returns:

An array of subject names

Return type:

np.ndarray

initialise_shanks()[source]

Initialise each shank with the loaders.

load_data()[source]

Load data for all configs and shanks.

Return type:

None

set_info(idx)[source]

Set the information about the selected shank.

Parameters:

idx (int) – The index of the selected shank