Skip to content

Instantly share code, notes, and snippets.

@wmvanvliet
Last active August 2, 2017 12:39
Show Gist options
  • Save wmvanvliet/b6f6acbeba26642f389028509c56caf7 to your computer and use it in GitHub Desktop.
Save wmvanvliet/b6f6acbeba26642f389028509c56caf7 to your computer and use it in GitHub Desktop.
API proposal for picking vertices
# PROPOSED FUNCTIONS
select_vertices_in_label(inst, label):
"""Return the vertno of the vertices that lie within one of the labels."""
select_vertices_in_sensor_range(inst, max_dist, info=None):
"""Return the vertno of the vertices which nearest sensor is no further away than max_dist."""
restrict_vertices(inst, vertices):
"""Restrict the vertices in a Forward, SourceSpaces or SourceEstimate object to the given vertno."""
# EXISTING FUNCTIONALITY CAN BE IMPLEMENTED USING THE ABOVE FUNCTIONS
# restrict_forward_to_stc(fwd, stc)
restrict_vertices(fwd, stc.vertices)
# restrict_forward_to_label(fwd, labels)
restrict_vertices(fwd, select_vertices_in_label(fwd, label))
# src.in_label(labels)
restrict_vertices(stc, select_vertices_in_label(stc, label))
# NEW FUNCTIONALITY INCLUDES:
restrict_vertices(src, stc.vertices)
restrict_vertices(fwd, select_vertices_in_sensor_range(fwd, max_dist=0.07))
restrict_vertices(stc, select_vertices_in_sensor_range(stc, max_dist=0.07, info=info))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment