Plugins

Overview

You can add plugins to the MLR interface that allow for additional customized menu items, colormaps and interrogators. Plugins can also change the functionality of user interface items (by installing their own callbacks to existing GUI items).

Plugins that are distributed with the MLR code can be found in the directory:

mrLoadRet/Plugin

And they can be selected by running:

mlrPlugin

Which allows you to select/deselect which plugins you want to use. Note that plugins are installed when you run mrLoadRet (via the function mrOpenWindow), so if you change which plugins you are using, you will need to restart mrLoadRet for the changes to take effect.

How plugins work

Plugins live in their own folder in mrLoadRet/Plugins. They can also be put in a folder that you specify in the preference:

mrSetPref('pluginPaths','/path/to/your/plugins')

Note that this preference can be a comma-delimited list of paths if you have multiple locations where plugins can be found.

For each directory in these Plugin folders there should be a Plugin command that gives help and installs the plugin. These must be named as folderNamePlugin and have a specific calling convention. For example, the Default plugin directory is located in:

mrLoadRet/Plugins/Default

and there is a function called

mrLoadRet/Plugins/Default/DefaultPlugin.m

which is the function that mlrPlugin uses to get help and install the plugin. If you wish to write your own plugin, you should look at this function (i.e. DefaultPlugin.m) to see the correct calling convention.

mlrAdjustGUI

The plugin functions call mlrAdjustGUI to change the behavior of the GUI. This function takes different commands to adjust various aspects of the GUI. To use it, you will generally need to specify a UI interface item on the MLR window for which you want to make an adjustment (or a menu item under which you want to add a new menu item).

Every UI interface item on the MLR window can be specified by either a tag (a string that identifies it), or by the label for a menu item. Thus, the menu item under ROI called Show is called /ROI/Show and the cortical depth slider has the tag corticalDepth. These identifiers are what is called the “controlName” below and you can get a full list of all possible controlNames by doing:

mlrAdjustGUI(getMLRView,'list');

To set a property of a control:

mlrAdjustGUI(v,'set',controlName,propertyName,propertyValue);
e.g.:  mlrAdjustGUI(getMLRView,'set','baseGammaSlider','Visible','off');

Similarly, to set the callback for a control:

e.g.:  mlrAdjustGUI(getMLRView,'set','baseGammaSlider','Callback',@testCallback);

Where testCallback is a function that takes two arguments and usually begins with a snippet of code that gets the view. For example:

function testCallback(hObject,eventdata)

% get the view
v = viewGet(getfield(guidata(hObject),'viewNum'),'view');

% Do whatever you want here

NB: properties of menu items start with a capital letter: use 'callback' for a uicontrol, but 'Callback' for a menu item.

To add a new menu item:

mlrAdjustGUI(v,'add','menu',menuName,menuLocation,propertyName1,propertyValue1,...);
e.g.:  mlrAdjustGUI(getMLRView,'add','menu','Plugin','Plots','Callback',@testCallback,'Separator','on');

The above will add the menu item Plugin after the menu identified as Plots. If you wanted instead to put it at the top of the Plots menu, then set the menuLocation to /Plots/. Note that the callback function should take the same form as described as above.

To add an interrogator function as a default one (that shows up in the GUI):

mlrAdjustGUI(v,'add','interrogator',interrogatorName)
e.g.:  mlrAdjustGUI(getMLRView,'add','interrogator','eventRelatedPlot');

To add colormap functions which will show up in /Edit/Overlay:

mlrAdjustGUI(v,'add','colormap',colormapName)
e.g.: mlrAdjustGUI(getMLRView,'add','colormap','gray');

Alt Plugins

There are also a set of alternative plugins that don't come up with the default mlrPlugin. These are located under the directory mrLoadRet/PluginAlt. Each directory under that one contains a set of plugins that may be site-specific or advanced or undocumented and should only be used by those who know what they are. They are accessed by doing:

mlrPlugin('altPlugins');