ibl_alignment_gui.loaders.geometry_loader
Functions
Arrange channel data into probe banks for visualization. |
|
Average data across channels at the same depth. |
|
Describe the ways the electrode and channel geometries disagree about the probe layout. |
|
Pad data to align with the full channel map, filling gaps with NaNs. |
Classes
Geometry class using spike sorting channel data. |
|
Abstract base class for splitting the sites on a probe per shank. |
|
Abstract base class for loading probe geometry from metadata or channels. |
|
Geometry loader using local file system. |
|
Geometry loader using the ONE API. |
|
Geometry class using spikeglx ap metadata. |
- class ibl_alignment_gui.loaders.geometry_loader.ChannelGeometry(channels, shank_diff=100)[source]
Bases:
GeometryGeometry class using spike sorting channel data.
Here the sites correspond to the spike sorting channels.
- Parameters:
channels (Bunch) – A Bunch object containing spike sorting channels data.
shank_diff (int) – The minimum difference in x coordinates to separate shanks.
- class ibl_alignment_gui.loaders.geometry_loader.Geometry(x_coords, y_coords, chn_ind)[source]
Bases:
ABCAbstract base class for splitting the sites on a probe per shank.
Sites can either correspond to spike sorting channels or raw data electrodes.
Subclasses must implement the _get_n_shanks and _get_shank_groups methods.
- Parameters:
x_coords (np.ndarray) – x coordinates of the sites
y_coords (np.ndarray) – y coordinates of the sites
chn_ind (
ndarray) – Map of spike-sorting channels to raw data
- split_sites_per_shank()[source]
Split the sites into shanks and store the results in self.shanks.
Channels are sorted according to the y coordinates.
- Return type:
None
- Each entry in self.shanks is a Bunch containing:
- spikes_ind: np.ndarray
Indices of the sites that correspond to the spike sorting data.
- raw_ind: np.ndarray
Indices of sites relative to raw data ordering.
- site_coords: np.ndarray
(x, y) coordinates of the shank sites.
- sites_min/ sites_max: float
Minimum and maximum y coordinate values.
- sites_pitch: float
Minimum difference between y coordinates (sites spacing).
- sites_full: np.ndarray
Full set of y coordinates covering the whole shank.
- idx_full: np.ndarray
Indices of the actual y coordinates within sites_full.
- n_banks: int
Number of banks in the shank.
- class ibl_alignment_gui.loaders.geometry_loader.GeometryLoader[source]
Bases:
ABCAbstract base class for loading probe geometry from metadata or channels.
Subclasses must implement the load_meta_data and load_channels methods.
- get_sites_for_shank(shank_idx, sites=None)[source]
Get the sites information for a given shank.
By default, the site information from the electrodes (ap.metadata) is returned. If sites=’channels’, the site information for the channels is returned
- Parameters:
shank_idx (int) – Index of the shank.
sites (str) – The origin of the site information
- Returns:
Site information for the given shank.
- Return type:
Bunch
- class ibl_alignment_gui.loaders.geometry_loader.GeometryLoaderLocal(data_paths)[source]
Bases:
GeometryLoaderGeometry loader using local file system.
- Parameters:
data_paths (DatasetPaths) – The resolved dataset paths for the probe. The channels are read from the
spike_sortingfolder and the metadata from theraw_ephysfolder.
- class ibl_alignment_gui.loaders.geometry_loader.GeometryLoaderOne(insertion, one, session_path=None, probe_collection=None)[source]
Bases:
GeometryLoaderGeometry loader using the ONE API.
- Parameters:
insertion (dict) – Dictionary representing a probe insertion (must include ‘session’ and ‘name’).
one (ONE) – An ONE instance used to access data.
session_path (Path or None) – Path to the session folder. If None, it is resolved using the eid via one.eid2path.
probe_collection (str or None) – The collection to the spike sorting data to load
- class ibl_alignment_gui.loaders.geometry_loader.MetaGeometry(meta)[source]
Bases:
GeometryGeometry class using spikeglx ap metadata. Here the sites correspond to the electrode sites.
- Parameters:
meta (Bunch) – A Bunch object containing spikeglx metadata
- ibl_alignment_gui.loaders.geometry_loader.arrange_channels_into_banks(shank_geom, data, bnk_width=10)[source]
Arrange channel data into probe banks for visualization.
Channels are grouped by bank (x-coordinate). For each bank, channel values are aligned along the y-axis. If the spacing between channels does not match the expected spacing (self.chn_diff), gaps are filled with NaNs
- Parameters:
shank_geom (Bunch) – A bunch containing channel geometry information for a shank, returned from Geometry.get_chns_for_shank().
data (np.ndarray) – 1D array of values per channel
bnk_width (int) – The width of each bank in the x dimension for visualization.
- Return type:
tuple[ndarray,ndarray,ndarray]- Returns:
bnk_data (np.ndarray) – A 2D array with data organised into individual banks on the shank.
bnk_scale (np.ndarray) – Scale factor to apply along x and y axes
bnk_offset (list of np.ndarray) – Offset to apply along x and y axes.
- ibl_alignment_gui.loaders.geometry_loader.average_chns_at_same_depths(shank_geom, data)[source]
Average data across channels at the same depth.
- Parameters:
shank_geom (Bunch) – A bunch containing channel geometry information for a shank, returned from Geometry.get_chns_for_shank().
data (np.ndarray) – 2D array of data with shape (time or frequency x channels).
- Returns:
2D array with averaged data across equivalent depths.
- Return type:
np.ndarray
- ibl_alignment_gui.loaders.geometry_loader.find_geometry_mismatches(electrodes, channels)[source]
Describe the ways the electrode and channel geometries disagree about the probe layout.
The spike sorting channels are expected to describe a subset of the electrodes, so the number of sites and their exact depths are not required to match - channels that recorded no spikes may be missing entirely. What is checked is that each shank has the same number of banks, and that every channel site falls within the depth range the metadata reports for that shank.
Note that the x coordinates are deliberately not compared: the metadata x is relative to each shank, so the same values repeat across shanks, whereas the spike sorting localCoordinates are absolute across the whole probe.
- ibl_alignment_gui.loaders.geometry_loader.pad_data_to_full_chn_map(shank_geom, data)[source]
Pad data to align with the full channel map, filling gaps with NaNs.
- Parameters:
shank_geom (Bunch) – A bunch containing channel geometry information for a shank, returned from Geometry.get_chns_for_shank().
data (np.ndarray) – 2D array of data with shape (time or frequency x channels).
- Returns:
2D array padded to the full channel map.
- Return type:
np.ndarray