Skip to content

Commit 43a256d

Browse files
committed
FIX pickerfun Python callback
1 parent fe46c5d commit 43a256d

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

cortex/webgl/resources/js/facepick.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ PickPosition.prototype = {
248248
this.callback(vec, hemi, ptidx);
249249
},
250250

251+
callback: function(vec, hemi, ptidx) {
252+
$.get("/picker?voxel=" + vec.x + "," + vec.y + "," + vec.z + "&vertex=" + ptidx + "&hemi=" + hemi);
253+
},
254+
251255
process_nonpick: function() {
252256
for (var i = 0; i < this.axes.length; i++) {
253257
this.markers[this.axes[i].hemi].remove(this.axes[i].group);

cortex/webgl/view.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,11 @@ def show(
325325
The port that will be used by the server. If None, a random port will be
326326
selected from the range 1024-65536. Default None
327327
pickerfun : function or None, optional
328-
Should be a function that takes two arguments, a voxel index and a vertex
329-
index. Is called whenever a location on the surface is clicked in the
330-
viewer. This can be used to print information about individual voxels or
331-
vertices, plot receptive fields, or many other uses. Default None
328+
Should be a function that takes three arguments, a 3-D voxel vector, a
329+
vertex index, and the hemisphere ("left" or "right"). Is called whenever
330+
a location on the surface is clicked in the viewer. This can be used to
331+
print information about individual voxels or vertices, plot receptive
332+
fields, or many other uses. Default None
332333
recache : bool, optional
333334
Force recreation of CTM and SVG files for surfaces. Default False
334335
template : string, optional
@@ -452,7 +453,7 @@ def show(
452453
my_viewopts[sec] = dict(options.config.items(sec))
453454

454455
if pickerfun is None:
455-
pickerfun = lambda a, b: None
456+
pickerfun = lambda *a: None
456457

457458
class CTMHandler(web.RequestHandler):
458459
def get(self, path):
@@ -888,7 +889,10 @@ def make_movie_views(self, animation, filename="brainmovie%07d.png",
888889

889890
class PickerHandler(web.RequestHandler):
890891
def get(self):
891-
pickerfun(int(self.get_argument("voxel")), int(self.get_argument("vertex")))
892+
voxel: tuple[int, int, int] = tuple(int(i) for i in self.get_argument("voxel").split(","))
893+
vertex: int = int(self.get_argument("vertex"))
894+
hemi: str = self.get_argument("hemi")
895+
pickerfun(voxel, vertex, hemi)
892896

893897
class WebApp(serve.WebApp):
894898
disconnect_on_close = autoclose

0 commit comments

Comments
 (0)