|
1 | 1 | # Copyright (c) 2021-2024 The University of Texas Southwestern Medical Center.
|
2 | 2 | # All rights reserved.
|
3 |
| - |
4 | 3 | # Redistribution and use in source and binary forms, with or without
|
5 | 4 | # modification, are permitted for academic and research use only
|
6 | 5 | # (subject to the limitations in the disclaimer below)
|
|
39 | 38 | from pathlib import Path
|
40 | 39 | from os.path import isfile
|
41 | 40 | from multiprocessing.managers import ListProxy, DictProxy
|
| 41 | +import inspect |
42 | 42 |
|
43 | 43 | # Third Party Imports
|
44 | 44 | import yaml
|
45 | 45 |
|
46 | 46 | # Local Imports
|
47 |
| -from navigate.tools.common_functions import build_ref_name |
| 47 | +from navigate.tools.common_functions import build_ref_name, load_module_from_file |
| 48 | +from navigate.model.features import feature_related_functions |
48 | 49 |
|
49 | 50 |
|
50 | 51 | def get_navigate_path():
|
@@ -1097,3 +1098,23 @@ def verify_configuration(manager, configuration):
|
1097 | 1098 | "gui",
|
1098 | 1099 | {"channels": {"count": channel_count}},
|
1099 | 1100 | )
|
| 1101 | + |
| 1102 | + |
| 1103 | +def set_feature_attributes(plugin_path): |
| 1104 | + """Load feature module and set function attributes. |
| 1105 | +
|
| 1106 | + Parameters |
| 1107 | + ---------- |
| 1108 | + plugin_path : str |
| 1109 | + The path to the plugins folder. |
| 1110 | + """ |
| 1111 | + features_dir = os.path.join(plugin_path, "model", "features") |
| 1112 | + if os.path.exists(features_dir): |
| 1113 | + features = os.listdir(features_dir) |
| 1114 | + for feature in features: |
| 1115 | + feature_file = os.path.join(features_dir, feature) |
| 1116 | + if os.path.isfile(feature_file): |
| 1117 | + temp = load_module_from_file(feature, feature_file) |
| 1118 | + for c in dir(temp): |
| 1119 | + if inspect.isclass(getattr(temp, c)): |
| 1120 | + setattr(feature_related_functions, c, getattr(temp, c)) |
0 commit comments