How to develop your own Plugins#
To develop a Plugin you need to create a class inheriting from PTKPlugin
, set the appropriate property values and write the implementation in the RunPlugin()
method. You should look to existing Plugins for examples.
Plugin naming#
It is recommended not to use the prefix PTK
for your own class names, so that you can clearly distinguish between core Plugins provided by PTK and those you have developed yourself.
Modifying paths and auto-detecting new Plugins#
If you add a Plugin, it needs to be in one of the existing Plugin directories, or else you need to modify the PTKAddPaths.m
function to include your additional paths.
If you modify PTKAddPaths.m
during a Matlab session, you may need to run PTKAddPaths force
to force it to detect the new paths (restarting Matlab will always pick up the new paths).
When running Plugins using the API, PTK will find them if they are on the current path set by PTKAddPaths
.
The GUI will only display Plugins that were found in the Plugin
directories during the first run in a Matlab session. To force it to search again, close all Matlab windows then run clear all classes
to clear the memory caches.
Implement the RunPlugin()
method#
Assuming you have set the property PTKVersion = '2'
(see below), then you need to implement the following RunPlugin()
method:
methods (Static)
function results_image = RunPlugin(dataset, context, reporting)
... do some processing and set results_image
end
end
The following three parameters are passed to your Plugin when it is run by PTK:
Parameter |
Description |
---|---|
dataset |
A |
context |
The current context which PTK is asking you to process. If your Plugin supports processing over different Contexts then you may need to use this value to fetch the appropriate Context results from other Plugins |
reporting |
A PTKReporting object for progress and error reporting |
Plugin properties#
Properties determining how the Plugin is run#
Property name |
Recommended value |
Description |
---|---|---|
AllowResultsToBeCached |
|
If |
AlwaysRunPlugin |
|
If |
PluginType |
|
Tells the GUI what to do with the result of the plugin after it has been run. |
HidePluginInDisplay |
|
If |
FlattenPreviewImage |
|
Controls how the preview image displayed on the Plugin button is shown. If true then it superimposes all slices of the result to generate a preview. |
PTKVersion |
|
Determines the Plugin interface version which your Plugin implements. This determines the parameters passed into the |
Context |
`’PTKContextSet.LungROI’ |
Advanced property. The Context or ContextSet over which the Plugin will be run. When running the Plugin, PTK will convert the Context to what the Plugin is expecting. For lung analysis, most plugins run on the |