write a custom segmentation script

To write a custom segmentation algorithm, you should have access to MATLAB and be running LEVER from the source code.

All file paths below are relative to the src\MATLAB folder where you downloaded the LEVER source code. When you see a folder named ‘+Segmentation’, you access it using ‘Segmentation.FunctionName’. If you type ‘Segmentation.’ and press the tab key you will see a list of all functions in the +Segmentation folder that you can use. Note the ‘.m’ extension is omitted.

For a custom segmentation, you must modify the following files:

Segmentation.FrameSegmentor.m — copy this file to whatever you call your segmentation algorithm, e.g. Segmentation.FrameSegmentor_MyCustomSegmentation.m. Modify the file as needed – this is where your segmentation code goes.

HINT: we generally find it easier to develop/debug a frame segmentation outside of the LEVER environment, and then copy your segmentation functions into the LEVER world.

Load.GetSupportedCellTypes.m — you need to add your new segmentation algorithm here. Copy one of the existing calls to SupportedTypes = addCellType(…)’, and rename it to your @Segmentation.FrameSegmentor_MyCustomSegmentation. You can set the default tracking parameters here as well.¬† You can specify a custom¬†resegmentation routine as well, or just use the same frame segmentor. You can also specify a range of parameters that should be searched over during resegmentation – this will allow you to e.g. vary a threshold iteratively until a desired segmentation is obtained.