brain_deer.plugins.leaddbs_atlas_widget¶
leadDBS Atlas Plugin Widget for BrainDeer 🧠🦌
This widget provides a beautiful interface for loading and displaying the Human Dysfunctome Atlas (Hollunder 2024) from leadDBS.
Classes¶
Beautiful widget for leadDBS Human Dysfunctome Atlas integration. |
Module Contents¶
- class brain_deer.plugins.leaddbs_atlas_widget.LeadDBSAtlasWidget(main_window=None, parent=None)¶
Bases:
PyQt5.QtWidgets.QWidgetBeautiful widget for leadDBS Human Dysfunctome Atlas integration.
- setup_ui()¶
Create the beautiful leadDBS atlas interface.
- create_header()¶
Create the header with leadDBS branding.
- create_atlas_selection_section()¶
Create section for selecting atlas directory.
- create_sweet_spots_section()¶
Create section for Sweet Spot structures.
- create_streamlines_section()¶
Create section for Streamline structures.
- on_max_streamlines_changed(value)¶
Update max streamlines label and setting.
- on_tube_radius_changed(value)¶
Update tube radius label and setting.
- on_opacity_changed(value)¶
Update opacity label and setting.
- on_streamline_filter_changed()¶
Update streamline filter settings.
- streamline_points_for_set(set_id: str)¶
Return the stored streamline list for a set (world mm), or None.
- set_streamline_point_colors(set_id: str, rgba) bool¶
Swap the RGBA point scalars of a tract set in place (no geometry rebuild).
rgbais an (N, 4) uint8 array with one row per polydata point, in streamline order (the same point order used when the set was built). Used e.g. for map projection colouring driven from the bottom-panel tract rows. Geometry, tube filter and actors are reused; only scalars are touched.
- apply_streamline_visual_props_only(set_id: str, *, refresh_view: bool = True) bool¶
Update color/opacity on existing actors (no geometry rebuild).
Point-scalar coloring (±vals, density) ignores actor
SetColor, but opacity still applies to the whole actor — so we always push opacity and only set RGB when the mapper is not driven by point scalars.refresh_view=Falselets callers update many tracts then render once (global opacity).
- apply_streamline_settings(set_ids: Iterable[str] | None = None, *, update_table: bool = True, present_view: bool = True)¶
Re-render streamlines. Pass
set_idsto refresh only those sets (e.g. one tract from Atlas Browser 2.0).
- create_electrode_section()¶
Create section for DBS electrode visualization.
- create_structures_section()¶
Create section for additional structures (STN, etc.).
- create_display_options_section()¶
Create section for display options.
- browse_atlas_directory()¶
Open file dialog to select atlas directory.
- auto_detect_atlas()¶
Auto-detect atlas from default leadDBS location.
- auto_detect_template()¶
Auto-detect template from leadDBS location.
- set_atlas_path(path)¶
Set the atlas path and update UI.
- on_disease_changed(index)¶
Handle disease selection change.
- on_hemisphere_changed(index)¶
Handle hemisphere selection change.
- load_sweet_spot()¶
Load selected sweet spot.
- pick_streamline_color()¶
Open color picker for streamline color.
- load_streamline_with_color()¶
Load selected streamline with chosen color.
- load_streamline()¶
Load selected streamline as beautiful fiber tracks (legacy method).
- load_streamline_as_isosurface(structure_name, filepath, color=None)¶
Load streamline volume and convert to actual streamlines (fiber tracks) like leadDBS.
LeadDBS loads streamlines from .mat files if available, otherwise generates from NIfTI.
- Parameters:
structure_name – Unique identifier for this streamline set
filepath – Path to the streamline file
color – Optional (r, g, b) tuple for custom color (default: golden)
This function tries to load .mat file first (like LeadDBS), then falls back to NIfTI generation.
- toggle_streamline_set_visibility(set_id, visible)¶
Toggle visibility of a streamline set.
- change_streamline_set_color(set_id)¶
Change color of a streamline set.
- remove_streamline_set(set_id)¶
Remove a streamline set from the view.
- visualize_example_electrode()¶
Visualize a realistic example DBS electrode placement (STN target).
- create_interactive_electrode()¶
Create a realistic LeadDBS-style DBS electrode with rounded tip. Clean, focused implementation that works smoothly with BrainDeer.
- clear_electrodes()¶
Remove all electrode actors from the 3D view.
- load_mesh_electrode()¶
Load a mesh file (STL, OBJ, or PLY) and display it in the 3D view.
OBJ files can contain colors/textures from Blender via MTL files. PLY files can contain vertex colors.
- toggle_interactive_manipulation(state)¶
Enable/disable interactive manipulation widget.
- update_stl_transform()¶
Update the transform of the electrode based on UI controls.
- toggle_structure(structure_name, visible)¶
Toggle structure visibility.
- choose_color()¶
Open color picker dialog.
- load_template()¶
Load the template (t1.nii) as background reference.
- load_structure_file(structure_name, filepath, colormap='gray', opacity=None)¶
Load a structure file into BrainDeer.
- Parameters:
structure_name – Display name for the structure
filepath – Path to the NIfTI file
colormap – Colormap to use (default: ‘gray’ for atlas structures)
opacity – Opacity value (0-1), uses slider value if None
- get_stylesheet()¶
Get main stylesheet for the widget.
- get_groupbox_stylesheet()¶
Get stylesheet for group boxes.
- get_button_stylesheet(secondary=False)¶
Get stylesheet for buttons.
- get_combobox_stylesheet()¶
Get stylesheet for combo boxes.
- get_checkbox_stylesheet()¶
Get stylesheet for checkboxes.
- get_slider_stylesheet()¶
Get stylesheet for sliders.