Reference
This is the reference material for the project API.
You can write any markdown here as you would in any other markdown file. You can also include images, links, and other media. Check out the list of plugins to see what extra functionality is available.
API
load_sample_data()
Load sample data.
Source code in src/napari_workshop_plugin/_sample_data.py
10 11 12 13 |
|
napari_get_reader(path)
Find the reader contribution for a path.
If path is recognised as a readable extension, return the appropriate function to read from that path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str or list of str
|
Path to file, or list of paths. |
required |
Returns:
Type | Description |
---|---|
function or None
|
If the path is a recognized format, return a function that accepts the same path or list of paths, and returns a list of layer data tuples. |
Source code in src/napari_workshop_plugin/_reader.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 |
|
read_numpy_file(path)
Take a path or list of paths and return a list of LayerData tuples.
Readers are expected to return data as a list of tuples, where each tuple is (data, [add_kwargs, [layer_type]]), "add_kwargs" and "layer_type" are both optional.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str or list of str
|
Path to file, or list of paths. |
required |
Returns:
Name | Type | Description |
---|---|---|
layer_data |
list of tuples
|
A list of LayerData tuples where each tuple in the list contains (data, metadata, layer_type), where data is a numpy array, metadata is a dict of keyword arguments for the corresponding viewer.add_* method in napari, and layer_type is a lower-case string naming the type of layer. Both "meta", and "layer_type" are optional. napari will default to layer_type=="image" if not provided |
Source code in src/napari_workshop_plugin/_reader.py
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 |
|
segmentation_widget(viewer, image, blur_sigma=2.0, disk_size=4, classes=3)
Segment cells from calcium image max projection.
- Grayscale and blur the image.
- Perform a multiotsu to separate the image into three classes: background, non-cell tissue, and cells.
- Smooth the multiotsu segmentation via disks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
viewer |
napari.Viewer
|
A viewer instance from napari |
required |
image |
napari.layers.Image
|
The image to segment from. Can be one channel or more. If more than one channel, is converted to grayscale. |
required |
blur_sigma |
float
|
The standard deviation of the gaussian blur to be applied. A higher sigma indicates more blur. By default 2.0. |
2.0
|
disk_size |
int
|
The size of the disk in pixels for smoothing. A higher disk_size indicates more smoothing. By default 4. |
4
|
classes |
int
|
The number of classes to segment into. One of the classes will be background. By default 3. Going past 5 classes is not recommended for speed. |
3
|
Source code in src/napari_workshop_plugin/_widget.py
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 |
|