Image Processing Module
Image processing functions for qi2lab 3D MERFISH.
This module includes various utilities for image processing, such as downsampling, padding, and chunked GPU-based deconvolution.
History:
- 2024/12: Refactored repo structure.
- 2024/07: Added numba-accelerated downsampling, padding helper functions, and chunked GPU deconvolution.
Functions:
| Name | Description |
|---|---|
downsample_axis | Numba accelerated downsampling for 3D images along a specified axis. |
downsample_image_anisotropic | Numba accelerated anisotropic downsampling. |
estimate_shading | Estimate shading using stack of images and BaSiCPy. |
image_has_signal | Screen YX or ZYX data for connected signal above a robust background. |
replace_hot_pixels | Replace hot pixels with median values surrounding them. |
downsample_axis(image, level=2, axis=0)
Numba accelerated downsampling for 3D images along a specified axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image | ArrayLike | 3D image to be downsampled. | required |
level | int | Amount of downsampling. | 2 |
axis | int | Axis along which to downsample (0, 1, or 2). | 0 |
Returns:
| Name | Type | Description |
|---|---|---|
downsampled_image | ArrayLike | 3D downsampled image. |
Source code in src/merfish3danalysis/utils/imageprocessing.py
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 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
downsample_image_anisotropic(image, level=(2, 6, 6))
Numba accelerated anisotropic downsampling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image | ArrayLike | 3D image to be downsampled | required |
level | tuple[int, int, int] | anisotropic downsampling level | (2, 6, 6) |
Returns:
| Name | Type | Description |
|---|---|---|
downsampled_image | ArrayLike | downsampled 3D image |
Source code in src/merfish3danalysis/utils/imageprocessing.py
estimate_shading(images)
Estimate shading using stack of images and BaSiCPy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images | Iterable[Future] | Read futures yielding ZYX images. Pass a generator to load one stack at a time. Only YX maximum projections are retained for fitting. | required |
Returns:
| Name | Type | Description |
|---|---|---|
shading_image | ArrayLike | estimated shading image |
Source code in src/merfish3danalysis/utils/imageprocessing.py
image_has_signal(image, *, mask=None, background_sigma=5.0, minimum_pixels=9)
Screen YX or ZYX data for connected signal above a robust background.
Median-filter the Z maximum projection over 3x3 pixels to suppress isolated hot pixels. Require a connected region of at least minimum_pixels above median + background_sigma times the MAD-based noise estimate (1.4826 MAD). An optional YX mask restricts both background estimation and accepted signal. This is an intensity-contrast screen, not a calibrated significance test. Empty images/masks return False; invalid dimensions or nonfinite data raise.
Source code in src/merfish3danalysis/utils/imageprocessing.py
replace_hot_pixels(noise_map, data, threshold=375.0)
Replace hot pixels with median values surrounding them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
noise_map | ArrayLike | darkfield image collected at long exposure time to get hot pixels | required |
data | ArrayLike | ND data [broadcast_dim,z,y,x] | required |
threshold | float | threshold to determine hot pixel | 375.0 |
Returns:
| Name | Type | Description |
|---|---|---|
data | ArrayLike | hotpixel corrected data |