Skip to main content

ElectrodeObject

Namespace: DISP3DLIB  ·  Library: 3D Display Library

#include <disp3D/electrodeobject.h>

class DISP3DLIB::ElectrodeObject

Renderable sEEG / ECoG electrodes: contact spheres plus lead bodies.

src/examples/ex_disp3d_scene/main.cpp
QVector<IeegContact> shaft(4); // LH1..LH4, 3.5 mm apart: grouped into the sEEG depth lead "LH"
for (int k = 0; k < 4; ++k) {
shaft[k].name = QString("LH%1").arg(k + 1);
shaft[k].position = Eigen::Vector3f(0.010f + 0.0035f * float(k), -0.020f, 0.005f); // surface RAS, metres
}
ElectrodeObject electrodes; // a view of the implantation, drawn by BrainView::setElectrodes()
electrodes.setImplantation(IeegImplantation(shaft));
electrodes.selectContact("LH3");
float contactDistance = 0.0f;
const int pickedContact = electrodes.intersect(QVector3D(0.017f, -0.020f, 1.0f), QVector3D(0.0f, 0.0f, -1.0f), contactDistance);

Public Methods​

ElectrodeObject()​


~ElectrodeObject()​


setImplantation(implantation)​

Draw an implantation.

Clears the selection, hover and contact colours.

Parameters:

  • implantation : const IeegImplantation & Contacts and leads, positions in the frame of the surfaces.

implantation()​

Returns:


totalContactCount()​

Returns:

  • int — Total number of contacts.

setContactValues(values, colormap)​

Colour contacts by value through a colormap spanning [min(0, smallest), largest].

Contacts without a value keep the colour of their lead.

Parameters:

  • values : const QMap< QString, float > & Map of contact name -> scalar value.

  • colormap : const QString & ColorMap name.


clearContactValues()​

Restore the lead colours of all contacts.


surfaceColors(vertices, distance)​

Paint the contact values onto a surface, as MNE-Python's stc_near_sensors: each vertex takes the distance-weighted mean of the contacts within reach and fades out with the summed weight.

ECoG contacts are first moved onto the surface; depth contacts are not.

Parameters:

  • vertices : const Eigen::MatrixX3f & Surface vertex positions in the frame of the implantation, metres.

  • distance : double Reach of each contact in metres.

Returns:

  • QVector< uint32_t > — ABGR colour per vertex, transparent away from the contacts; empty without values.

selectContact(name)​

Select a contact by name.

Clears the previous selection.

Parameters:

  • name : const QString & Contact name to select.

clearSelection()​

Clear the contact selection.


selectedContact()​

Returns:

  • QString — Name of the currently selected contact, or empty string if none.

setHoveredContact(index)​

Highlight one contact while the pointer is over it, without changing the selection.

Parameters:

  • index : int Contact index (as returned by intersect), or -1 for none.

hoveredContact()​

Returns:

  • int — Hovered contact index, or -1.

intersect(rayOrigin, rayDir, dist)​

Intersect a ray with the contact spheres.

Parameters:

  • rayOrigin : const QVector3D & Ray origin.

  • rayDir : const QVector3D & Normalised ray direction.

  • dist : float & Distance to the nearest hit.

Returns:

  • int — Index of the nearest contact hit, or -1.

contactAt(index)​

Parameters:

  • index : int Contact index.

Returns:

  • *const IeegContact ** — The contact, or nullptr when out of range.

contactLabel(index)​

Parameters:

  • index : int Contact index.

Returns:

  • QString — Hover text, e.g. "LA3 (depth lead LA)", or an empty string when out of range.

contactStreams()​

Returns:

  • InstancedStreams — Instanced streams of the contact spheres (one instance per contact).

bodyStreams()​

Returns:

  • InstancedStreams — Instanced streams of the lead bodies (unit cylinders: shafts and ties).

contactRenderKey()​

Returns:

  • const RenderKey & — Identity of the contact mesh in the renderer's GPU cache.

bodyRenderKey()​

Returns:

  • const RenderKey & — Identity of the body mesh in the renderer's GPU cache.

isVisible()​


setVisible(visible)​


boundingBoxMin()​

Returns:

  • QVector3D — Axis-aligned bounding box minimum corner (with contact-radius padding).

boundingBoxMax()​

Returns:

  • QVector3D — Axis-aligned bounding box maximum corner (with contact-radius padding).

Static Methods​

leadColor(index)​

Parameters:

  • index : int Lead index.

Returns:

  • QColor — Lead colour: golden-angle hues, so neighbouring leads differ clearly.

Example​

Used in examples​

ex_disp3d_scene​

Disp3D scene data: sensor-to-surface interpolation, electrodes, MRI slices, video overlay and layers.

src/examples/ex_disp3d_scene/main.cpp, line 139
ElectrodeObject electrodes; // a view of the implantation, drawn by BrainView::setElectrodes()
electrodes.setImplantation(IeegImplantation(shaft));
electrodes.selectContact("LH3");
float contactDistance = 0.0f;
const int pickedContact = electrodes.intersect(QVector3D(0.017f, -0.020f, 1.0f), QVector3D(0.0f, 0.0f, -1.0f), contactDistance);
ok &= expect(electrodes.totalContactCount() == 4 && electrodes.selectedContact() == "LH3" && electrodes.contactStreams().instanceCount == 4 && electrodes.bodyStreams().instanceCount == 1 && electrodes.contactLabel(pickedContact) == "LH3 (depth lead LH)",
"ElectrodeObject: 4 contacts on one shaft, a ray through LH3 picks it");

Authors of this file​