Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor iteration #7

Merged
merged 5 commits into from Jan 31, 2019

Conversation

Projects
None yet
1 participant
@JoostJM
Copy link
Owner

commented Jan 31, 2019

Update logic for more modular design

  • The subsection that handles the GUI for input data (here only CSV table) is move to a separate class, inherited from new base class IteratorWidgetBase
  • This subclass has a function startBatch, which attempts to start a batch (raise Error on fail). If loading is successful, an instance derived from new base class IteratorLogicBase is returned
  • IteratorLogicBase subclass exposes functions to load a specific case (using index), and an attribute specifying the number of cases in the batch. Finally, base class exposes a function to save a mask node.
  • Widget subclass also has an attribute ValidationHandler (is set to a function in the main widget, which accepts a boolean returned by the function is_valid (specifying if the current configuration of input is valid)), which the main widget can use to control whether the start batch button should be enabled.
  • Main Widget class will call startBatch and if successful, starts an instance of the SlicerCaseIteratorLogic, which handles the control of the iterator itself. The widget holds observers for the shortcut keys and observers the onEndClose event.

This will simplify addition of new types of generator.
Adding a new type of generator will only require the user to program 2 new derived classes (derived from IteratorWidgetBase and IteratorLogicBase).

N.B. Currently does not contain code to allow switching between different types of iterator (currently only 1 available)

JoostJM added some commits Jan 30, 2019

REFACTOR: Update structure of Case Iterator
Adopt new flow:

- The subsection that handles the GUI for input data (here only CSV table) is move to a separate class, inherited from new base class `IteratorBaseWidget`
- This subclass has a function `startBatch`, which attempts to start a batch (raise Error on fail). If loading is successfull, an instance derived from new base class `IteratorBase` is returned
- `IteratorBase` subclass exposes functions to load a specific case (using index), and an attribute specifying the number of cases in the batch. Finally, base class exposes a function to save a mask node.
- Widget subclass also has an attribute `ValidationHandler` (is set to a function in the main widget, which accepts a boolean returned by the function `is_valid` (specifying if the current configuration of input is valid)), which the main widget can use to control whether the `start batch button` should be enabled.
- Main Widget class will call `startBatch` and if successful, starts an instance of the SlicerCaseIteratorLogic, which handles the control of the iterator itself. The widget holds observers for the shortcut keys and observers the onEndClose event.
ENH: Explicitly set the segmentation and master volume nodes
When redirecting to the segment editor, explicitly set the segmentation and mastervolume nodes to the main mask and image.
If no mask is specified, only set the mastervolume node.
STYL: Update documentation on case classes for iterator objects
Additionally, change the name of the iterator object itself to include "Logic"
BUG: Fix a memory leak when loading label volumes
When a mask is detected to be a label volume, it is loaded and converted to segmentation. Because the segmentation is a new node, a storage node is also added (which is used to determine the storage location upon saving the segmentation).
However, when creating a storage node using `CreateDefaultStorageNode()`, the reference count is increased. To allow correct GC, UnRegister the node after it is linked to the segmentation node.

Additionally, fix a bug due to the renaming of the IteratorLogicBase.

@JoostJM JoostJM merged commit b16c9ad into master Jan 31, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.