def _instantiate_cats(found_cats): """ Instantiate imported categories and return a list of instantiated categories. Create a list with methods that represent a pipeline with selected algorithms and predefined settings. <When the Category object is instantiated it automatically imports and creates a list of algorithms that belong to it> Args: | *found_cats*: a list of found category file names Vars: | *cats_inst*: a list of found and instantiated methods | *categories*: a dictionary of algs where {Algorithm: Category} Returns: | *categories*: a list with Method instances """ cats_inst = [] for cat_path in found_cats: cat_name = os.path.basename(cat_path).split('.')[0] cat = SourceFileLoader(cat_name, cat_path).load_module() inst = cat.CatBody() cats_inst.append(inst) # sort the cats order = [ 'Preprocessing', 'Segmentation', 'Graph Detection', 'Graph Filtering' ] # in case we have custom cats, add them for cat in cats_inst: if cat.name not in order: order.append(cat.name) cats_inst.sort(key=lambda x: order.index(x.name)) # create a dict of {Category name: Category instance} cats = od() for category in cats_inst: cats[category.name] = category return cats