infer_subc/workflows
Code for classes which interface with the sibling napari plugin repo organelle-segmenter-plugin
documented at ndcn.github.io/organelle-segmenter-plugin
infer_subc/workflow for napari plugin
The workflow
sub-module is designed to interface with this repo (infer_subc
) and the sibling napari plugin repo organelle-segmenter-plugin
workflow sub-modules
Workflow
Represents an executable aics-segmentation workflow This class provides the functionality to run a workflow using an image input according to the steps defined in its WorkflowDefinition.
Source code in infer_subc/workflow/workflow.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
execute_all()
Execute all steps in the Workflow
default parameters will be used to execute the steps. To execute a step
with user-provided parameters, use execute_next()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
none |
None |
required |
Returns (np.ndarray): Result of the final WorkflowStep.
Source code in infer_subc/workflow/workflow.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
execute_next(parameters=None)
Execute the next workflow step.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameters |
Dict[str, Any]
|
Optional dictionary of parameter inputs to use when executing the step If parameters are not provided, the step's default parameters will be used |
None
|
Returns result (np.ndarray): resultant image from running the next workflow step
Source code in infer_subc/workflow/workflow.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
execute_step(i, parameters, selected_image)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
i |
int
|
step number (0 indexed) that you want to run |
required |
Returns
Source code in infer_subc/workflow/workflow.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
get_most_recent_result()
Get the result from the last executed WorkflowStep.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
none |
None |
required |
Returns (np.ndarray): Result of the last executed WorkflowStep, returns the starting image if no Workflowsteps have been run.
Source code in infer_subc/workflow/workflow.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
get_next_step()
Get the next step to be performed
Parameters:
Name | Type | Description | Default |
---|---|---|---|
none |
None |
required |
Returns (WorkflowStep): next WorkflowStep object to perform on image None if all steps have already been executed
Source code in infer_subc/workflow/workflow.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
get_result(step_index)
Get the result image for a workflow step.
You must call execute() on the workflow step in order to produce a result first before calling this function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
step_index |
int
|
index of the WorkflowStep in the |
required |
Returns self.image (np.ndarray): Result of performing workflow step on the given image None if step has not been executed yet.
Source code in infer_subc/workflow/workflow.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
is_done()
Check if all WorkflowSteps have been executed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
none |
None |
required |
Returns (bool): True if all WorkflowSteps have been executed, False if not
Source code in infer_subc/workflow/workflow.py
180 181 182 183 184 185 186 187 188 189 190 |
|
reset()
Reset the workflow so it can be run again
Source code in infer_subc/workflow/workflow.py
34 35 36 37 38 39 |
|
ConfigurationException
Bases: Exception
Raised when errors are encountered reading from Configuration files
Source code in infer_subc/workflow/workflow_config.py
11 12 13 14 15 16 |
|
WorkflowConfig
Provides access to structure workflow configuration
Source code in infer_subc/workflow/workflow_config.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
get_all_functions()
Get the list of all available Functions from configuration
Source code in infer_subc/workflow/workflow_config.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
get_available_workflows()
Get the list of all workflows available through configuration
Source code in infer_subc/workflow/workflow_config.py
28 29 30 31 32 33 34 35 36 |
|
get_workflow_definition(workflow_name)
Get a WorkflowDefinition for the given workflow from the corresponding prebuilt json structure config
Source code in infer_subc/workflow/workflow_config.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
get_workflow_definition_from_config_file(file_path, workflow_name=None, prebuilt=False)
Get a WorkflowDefinition based off the given json configuration file
Source code in infer_subc/workflow/workflow_config.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
save_workflow_definition_as_json(workflow_definition, output_file_path)
Save a WorkflowDefinition as a json config file
Source code in infer_subc/workflow/workflow_config.py
86 87 88 89 90 91 92 93 94 |
|
SegmentationWrap
dataclass
Simple dataclass wrapper for segmentations of organelles + masks TODO: make a nice reppr
Source code in infer_subc/workflow/workflow_definition.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
WorkflowDefinition
dataclass
Definition of a custom aics-segmentation Workflow loaded from file.
This class only defines the workflow (i.e. the workflow characteristics and steps) and is used either for building an executable Workflow object or to access information about the Workflow without needing to execute it
Source code in infer_subc/workflow/workflow_definition.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
WorkflowEngine
aicssegmentation workflow engine Use this class to access and execute aicssegmentation structure workflows
Source code in infer_subc/workflow/workflow_engine.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
workflow_definitions: List[WorkflowDefinition]
property
List of all workflow definitions
add_workflow(file_path, workflow_name=None)
add WorkflowDefinition to list from a configuration file
Source code in infer_subc/workflow/workflow_engine.py
47 48 49 50 51 52 53 54 |
|
get_executable_batch_workflow(workflow_name, input_dir, output_dir, segmentation_name, channel_index=-1)
Get an executable BatchWorkflow object
inputs
workflow_name (str): Name of the workflow to load input_dir (str|Path): Directory containing input files for the batch processing output_dir (str|Path): Output directory for the batch processing channel_index (int): Index of the channel to process in each image (usually a structure channel)
Source code in infer_subc/workflow/workflow_engine.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
get_executable_batch_workflow_from_config_file(file_path, input_dir, output_dir, segmentation_name, channel_index=-1)
Get an executable batch workflow object from a configuration file
inputs
file_path (str|Path): Path to the workflow configuration file input_dir (str|Path): Directory containing input files for the batch processing output_dir (str|Path): Output directory for the batch processing channel_index (int): Index of the channel to process in each image (usually a structure channel)
Source code in infer_subc/workflow/workflow_engine.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
get_executable_batch_workflows_from_config_file(file_path, input_dir, output_dir, segmentation_names, channel_index=-1)
Get an executable batch workflow object from a configuration file
inputs
file_path (str|Path): Path to the workflow configuration file input_dir (str|Path): Directory containing input files for the batch processing output_dir (str|Path): Output directory for the batch processing channel_index (int): Index of the channel to process in each image (usually a structure channel)
Source code in infer_subc/workflow/workflow_engine.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
get_executable_workflow(workflow_name, input_image)
Get an executable workflow object
inputs
workflow_name (str): Name of the workflow to load input_image (ndarray): input image for the workflow to execute on
Source code in infer_subc/workflow/workflow_engine.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
get_executable_workflow_from_config_file(file_path, input_image)
Get an executable workflow object from a configuration file
inputs
file_path (str|Path): Path to the workflow configuration file input_image (ndarray): input image for the workflow to execute on
Source code in infer_subc/workflow/workflow_engine.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
WorkflowStep
dataclass
Represents a single step in an aicssegmentation Workflow
Source code in infer_subc/workflow/workflow_step.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
execute(input_images, parameters=None)
Execute this workflow step on the given input image and return the result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_images |
List[np.ndarray]
|
List of image inputs to perform this workflow step on, generally parent image |
required |
parameters |
Dict
|
Dictionary of parameters to pass to the underlying function |
None
|
Returns self.result (np.ndarray): Result of performing workflow step on the given image.
Source code in infer_subc/workflow/workflow_step.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|