How do you provide an interface for users to supply input parameters for a custom algorithm to be used within the Medical Image Labeler?
2 views (last 30 days)
Show older comments
Matt Latourette
on 23 Jan 2023
Commented: Ritish Raghav Maram
on 28 Jan 2023
Several of the built-in segmentation algorithms on the Automate tab of the Medical Image Labeler provide an interface for users to enter input parameters for the segmentation via the Algorithm Parameters button. The Medical Image Labeler provides a mechanism to create your own custom segmentation algorithm via the Add Algorithm menu's New -> Function Template and New -> Class Template options, both for slice-based and volume-based algorithms. However, I don't see any explanation in the template or in the documentation regarding how one might create a custom GUI to launch from the Algorithm Parameters button as an accompaniment to provide input parameters for a custom segmentation algorithm. Is it possible to do this? If so, how?
1 Comment
Ritish Raghav Maram
on 27 Jan 2023
Even I have the same question. I looked into the documentation but did not find any clear explanation. Thank you for rising this question! Hope someone from Mathworks responds to this.
Accepted Answer
Sailesh Sidhwani
on 27 Jan 2023
Hi Matt,
It is possible to achieve what you are asking for in the Medical Image Labeler app, however, I understand that this particular feature isn't well-documented. I'll talk to our doc team to improve the documentation for this.
First of all, this feature is only available when using the Class Template (either slice based or volume based), and not for function templates. The use of Class Templates requires an understanding of how classes work in MATLAB, but it also provides more control over how your custom automation algorithm behaves within the app. On the other hand, the Slice Templates are easy to use but do not offer granular control.
For the rest of the answer, I'll talk using Volume Based Class template but the same applies to Slice Based Class template as well.
- A Class template inherits from the following class: 'images.automation.volume.Algorithm'.By opening this class, you'll notice that there is a static member function called 'getSettings'. This method is what you'll use to implement the dialog box that can be launched with your custom automation algorithm.
- For reference, you can take a look at the sample implementation for the erode algorithm in the app: 'images.automation.volume.Erode'
- In the getSettings method, you'll need to return an object for a Settings class that you'll write. Your settings class should inherit from 'images.automation.volume.settings.Settings'. For further reference, you can take a look at the Morphology settings class in the Erode algorithm above. The entire path to the class is: 'images.automation.volume.settings.MorphologySettings'.
- If your Settings class implements the dialog box correctly, clicking Algorithm Parameters button when your Algorthim is selected will launch your dialog box.
When writing your Settings class, there are a few things to keep in mind:
- Pay attention to how the Settings class interacts with your Automation Algorithm class. For example, in the 'run' method of the Erode class, the values obj.Parameters.Radius and obj.Parameters.N are coming from the Settings class.
- Take note of the 'initialize' method in the MorphologySettings class. This is where the Parameters used by the Automation class are set. It's important to keep in mind that UI interactions from your dialog must update the Parameters struct values for it to have any impact on your Automation algorithm..
Order of operations from the app when calling an Automation algorithm:
- The app first calls your automation algorithm's getSettings static method.
- The value returned from getSettings is actually used when the constructor for your algorithm is called.
I hope this helps.
1 Comment
Ritish Raghav Maram
on 28 Jan 2023
Thank you so much sir, the above explanation is great and helpful.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!