Custom Cell Pick Segmentation Routines

Writing Custom Cell Pick Functions

When using the cell picker in the ROI/Stimulus Group Editor, custom segmentation routines can be selected from the New ROI panel when in cell picker mode by choosing Custom… from the Selection Mode drop down. When Custom… is selected, it will prompt you to enter a matlab function. This must be a function on the current function path with the following function signature:

1function xyPoints = cellPickFunc(operation, imageData, xyPoints)

The operation parameter indicates why the function is being called. It can be any of the following

  • ‘pick’ - This indicates the user clicked in a context image to attempt to pick a cell. imData contains an array representing the image data of the context image. The xyPoints input will contain the pixel location where the user clicked. When called for this operation, the function should execute its segmentation routine to indentify a cell at the specified location. If a cell is found, it should return a Nx2 matrix of XY points that define the cell in the context image. If a cell was not found, an empty array should be returned.


  • ‘dilate’ - This indicates the user clicked the Dilate button on a previously selected cell. imData contains an array representing the image data of the context image. xyPoints contains an Nx2 matrix of all the XY points that currently define the cell. When called for this operation, the function should return a new matrix of XY points for the same cell increased in size. You can define your own custom behavior for determining how much larger the cell should be.


  • ‘erode’ - This indicates the user clicked the Erode button on a previously selected cell. imData contains an array representing the image data of the context image. xyPoints contains an Nx2 matrix of all the XY points that currently define the cell. When called for this operation, the function should return a new matrix of XY points for the same cell decreased in size. You can define your own custom behavior for determining how much smaller the cell should be.