ibl_alignment_gui.app.shank_view
Classes
View for displaying plots for a shank on a probe for a given recording configuration. |
- class ibl_alignment_gui.app.shank_view.ShankView(name, index, config)[source]
Bases:
objectView for displaying plots for a shank on a probe for a given recording configuration.
- Parameters:
name (str) – The name of the shank
index (int) – The index of the shank
config (
str) – The config of the shank
- COLOURS = ['#cc0000', '#6aa84f', '#1155cc', '#a64d79']
- HEADER_STYLE = {'deselected': '\n QLabel {\n background-color: rgb(240, 240, 240);\n border: 1px solid lightgrey;\n color: black;\n padding: 6px;\n font-weight: bold;\n }\n ', 'selected': 'QLabel {\n background-color: #c92d0e;\n border: 1px solid lightgrey;\n color: white;\n padding: 6px;\n font-weight: bold;\n }\n '}
- add_reference_lines_to_display()[source]
Add all reference lines to the respective plots.
- Return type:
None
- align_reference_lines_and_points()[source]
Align the position of the track reference lines and scatter points.
The position is updated based on the new positions of their corresponding feature reference lines.
- Return type:
None
- clear_channels(fig_slice)[source]
Clear channels and reference lines from the slice plot.
- Parameters:
fig_slice (pg.ViewBox) – The fig slice to remove the channels and reference lines from
- Return type:
None
- create_fit_items()[source]
Create plot items to put on the fit figure.
The actual fit PlotItem is stored in the app_view as it is shared across the different shanks.
- Return type:
None
- static create_line_style(colour=None)[source]
Generate a random line style (color and dash style) for reference lines.
If the colour is given this is used.
- Parameters:
colour (QtGui.QColor, optional) – The colour to use for the line. If None, a random colour is chosen.
- Return type:
tuple[QPen,QBrush]- Returns:
pen (QtGui.QPen) – A pen object defining the line color, dash style, and width.
brush (QtGui.QBrush) – A brush object with the same color as the pen for use with filled items.
- create_reference_line_and_point(pos, fix_colour=False)[source]
Create a new reference line.
Creates a feature reference line on the line, image and probe figures, a track reference line on the histology figure and a scatter point to be added to the fit figure
- Parameters:
pos (float) – Y-axis position at which to draw the horizontal line.
fix_colour (bool) – Whether to use a fixed colour for the reference line or choose a random color
- Return type:
tuple[InfiniteLine,list[InfiniteLine],PlotDataItem]- Returns:
line_track (pg.InfiniteLine) – The track reference line
line_feature (list[pg.InfiniteLine]) – The feature reference lines
point (pg.PlotDataItem) – The scatter point
- create_slice_items()[source]
Create the slice figure area to show the coronal slices and channels.
- Return type:
None
- delete_reference_line_and_point(line_idx)[source]
Delete a reference line (track, feature and point) from the tracking arrays.
- Parameters:
line_idx (int) – The index of the reference line to remove.
- Return type:
None
- get_feature_and_track_coords()[source]
Return the values of the track and feature reference lines.
- Return type:
tuple[ndarray,ndarray]- Returns:
line_track (np.ndarray) – An array containing the positions of the track reference lines
line_feature (np.ndarray) – An array containing the positions of the track reference lines
- init_plot_items()[source]
Initialise all plot items and attributes used to keep track of plots.
- Return type:
None
- init_reference_line_arrays()[source]
Initialise arrays used to keep track of reference lines and points.
- Return type:
None
- static make_transform(scale, offset)[source]
Create a Qt transform matrix based on scaling and offset values.
- Parameters:
scale (list or np.ndarray) – The x-scale and y-scale factors to apply.
offset (list or np.ndarray) – The x-offset and y-offset translations to apply.
- Returns:
The constructed transformation matrix.
- Return type:
QtGui.QTransform
- match_feature_line(feature_line)[source]
Find the index of the feature reference line matching the given line.
Also find the indices of the feature plots that this line does not belong to.
- Parameters:
feature_line (pg.InfiniteLine) – The feature line to match
- Return type:
tuple[int|None,list|ndarray|None]- Returns:
line_idx (int or None) – The index of the matching feature line or None if not found
fig_idx (np.ndarray or None) – An array containing the indices of the other plots, or None if not found.
- match_linear_region(hover_item)[source]
Find the index of a hovered linear region within the list of scale regions.
- Parameters:
hover_item (pg.LinearRegionItem) – The region item currently hovered over.
- Returns:
region_idx – The index of the hovered region in the scale regions list.
- Return type:
int
- match_track_line(track_line)[source]
Find the index of the track reference line matching the given line.
- Parameters:
track_line (pg.InfiniteLine) – The track line to match
- Returns:
line_idx – The index of the matching track line or None if not found
- Return type:
int or None
- plot_channels(fig_slice, data, colour='r')[source]
Plot the locations of electrode channels and track reference lines on the histology slice.
Note special case as the fig_slice may not come from the current item so it is passed in.
- Parameters:
fig_slice (pg.ViewBox) – The fig slice to plot the channels and reference lines on
data (Bunch) – A Bunch object containing the channels data
colour (str) – The colour to use to plot the channels
- Return type:
None
- plot_empty(fig, fig_cb=None, img=False)[source]
Create an empty placeholder plot when no data is available.
- Parameters:
fig (pg.PlotItem) – The figure to display empty data
fig_cb (pg.PlotItem) – An optional colourbar to reset
img (bool) – Whether the figure is an image plot or not
- Return type:
None
- plot_feature(data)[source]
Plot a 2D feature plot of electrophysiology data.
This is made up of many individual probe plots stacked horizontally.
- Parameters:
data (Bunch[str, ProbeData]) – A Bunch object containing data to plot
- Return type:
None
- plot_fit(data)[source]
Plot data onto fit lines.
- Parameters:
data (Bunch) – A Bunch object containing the fit data
- Return type:
None
- plot_histology(fig, data, ax='left')[source]
Plot histology regions on the given figure.
Shows brain regions intersecting with the probe track.
- Parameters:
fig (pg.PlotItem) – The figure on which to plot the histology regions.
data (Bunch) – A Bunch object containing the histology data.
ax (str, default='left') – Orientation of the axis on which to add labels. ‘left’ for the main histology figure (fig_hist), and ‘right’ for the reference figure (fig_hist_ref).
- Return type:
None
- plot_histology_cumulative(fig, data, ax='right')[source]
Plot cumulative histology probabilities on the given figure.
- Parameters:
fig (pg.PlotItem) – The figure on which to plot the histology regions.
data (Bunch) – A Bunch object containing the histology data.
ax (str, default='left') – Orientation of the axis on which to add labels. ‘left’ for the main histology figure (fig_hist), and ‘right’ for the reference figure (fig_hist_ref).
- Return type:
None
- plot_line(data)[source]
Plot a 1D line plot of electrophysiology data.
- Parameters:
data (LineData) – A LineData object containing data to plot
- Return type:
None
- plot_scale_factor(data)[source]
Plot the scale factor applied to brain regions alongside the histology figure.
- Parameters:
data (Bunch) – A Bunch object containing the scaling data
- Returns:
cbar – The created colorbar
- Return type:
- plot_scatter(data, levels=None)[source]
Plot a 2D scatter plot of electrophysiology data.
- Parameters:
data (ScatterData) – A ScatterData object containing the data to plot
levels (list or np.ndarray, optional) – A list or array containing the levels to set for the colorbar. Defaults to data.levels
- Returns:
The created colorbar
- Return type:
- plot_slice(data, data_traj)[source]
Plot a slice image showing a coronal histology slice.
Add a trajectory line showing the probe location through the slice.
- Parameters:
data (Bunch) – A Bunch object containing the slice data
data_traj (Bunch) – A Bunch object containing the trajectory data
- Return type:
tuple[ImageItem,ColorBar|None]- Returns:
pg.ImageItem – The created image item.
ColorBar – The created colorbar.
- static remove_items(fig, item, delete=True)[source]
Remove all items from a plot item and optionally delete them.
- Parameters:
fig (pg.PlotItem) – The plot item from which to remove items
item (list[pg.GraphicsItem] or pg.GraphicsItem) – A list of items or a single item to remove
delete (bool, default=True) – Whether the item should be deleted
- remove_reference_line(line_idx)[source]
Remove a reference line (track and feature) from the displays.
- Parameters:
line_idx (int) – The index of the reference line to remove
- Return type:
None
- remove_reference_lines_from_display()[source]
Remove all reference lines from the respective plots.
- Return type:
None
- set_feature_title(feature)[source]
Update the axis of the feature label to display the current hovered feature.
- Parameters:
feature (str) – The feature name to display in the axis label.
- Return type:
None
- set_fig_scale_title(value)[source]
Update the label of the scale plot axis to display the current scale value.
- Parameters:
value (float) – The scale factor to display in the axis label. The value is rounded to two decimal places before updating the label.
- Return type:
None
- set_header_style(selected)[source]
Set the stylesheet of the header item.
Update style based on whether the current shank is selected or not.
- Parameters:
selected (bool) – Whether the current shank is selected or not
- Return type:
None
- set_probe_lims(min_val, max_val)[source]
Set the values of the probe tip and probe top.
Update all the associated lines showing the new probe extent.
- Parameters:
min_val (float) – The value for probe tip
max_val (float) – The value for the probe top
- Return type:
None
- set_xaxis_range(fig, xrange=None)[source]
Set the x-axis range of a given figure.
- Parameters:
fig (pg.PlotItem) – The figure whose x-axis range will be updated
xrange (list, optional) – The xrange values to use. If None, the default values are used.
- Return type:
None
- set_yaxis_lims(min_val, max_val)[source]
Set the yrange values that are used to set the y-axis limits used to display plots.
- Parameters:
min_val (float) – The minimum y-axis value
max_val (float) – The maximum y-axis value
- Return type:
None
- set_yaxis_range(fig)[source]
Set the y-axis range of a given figure.
- Parameters:
fig (pg.PlotItem) – The figure whose y-axis range will be updated
- Return type:
None
- toggle_channels(fig_slice, show)[source]
Show/hide the channels and traj line on the slice plot.
- Parameters:
fig_slice (pg.ViewBox) – The fig slice to add or remove the items
show (bool) – Whether to show the channels and traj line or not
- Return type:
None
- toggle_labels(show)[source]
Show/hide the brain region axis labels on the histology plot.
- Parameters:
show (bool) – Whether to show the labels or not.
- Return type:
None
- update_feature_reference_line_and_point(feature_line, line_idx, fig_idx)[source]
Update the feature lines to match the coordinate of the moved feature line.
Also update the scatter point location.
- Parameters:
feature_line (pyqtgraph.InfiniteLine) – The feature line instance that was moved by the user.
line_idx (
int) – The index of the reference line in the tracking arrays.fig_idx (list) – The index of the figures where the feature line position needs to be updated.
- Return type:
None
- update_track_reference_line_and_point(track_line, line_idx)[source]
Update the scatter point location to match the coordinate of the moved track line.
- Parameters:
track_line (pg.InfiniteLine) – The track line instance that was moved by the user.
line_idx (int) – The index of the reference line in the tracking arrays.
- Return type:
None