napari_ndev.image_overview
#
Function and class to create and manage image overviews with stackview.
It includes a function image_overview
to generate an overview of images
and a class ImageOverview
to generate and save image overviews.
ImageOverview
#
A class for generating and saving image overviews.
Use this class to prevent a memory leak otherwise generated by the image_overview() function when show=True. For some reason, preventing the memory leak requires the use of a class instead of a function, and show=False.
Source code in src/napari_ndev/image_overview.py
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 |
|
__init__
#
__init__(image_sets, fig_scale=(3, 3), fig_title='', scalebar=None, show=False)
Initialize an ImageOverivew object.
Parameters:
-
image_sets
#ImageSet, list of ImageSet, dict, or list of dict
) –A list of dictionaries, each containing an image set. Each image set should be a dictionary containing the following keys: - image (list): A list of images to display. - title (list of str, optional): The title of the image set. - colormap (list of str, optional): The colormap to use. "labels" will display the image as labels. - labels (list of bool, optional): Whether to display labels. - **kwargs: Additional keyword arguments to pass to stackview.imshow.
-
fig_scale
#tuple of float
, default:(3, 3)
) –The scale of the plot. (Width, Height). Values lower than 2 are likely to result in overlapping text. Increased values increase image size. Defaults to (3, 3).
-
fig_title
#str
, default:''
) –The title of the image overview. Default is an empty string.
-
scalebar
#float or dict
, default:None
) –The scalebar to add to the image overview. If a float, it is used as the dx parameter for the scalebar. If a dict, all **kwargs are passed to the matplotlib_scalebar.scalebar.ScaleBar class. Defaults to None.
-
show
#bool
, default:False
) –Whether to display the generated overview. Default is False. Prevents memory leak when False.
Source code in src/napari_ndev/image_overview.py
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 |
|
save
#
save(directory=None, filename=None)
Save the generated image overview with matplotlib.savefig.
Parameters:
-
directory
#str
, default:None
) –The directory to save the image overview. If not provided, the current directory will be used.
-
filename
#str
, default:None
) –The filename of the saved image overview. If not provided, a default filename will be used.
Source code in src/napari_ndev/image_overview.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
ImageSet
dataclass
#
Image information passed to stackview.imshow
.
Parameters:
-
image
#list
) –A list of image data to display.
-
title
#list of str
, default:None
) –The title of the image.
-
colormap
#list of str
, default:None
) –The colormap to use. "labels" will display the image as labels.
-
labels
#list of bool
, default:None
) –Whether to display image as a labels.
-
min_display_intensity
#list of float
, default:None
) –The minimum display intensity, in the same units as the image. Use
np.percentile(image, 0.1)
for 0.1th percentile. -
max_display_intensity
#list of float
, default:None
) –The maximum display intensity, in the same units as the image. Use
np.percentile(image, 99.8)
for 99.9th percentile.
Source code in src/napari_ndev/image_overview.py
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 |
|
__post_init__
#
__post_init__()
Set default values for colormap and labels if not provided.
Source code in src/napari_ndev/image_overview.py
51 52 53 54 55 56 |
|
image_overview
#
image_overview(image_sets, fig_scale=(3, 3), fig_title='', scalebar=None)
Create an overview of images.
Parameters:
-
image_sets
#ImageSet, list of ImageSet, dict, or list of dict
) –A list of
napari_ndev.image_overview.ImageSet objects containing image information to display for
stackview.imshow`. Using a dict is deprecated and will be removed in the future, but is supported by passing the dictionary keys as arguments to the ImageSet constructor. Will be removed in v1.0.0. -
fig_scale
#tuple of float
, default:(3, 3)
) –The scale of the plot. (Width, Height). Values lower than 2 are likely to result in overlapping text. Increased values increase image size. Defaults to (3, 3).
-
fig_title
#str
, default:''
) –The title of the plot. Defaults to an empty string.
-
scalebar
#float or dict
, default:None
) –The scalebar to add to the image overview. If a float, it is used as the dx parameter for the scalebar. If a dict, all **kwargs are passed to the matplotlib_scalebar.scalebar.ScaleBar class. Defaults to None.
Returns:
-
fig
(Figure
) –The matplotlib figure object containing the image overview.
Source code in src/napari_ndev/image_overview.py
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 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
|