-
Notifications
You must be signed in to change notification settings - Fork 2
Design Pattern
Command design pattern:
Tools package stored under labels_manager.tools are designed to manipulate segmentations as numpy.arrays and are tested individually in the test folder. To make them work directly with nifty images, the class LabelsManager is implemented, with a facade design pattern. Under labels_manager/main.py, the class LabelsManager calls the methods stored in the tools package, and it is extended in a has-a relationship with Command design pattern and class composition paradigm through the "agents" classes under label_manager.agents.
An instances of the class LabelsManager access the nifty images through their paths, and apply to their data each of the specified tools.
For example to apply the tool relabel
under tools.manipulations.relabel
to the input files file{1..10}.nii.gz
in the folder input_folder
and save the relabelled segmentations in the output_folder
you can:
lm = LabelsManager(input_folder, output_folder)
for i in range(1, 11):
input_file_name = 'file{}.nii.gz'.format(i)
output_file_name = 'file{}.nii.gz'.format(i)
lm.manipulate.relabel(input_file_name, output_file_name,
[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7])