-
Notifications
You must be signed in to change notification settings - Fork 2
Design Pattern
Sebastiano Ferraris edited this page Jun 5, 2018
·
16 revisions
The code is designed around the command design pattern.
Each core function is designed to act on numpy arrays or nibabel instances, and it is tested on dummy examples.
The facade methods, acting on paths to the images in nifti format, access the core method and return another image as output.
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 do:
lt = LABelsToolkit(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)
lt.manipulate.relabel(input_file_name, output_file_name,
[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7])