You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9b1cefe
Browse filesBrowse the repository at this point in the historyBrowse files
run_algorithm_func: The Python function to convert.
212
-
parameters: A dictionary of annotated parameters.
213
-
name: A name for the algorithm (doesn't accept spaces and special characters).
214
-
description: A short description to display on the algorithm doc page. Defaults to the docstring of the Python function.
215
-
tags: A list of tags (arbitrary).
216
-
project_url: A link to a related, or the original project (gets displayed on the algo doc page).
217
-
metadata_file: A path to a metadata.yaml file with algorithm metadata.
218
-
samples: A list of sample parameters for the algorithm, each represented as a dictionary mapping parameter_name to example_value. Sample images can be a Numpy array, a URL, or a local path to a file readable by `skimage.io.imread`.
219
-
tileable: Whether to allow running the algorithm tile-by-tile.
220
-
221
-
Notes
222
-
----------
223
-
- Algorithms can be converted to FastAPI servers or PyQt widgets for Napari or QuPath.
224
-
- Algorithms are associated with a Pydantic Schema that can be used to validate input parameters.
225
-
- Algorithms can be run tile-by-tile (in most cases).
226
-
- Algorithms can be run on a subset of the spatial domain defined by their inputs.
227
-
- Algorithms can provide `samples` (example inputs).
228
-
- Algorithm metadata can populate an `info` page.
216
+
run_algorithm_func : callable
217
+
The Python function to convert.
218
+
parameters : dict, optional
219
+
Parameter annotations, mapping parameter names to data layers (e.g.
220
+
`{"sigma": sk.Float(min=0, default=1.0)}`). Parameters that are not annotated
221
+
are resolved from type hints, default values, or variable names.
222
+
name : str, optional
223
+
A name for the algorithm. Defaults to the name of the function.
224
+
description : str, optional
225
+
A short description, displayed on the algorithm documentation page. Defaults
226
+
to the docstring of the function.
227
+
tags : list of str, optional
228
+
A list of tags (arbitrary), displayed on the algorithm documentation page.
229
+
project_url : str, optional
230
+
A link to a related project, or to the original project, displayed on the
231
+
algorithm documentation page.
232
+
metadata_file : str, default="metadata.yaml"
233
+
A path to a YAML file with algorithm metadata.
234
+
samples : list of dict, optional
235
+
Samples for the algorithm. Each sample is a dictionary mapping parameter
236
+
names to example values. Sample images can be NumPy arrays, URLs, or paths to
237
+
local files readable by `skimage.io.imread`.
238
+
tileable : bool, default=False
239
+
Whether the algorithm can be run tile-by-tile.
229
240
230
241
Attributes
231
242
----------
232
-
name: A name for the algorithm.
233
-
parameters_model: A JSON schema representation of algorithm parameters.
234
-
samples: A list of sample parameters, mapping parameter names to parameter values.
235
-
algo_info: A dictionary of metadata about the algorithm.
236
-
algorithms: A list containing the algorithm's name.
237
-
238
-
Methods
239
-
----------
240
-
run(): Execute the algorithm with a set of parameters.
241
-
Set `tiled=True` for tiled inference.
242
-
Raises a ValidationError when parameters are invalidated.
243
-
get_n_samples(): Get the number of samples available.
244
-
get_sample(): Get a sample by index.
245
-
info(): Access algorithm documentation.
246
-
get_parameters(): Get the algorithm parameters schema.
243
+
name : str
244
+
The name of the algorithm.
245
+
parameters_model : pydantic.BaseModel
246
+
A Pydantic model used to validate the algorithm parameters.
"""Wrap a Python function as an algorithm (sk.Algorithm). Typically used as the `@sk.algorithm(...)` decorator.
500
+
"""Convert a Python function into an algorithm.
501
+
502
+
Typically used as a decorator, with or without arguments: `@sk.algorithm` or
503
+
`@sk.algorithm(...)`.
493
504
494
505
Parameters
495
506
----------
496
-
func : The Python function to convert.
497
-
parameters : A dictionary of annotated parameters.
498
-
name: A name for the algorithm (doesn't accept spaces and special characters).
499
-
description: A short description to display on the algorithm doc page. Defaults to the docstring of the Python function.
500
-
tags: A list of tags (arbitrary).
501
-
project_url: A link to a related, or the original project (gets displayed on the algo doc page).
502
-
metadata_file: A path to a metadata.yaml file with algorithm metadata.
503
-
samples: A list of sample parameters for the algorithm, each represented as a dictionary mapping parameter_name to example_value. Sample images can be a Numpy array, a URL, or a local path to a file readable by `skimag.io.imread`.
504
-
tileable: Whether to allow running the algorithm tile-by-tile.
507
+
func : callable, optional
508
+
The Python function to convert. Passed implicitly when used as a decorator.
509
+
parameters : dict, optional
510
+
Parameter annotations, mapping parameter names to data layers (e.g.
511
+
`{"sigma": sk.Float(min=0, default=1.0)}`). Parameters that are not annotated
512
+
are resolved from type hints, default values, or variable names.
513
+
name : str, optional
514
+
A name for the algorithm. Defaults to the name of the function.
515
+
description : str, optional
516
+
A short description, displayed on the algorithm documentation page. Defaults
517
+
to the docstring of the function.
518
+
tags : list of str, optional
519
+
A list of tags (arbitrary), displayed on the algorithm documentation page.
520
+
project_url : str, optional
521
+
A link to a related project, or to the original project, displayed on the
522
+
algorithm documentation page.
523
+
metadata_file : str, default="metadata.yaml"
524
+
A path to a YAML file with algorithm metadata.
525
+
samples : list of dict, optional
526
+
Samples for the algorithm. Each sample is a dictionary mapping parameter
527
+
names to example values. Sample images can be NumPy arrays, URLs, or paths to
528
+
local files readable by `skimage.io.imread`.
529
+
tileable : bool, default=False
530
+
Whether the algorithm can be run tile-by-tile.
505
531
506
532
Returns
507
533
-------
508
-
An algorithm instance (sk.Algorithm).
534
+
Algorithm
535
+
The algorithm. When called with keyword arguments only, a decorator
Copy file name to clipboardExpand all lines: src/imaging_server_kit/core/domain.py
+23-13Lines changed: 23 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -5,25 +5,35 @@
5
5
6
6
7
7
classDomain:
8
-
"""A nD-domain defined by a size and position in global pixel space. Used to represent tile extents, and to restrict an algorithm's computation to a specific region.
8
+
"""An n-D box defined by a size and a position in global pixel coordinates.
9
+
10
+
Domains represent regions of interest and tile extents, and are used to restrict
11
+
the computation of an algorithm to a region.
9
12
10
13
Parameters
11
14
----------
12
-
size: Size of the domain in pixels, one value per dimension.
13
-
position: Position of the domain's top-left corner in global pixel space. Defaults to the origin (all zeros) if only `size` is provided.
15
+
size : tuple, optional
16
+
Size of the domain in pixels, one value per dimension.
17
+
position : tuple, optional
18
+
Position of the lower corner of the domain (top-left in 2D), in global pixel
19
+
coordinates. Defaults to the origin if only `size` is provided.
14
20
15
21
Attributes
16
22
----------
17
-
size: Size of the domain in pixels.
18
-
coords_min: The position of the top-left corner of the domain.
19
-
coords_max: The position of the bottom-right corner of the domain.
20
-
ndim: Number of dimensions.
21
-
22
-
Methods
23
-
----------
24
-
serialize(): Convert the domain to a dictionary format.
25
-
copy(): Copy the domain.
26
-
merge(): Merge another domain.
23
+
size : tuple
24
+
Size of the domain in pixels.
25
+
coords_min : tuple
26
+
Lower corner of the domain (top-left in 2D).
27
+
coords_max : tuple
28
+
Upper corner of the domain (bottom-right in 2D).
29
+
ndim : int
30
+
Number of dimensions.
31
+
32
+
Examples
33
+
--------
34
+
>>> roi = sk.Domain(position=(20, 30), size=(60, 80))
Copy file name to clipboardExpand all lines: src/imaging_server_kit/core/multialgo.py
+26-15Lines changed: 26 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -7,22 +7,27 @@
7
7
8
8
9
9
classMultiAlgorithm(AlgorithmRunner):
10
-
"""A collection of algorithms exposed under a single interface, with the target algorithm selected by name at call time. Usually created via the `sk.combine()` function rather than instantiated directly.
10
+
"""A collection of algorithms exposed under a single interface.
11
+
12
+
Collections are usually created with `sk.combine()` rather than instantiated
13
+
directly. They implement the shared
14
+
[`AlgorithmRunner`][imaging_server_kit.AlgorithmRunner] interface, where methods
15
+
take an `algorithm` argument to select an algorithm by name.
11
16
12
17
Parameters
13
18
----------
14
-
algorithms: A list of algorithm instances in the collection.
15
-
name: A name for the algorithm collection.
19
+
algorithms : list of Algorithm
20
+
The algorithms in the collection. If several algorithms have the same name,
21
+
only the last one is kept.
22
+
name : str, default="algorithms"
23
+
A name for the collection.
16
24
17
25
Attributes
18
26
----------
19
-
algorithms_dict: A dictionary mapping algorithm names to instances in the collection.
20
-
algorithms: A list of algorithm names in the collection.
21
-
22
-
Methods
23
-
----------
24
-
This class implements the same methods as the Algorithm class (via AlgorithmRunner),
25
-
but methods take an extra argument `algorithm` to identify the algorithm to use.
27
+
algorithms_dict : dict
28
+
A dictionary mapping algorithm names to algorithms.
0 commit comments