PySPIM Core API Reference¶
pyspim
¶
Modules¶
conv
¶
data
¶
Modules¶
dispim
¶
utilities for loading data acquired in micro-manager with the ASI diSPIM plugin
uManagerAcquisition(path: os.PathLike, multi_pos: bool = False, xp: ModuleType = numpy)
¶uManagerAcquisition Create new acquisition object for fetching raw acquisition data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
PathLike
|
path to root directory of acquisition |
required |
multi_pos
|
bool
|
flag for if this is a multi-position acquisition. Defaults to False. |
False
|
xp
|
ModuleType
|
array module to load data into ( |
numpy
|
Source code in packages/pyspim/src/pyspim/data/dispim.py
parse_position_list(path: os.PathLike) -> numpy.ndarray
¶parse_position_list Parse uManager position list into numpy array
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
PathLike
|
path to the PositionList.pos file |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: 6-column array [position_index, grid_z, grid_y, z, y, x] |
Source code in packages/pyspim/src/pyspim/data/dispim.py
subtract_constant_uint16arr(arr: NDArray, const: int) -> NDArray
¶subtract_constant_uint16arr Subtract constant value from uint16 array, preventing underflow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
NDArray
|
input array |
required |
const
|
int
|
value to subtract |
required |
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/data/dispim.py
decon
¶
Functions¶
Modules¶
rl
¶
dualview_fft
¶Deconvolution algorithms for jointly deconvolving dual-view microscopy data.
References¶
[1] Wu, et. al., "Spatially isotropic four-dimensional...", doi:10.1038/nbt.2713 [2] Preibsch, et al. "Efficient Bayesian-based...", doi:10.1038/nmeth.2929 [3] Guo, et al. "Rapid image deconvolution..." doi:10.1038/s41587-020-0560-x [4] Anconelli, B., et al. "Reduction of boundary effects...", doi:10.1051/0004-6361:20053848
deconvolve(view_a: NDArray, view_b: NDArray, est_i: NDArray | None, psf_a: NDArray | Iterable[NDArray], psf_b: NDArray | Iterable[NDArray], backproj_a: NDArray | Iterable[NDArray], backproj_b: NDArray | Iterable[NDArray], decon_function: str, num_iter: int, epsilon: float, req_both: bool, boundary_correction: bool, zero_padding: Optional[PadType], boundary_sigma_a: float, boundary_sigma_b: float, verbose: bool) -> NDArray
¶Joint deconvolution of 2 views into a single one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
NDArray
|
array from 1st view |
required |
view_b
|
NDArray
|
array from 2nd view |
required |
est_i
|
NDArray | None
|
initial estimate |
required |
psf_a
|
NDArray | Iterable[NDArray]
|
psf arrays for view A (single one, or 1 per channel) |
required |
psf_b
|
NDArray | Iterable[NDArray]
|
psf arrays for view B (single, or 1 per channel) |
required |
backproj_a
|
NDArray | Iterable[NDArray]
|
backprojector array(s) for view A |
required |
backproj_b
|
NDArray | Iterable[NDArray]
|
backprojector array(s) for view B |
required |
decon_function
|
str
|
style of deconvolution to use |
required |
num_iter
|
int
|
number of iterations |
required |
epsilon
|
float
|
small parameter to prevent division by zero |
required |
req_both
|
bool
|
set all areas where either view doesn't have data to 0 |
required |
boundary_correction
|
bool
|
do boundary correction |
required |
zero_padding
|
Optional[PadType]
|
zero padding for boundary correction |
required |
boundary_sigma_a
|
float
|
significance level for pixels, view a |
required |
boundary_sigma_b
|
float
|
significance level for pixels, view b |
required |
verbose
|
bool
|
show progressbar for iterations |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
input array is not 3 or 4D |
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_fft.py
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 | |
joint_rl_dispim(view_a: NDArray, view_b: NDArray, est_i: NDArray, psf_a: NDArray, psf_b: NDArray, backproj_a: Optional[NDArray] = None, backproj_b: Optional[NDArray] = None, num_iter: int = 10, epsilon: float = 1e-05, boundary_correction: bool = True, req_both: bool = False, zero_padding: Optional[PadType] = None, boundary_sigma_a: float = 0.01, boundary_sigma_b: float = 0.01, verbose: bool = False) -> NDArray
¶joint_rl_dispim Modified Richardson-Lucy joint deconvolution, as described in [1].
originally developed by the Shroff group at the NIH for use in diSPIM imaging. NOTE: boundary correction is not implemented for this method, as at the time of writing, there is no known way of doing this
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
NDArray
|
data array corresponding to first view (A) |
required |
view_b
|
NDArray
|
data array corresponding to second view (B) |
required |
est_i
|
NDArray
|
initial estimate for deconvolution. If |
required |
psf_a
|
NDArray
|
array with real-space point spread function for view A |
required |
psf_b
|
NDArray
|
array with real-space point spread function for view B |
required |
backproj_a
|
NDArray
|
array with real-space backprojector for view A. If |
None
|
backproj_b
|
NDArray
|
array with real-space backprojector for view B. If |
None
|
num_iter
|
int
|
number of iterations to deconvolve for. Defaults to 10. |
10
|
epsilon
|
float
|
small parameter to prevent division by zero errors. Defaults to 1e-5. |
1e-05
|
boundary_correction
|
bool
|
correct boundary effects, defaults to True. |
True
|
req_both
|
bool
|
only deconvolve areas where views a & b have data, defaults to False. |
False
|
zero_padding
|
PadType
|
amount of zero-padding to add to each axis, defaults to None. if None, each axis of size N is padded on each side by N/2 so that the padded image has dimension 2N in that axis. |
None
|
boundary_sigma_a
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
0.01
|
boundary_sigma_b
|
float
|
threshold for determining significant pixels in view B, defaults to 1e-2. |
0.01
|
verbose
|
bool
|
display progress bar, defaults to False |
False
|
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_fft.py
efficient_bayesian_backprojectors(psf_a: NDArray, psf_b: NDArray) -> Tuple[NDArray, NDArray]
¶efficient_bayesian_backprojectors Calculate proper backprojectors for "Efficient Bayesian" deconvolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psf_a
|
NDArray
|
point spread function for view A |
required |
psf_b
|
NDArray
|
point spread function for view B |
required |
Returns:
| Type | Description |
|---|---|
Tuple[NDArray, NDArray]
|
Tuple[NDArray,NDArray]: tuple of backprojectors, one for each view. |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_fft.py
efficient_bayesian(view_a: NDArray, view_b: NDArray, est_i: NDArray, psf_a: NDArray, psf_b: NDArray, num_iter: int = 10, epsilon: float = 1e-05, boundary_correction: bool = True, req_both: bool = False, zero_padding: Optional[PadType] = None, boundary_sigma_a: float = 0.01, boundary_sigma_b: float = 0.01, verbose: bool = False) -> NDArray
¶efficient_bayesian Efficient bayesian multiview deconvolution.
Originally described in [2], this is just additive joint deconvolution with backprojectors calculated as described in the "quadruple-view deconvolution" section of [3]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
NDArray
|
data array corresponding to first view (A) |
required |
view_b
|
NDArray
|
data array corresponding to second view (B) |
required |
est_i
|
NDArray
|
initial estimate for deconvolution. If |
required |
psf_a
|
NDArray
|
array with real-space point spread function for view A |
required |
psf_b
|
NDArray
|
array with real-space point spread function for view B |
required |
backproj_a
|
NDArray
|
array with real-space backprojector for view A. If |
required |
backproj_b
|
NDArray
|
array with real-space backprojector for view B. If |
required |
num_iter
|
int
|
number of iterations to deconvolve for. Defaults to 10. |
10
|
epsilon
|
float
|
small parameter to prevent division by zero errors. Defaults to 1e-5. |
1e-05
|
boundary_correction
|
bool
|
correct boundary effects, defaults to True. |
True
|
req_both
|
bool
|
only deconvolve areas where views a & b have data, defaults to False. |
False
|
zero_padding
|
PadType
|
amount of zero-padding to add to each axis, defaults to None. if None, each axis of size N is padded on each side by N/2 so that the padded image has dimension 2N in that axis. |
None
|
boundary_sigma_a
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
0.01
|
boundary_sigma_b
|
float
|
threshold for determining significant pixels in view B, defaults to 1e-2. |
0.01
|
verbose
|
bool
|
display progress bar, defaults to False |
False
|
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_fft.py
additive_joint_rl(view_a: NDArray, view_b: NDArray, est_i: NDArray, psf_a: NDArray, psf_b: NDArray, backproj_a: Optional[NDArray] = None, backproj_b: Optional[NDArray] = None, num_iter: int = 10, epsilon: float = 1e-05, boundary_correction: bool = True, req_both: bool = False, zero_padding: Optional[PadType] = None, boundary_sigma_a: float = 0.01, boundary_sigma_b: float = 0.01, verbose: bool = False) -> NDArray
¶additive_joint_rl Additive joint deconvolution.
With boundary correction turned off, each view is deconvolved separately and then averaged at each iteration. With boundary correction turned on, an ordered subset EM algorithm from [4] is used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
NDArray
|
data array corresponding to first view (A) |
required |
view_b
|
NDArray
|
data array corresponding to second view (B) |
required |
est_i
|
NDArray
|
initial estimate for deconvolution. If |
required |
psf_a
|
NDArray
|
array with real-space point spread function for view A |
required |
psf_b
|
NDArray
|
array with real-space point spread function for view B |
required |
backproj_a
|
NDArray
|
array with real-space backprojector for view A. If |
None
|
backproj_b
|
NDArray
|
array with real-space backprojector for view B. If |
None
|
num_iter
|
int
|
number of iterations to deconvolve for. Defaults to 10. |
10
|
epsilon
|
float
|
small parameter to prevent division by zero errors. Defaults to 1e-5. |
1e-05
|
boundary_correction
|
bool
|
correct boundary effects, defaults to True. |
True
|
req_both
|
bool
|
only deconvolve areas where views a & b have data, defaults to False. |
False
|
zero_padding
|
PadType
|
amount of zero-padding to add to each axis, defaults to None. if None, each axis of size N is padded on each side by N/2 so that the padded image has dimension 2N in that axis. |
None
|
boundary_sigma_a
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
0.01
|
boundary_sigma_b
|
float
|
threshold for determining significant pixels in view B, defaults to 1e-2. |
0.01
|
verbose
|
bool
|
display progress bar, defaults to False |
False
|
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_fft.py
estimate_initialization(view_a: NDArray, view_b: NDArray, init_constant: bool) -> NDArray
¶estimate_initialization Initialize estimate for deconvolution
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
NDArray
|
input volume, view A |
required |
view_b
|
NDArray
|
input volume, view B |
required |
init_constant
|
bool
|
initialize as constant matrix, otherwise (A + B)/2 |
required |
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_fft.py
dualview_sep
¶Separable deconvolution of dual-view volumes.
TODO: add more detail here.
deconvolve(view_a: NDArray, view_b: NDArray, est_i: NDArray | None, psf_az: NDArray | Iterable[NDArray], psf_ay: NDArray | Iterable[NDArray], psf_ax: NDArray | Iterable[NDArray], psf_bz: NDArray | Iterable[NDArray], psf_by: NDArray | Iterable[NDArray], psf_bx: NDArray | Iterable[NDArray], bp_az: NDArray | Iterable[NDArray], bp_ay: NDArray | Iterable[NDArray], bp_ax: NDArray | Iterable[NDArray], bp_bz: NDArray | Iterable[NDArray], bp_by: NDArray | Iterable[NDArray], bp_bx: NDArray | Iterable[NDArray], decon_function: str, num_iter: int, epsilon: float, boundary_correction: bool, zero_padding: PadType, boundary_sigma_a: float, boundary_sigma_b: float, verbose: bool) -> NDArray
¶deconvolve Joint deconvolution of the 2 input views into a single volume.
Input volumes should be either 3D (ZRC) or 4D (CZRC).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
NDArray
|
input volume from first view (A) |
required |
view_b
|
NDArray
|
input volume from second view (B) |
required |
est_i
|
NDArray | None
|
initial estimate for deconvolution. If |
required |
psf_az
|
NDArray | Iterable[NDArray]
|
psf for view a in z-direction |
required |
psf_ay
|
NDArray | Iterable[NDArray]
|
psf for view a in y-direction |
required |
psf_ax
|
NDArray | Iterable[NDArray]
|
psf for view a in x-direction |
required |
psf_bz
|
NDArray | Iterable[NDArray]
|
psf for view b in z-direction |
required |
psf_by
|
NDArray | Iterable[NDArray]
|
psf for view b in y-direction |
required |
psf_bx
|
NDArray | Iterable[NDArray]
|
psf for view b in x-direction |
required |
bp_az
|
NDArray | Iterable[NDArray]
|
backprojector for view a in z-direction |
required |
bp_ay
|
NDArray | Iterable[NDArray]
|
backprojector for view a in y-direction |
required |
bp_ax
|
NDArray | Iterable[NDArray]
|
backprojector for view a in x-direction |
required |
bp_bz
|
NDArray | Iterable[NDArray]
|
backprojector for view b in z-direction |
required |
bp_by
|
NDArray | Iterable[NDArray]
|
backprojector for view b in y-direction |
required |
bp_bx
|
NDArray | Iterable[NDArray]
|
backprojector for view b in x-direction |
required |
decon_function
|
str
|
deconvolution function to use. One of |
required |
num_iter
|
int
|
number of deconvolution iterations |
required |
epsilon
|
float
|
small parameter for preventing division by zero |
required |
boundary_correction
|
bool
|
whether or not to do boundary correction |
required |
zero_padding
|
Optional[PadType]
|
zero padding for boundary correction |
required |
boundary_sigma_a
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
boundary_sigma_b
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
verbose
|
bool
|
show progress bar for iterations |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if input volume isn't 3- (single channel) or 4D (multichannel). |
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_sep.py
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 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
additive_joint_rl(view_a: cupy.ndarray, view_b: cupy.ndarray, est_i: cupy.ndarray, psf_az: cupy.ndarray, psf_ay: cupy.ndarray, psf_ax: cupy.ndarray, psf_bz: cupy.ndarray, psf_by: cupy.ndarray, psf_bx: cupy.ndarray, bp_az: cupy.ndarray, bp_ay: cupy.ndarray, bp_ax: cupy.ndarray, bp_bz: cupy.ndarray, bp_by: cupy.ndarray, bp_bx: cupy.ndarray, num_iter: int, epsilon: float, boundary_correction: bool, zero_padding: PadType, boundary_sigma_a: float, boundary_sigma_b: float, conv_module: Optional[cupy.RawModule], launch_pars: Optional[CuLaunchParameters], verbose: bool) -> cupy.ndarray
¶additive_joint_rl Additive joint RL deconvolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
ndarray
|
input volume for view A |
required |
view_b
|
ndarray
|
input volume for view B |
required |
est_i
|
ndarray
|
initial estimate |
required |
psf_az
|
ndarray
|
PSF for view A, z-direction |
required |
psf_ay
|
ndarray
|
PSF for view A, y-direction |
required |
psf_ax
|
ndarray
|
PSF for view A, x-direction |
required |
psf_bz
|
ndarray
|
PSF for view B, z-direction |
required |
psf_by
|
ndarray
|
PSF for view B, y-direction |
required |
psf_bx
|
ndarray
|
PSF for view B, x-direction |
required |
bp_az
|
ndarray
|
backprojector for view A, z-direction |
required |
bp_ay
|
ndarray
|
backprojector for view A, y-direction |
required |
bp_ax
|
ndarray
|
backprojector for view A, x-direction |
required |
bp_bz
|
ndarray
|
backprojector for view B, z-direction |
required |
bp_by
|
ndarray
|
backprojector for view B, y-direction |
required |
bp_bx
|
ndarray
|
backprojector for view B, x-direction |
required |
num_iter
|
int
|
number of deconvolution iterations |
required |
epsilon
|
float
|
small parameter to prevent division by zero |
required |
boundary_correction
|
bool
|
whether or not to do boundary correction |
required |
zero_padding
|
Optional[PadType]
|
zero-padding for boundary correction |
required |
boundary_sigma_a
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
boundary_sigma_b
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
conv_module
|
Optional[RawModule]
|
|
required |
launch_pars
|
Optional[CuLaunchParameters]
|
kernel launch parameters. If |
required |
verbose
|
bool
|
description |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
cupy.ndarray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_sep.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | |
joint_rl_dispim(view_a: cupy.ndarray, view_b: cupy.ndarray, est_i: cupy.ndarray, psf_az: cupy.ndarray, psf_ay: cupy.ndarray, psf_ax: cupy.ndarray, psf_bz: cupy.ndarray, psf_by: cupy.ndarray, psf_bx: cupy.ndarray, bp_az: cupy.ndarray, bp_ay: cupy.ndarray, bp_ax: cupy.ndarray, bp_bz: cupy.ndarray, bp_by: cupy.ndarray, bp_bx: cupy.ndarray, num_iter: int, epsilon: float, boundary_correction: bool, zero_padding: PadType, boundary_sigma_a: float, boundary_sigma_b: float, conv_module: Optional[cupy.RawModule], launch_pars: Optional[CuLaunchParameters], verbose: bool) -> cupy.ndarray
¶Joint deconvolution specifically for diSPIM volumes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
ndarray
|
input volume for view A |
required |
view_b
|
ndarray
|
input volume for view B |
required |
est_i
|
ndarray
|
initial estimate |
required |
psf_az
|
ndarray
|
PSF for view A, z-direction |
required |
psf_ay
|
ndarray
|
PSF for view A, y-direction |
required |
psf_ax
|
ndarray
|
PSF for view A, x-direction |
required |
psf_bz
|
ndarray
|
PSF for view B, z-direction |
required |
psf_by
|
ndarray
|
PSF for view B, y-direction |
required |
psf_bx
|
ndarray
|
PSF for view B, x-direction |
required |
bp_az
|
ndarray
|
backprojector for view A, z-direction |
required |
bp_ay
|
ndarray
|
backprojector for view A, y-direction |
required |
bp_ax
|
ndarray
|
backprojector for view A, x-direction |
required |
bp_bz
|
ndarray
|
backprojector for view B, z-direction |
required |
bp_by
|
ndarray
|
backprojector for view B, y-direction |
required |
bp_bx
|
ndarray
|
backprojector for view B, x-direction |
required |
num_iter
|
int
|
number of deconvolution iterations |
required |
epsilon
|
float
|
small parameter to prevent division by zero |
required |
boundary_correction
|
bool
|
whether or not to do boundary correction |
required |
zero_padding
|
Optional[PadType]
|
zero-padding for boundary correction |
required |
boundary_sigma_a
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
boundary_sigma_b
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
conv_module
|
Optional[RawModule]
|
|
required |
launch_pars
|
Optional[CuLaunchParameters]
|
kernel launch parameters. If |
required |
verbose
|
bool
|
description |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
cupy.ndarray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_sep.py
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 | |
deconvolve_chunkwise(view_a: zarr.Array, view_b: zarr.Array, out: zarr.Array, chunk_size: int | Tuple[int, int, int], overlap: int | Tuple[int, int, int], sigma_az: float, sigma_ay: float, sigma_ax: float, sigma_bz: float, sigma_by: float, sigma_bx: float, kernel_radius_z: int, kernel_radius_y: int, kernel_radius_x: int, decon_function: str, num_iter: int, epsilon: float, boundary_correction: bool, zero_padding: PadType, boundary_sigma_a: float, boundary_sigma_b: float, verbose: bool)
¶Joint deconvolution of the input views A & B, done chunk-by-chunk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
Array
|
zarr array for view A data |
required |
view_b
|
Array
|
zarr array for view B data |
required |
out
|
Array
|
zarr array to place deconvolved, output data into |
required |
chunk_size
|
int | Tuple[int, int, int]
|
size of chunks |
required |
overlap
|
int | Tuple[int, int, int]
|
amount of overlap between chunks |
required |
sigma_az
|
float
|
standard deviation of PSF (assumed Gaussian) for view A in z-direction |
required |
sigma_ay
|
float
|
standard deviation of PSF (assumed Gaussian) for view A in y-direction |
required |
sigma_ax
|
float
|
standard deviation of PSF (assumed Gaussian) for view A in x-direction |
required |
sigma_bz
|
float
|
standard deviation of PSF (assumed Gaussian) for view B in z-direction |
required |
sigma_by
|
float
|
standard deviation of PSF (assumed Gaussian) for view B in y-direction |
required |
sigma_bx
|
float
|
standard deviation of PSF (assumed Gaussian) for view B in x-direction |
required |
kernel_radius_z
|
int
|
radius of PSF kernel in z-direction |
required |
kernel_radius_y
|
int
|
radius of PSF kernel in y-direction |
required |
kernel_radius_x
|
int
|
radius of PSF kernel in x-direction |
required |
decon_function
|
str
|
deconvolution function to use. Either |
required |
num_iter
|
int
|
number of deconvolution iterations. |
required |
epsilon
|
float
|
small parameter to prevent division by zero |
required |
boundary_correction
|
bool
|
whether or not to do boundary correction |
required |
zero_padding
|
Optional[PadType]
|
zero-padding for boundary correction |
required |
boundary_sigma_a
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
boundary_sigma_b
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
verbose
|
bool
|
display a progress bar showing how many chunks have been/will be computed. |
required |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_sep.py
821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 | |
singleview_fft
¶Single-view Richardson Lucy deconvolution using FFT-space convolution.
References¶
[1] Bertero & Boccacci, "A simple method...", doi:10.1051/0004-6361:20052717
richardson_lucy(image: NDArray, psf: NDArray, bp: NDArray, num_iter: int = 50, boundary_correction: bool = True, epsilon: Optional[float] = None, boundary_padding: Optional[int] = None, boundary_sigma: float = 0.01, verbose: bool = False) -> NDArray
¶richardson_lucy Richardson-Lucy deconvolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray
|
input volume to be deconvolved |
required |
psf
|
NDArray
|
point spread function |
required |
bp
|
NDArray
|
back projector for deconvolution |
required |
num_iter
|
int
|
number of iterations. Defaults to 50. |
50
|
boundary_correction
|
bool
|
whether or not to do boundary correction. Defaults to True. |
True
|
epsilon
|
Optional[float]
|
small parameter to prevent division by zero. Defaults to None. |
None
|
boundary_padding
|
Optional[int]
|
zero-padding for boundary correction. Defaults to None. |
None
|
boundary_sigma
|
float
|
significance level for pixels when doing boundary correction. Defaults to 1e-2. |
0.01
|
verbose
|
bool
|
show a progress bar. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
uncorrected version of RL deconvolution. |
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/singleview_fft.py
richardson_lucy_boundcorr(image: NDArray, psf: NDArray, bp: Optional[NDArray] = None, num_iter: int = 50, epsilon: float = 0.0001, zero_padding: Optional[PadType] = None, boundary_sigma: float = 0.01, init_constant: bool = False, verbose: bool = False) -> NDArray
¶richardson_lucy_boundcorr Richardson-Lucy deconvolution with boundary correction described in [1], this method reduces Gibbs oscillations that occur due to boundary effects when doing RL deconvolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray
|
input volume to be deconvolved |
required |
psf
|
NDArray
|
point spread function |
required |
bp
|
Optional[NDArray]
|
backprojector. Defaults to None, if so will used mirrored PSF. |
None
|
num_iter
|
int
|
number of iterations. Defaults to 50. |
50
|
epsilon
|
float
|
small parameter to prevent division by zero. Defaults to 1e-4. |
0.0001
|
zero_padding
|
Optional[PadType]
|
amount of zero-padding. Defaults to None. |
None
|
boundary_sigma
|
float
|
significance level for pixels when doing boundary correction. Defaults to 1e-2. |
0.01
|
init_constant
|
bool
|
whether to make the inital guess a constant array, ( |
False
|
verbose
|
bool
|
show progress bar. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/singleview_fft.py
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 | |
singleview_sep
¶Separable deconvolution for single view volumes.
TODO: more detail here.
deconvolve(volume: NDArray, psf_z: NDArray, psf_y: NDArray, psf_x: NDArray, bp_z: NDArray, bp_y: NDArray, bp_x: NDArray, num_iter: int, boundary_correction: bool, epsilon: Optional[float], init_constant: bool, boundary_padding: Optional[int], boundary_sigma: float, verbose: bool) -> NDArray
¶deconvolve do deconvolution of volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
volume
|
NDArray
|
input volume to be deconvolved |
required |
psf_z
|
NDArray
|
PSF kernel in z-direction |
required |
psf_y
|
NDArray
|
PSF kernel in y-direction |
required |
psf_x
|
NDArray
|
PSF kernel in x-direction |
required |
bp_z
|
NDArray
|
backprojector kernel in z-direction |
required |
bp_y
|
NDArray
|
backprojector kernel in y-direction |
required |
bp_x
|
NDArray
|
backprojector kernel in x-direction |
required |
num_iter
|
int
|
number of iterations to do deconvolution for |
required |
boundary_correction
|
bool
|
whether or not to do boundary correction |
required |
epsilon
|
Optional[float]
|
small parameter to prevent division by zero |
required |
init_constant
|
bool
|
initialize deconvolution with a constant array (if |
required |
boundary_padding
|
Optional[int]
|
zero-padding for boundary correction |
required |
boundary_sigma
|
float
|
significance value for pixels when doing boundary correction |
required |
verbose
|
bool
|
show progress bar |
required |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
boundary correction |
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/singleview_sep.py
deskew
¶
Functions¶
Modules¶
affine
¶
Deskew by shear-warp algorithm.
Deskew the input volume using an affine transformation. Should return the same result as dispim but using shear-warp algorithm and (possibly higher-order) interpolation instead of texture-based interpolation.
fwd_deskew_matrix(pixel_size: float, step_size: float, direction: int, zed: int, row: int, col: int) -> numpy.ndarray
¶Forward deskewing matrix
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pixel_size
|
float
|
size of pixels, in real space |
required |
step_size
|
float
|
spacing between sheets, in real units |
required |
direction
|
int
|
scan direction (±1) |
required |
z
|
input volume size in z |
required | |
r
|
input volume size in r |
required | |
c
|
input volume size in c |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray |
Source code in packages/pyspim/src/pyspim/deskew/affine.py
output_shape(z: int, r: int, c: int, pixel_size: float, step_size: float, direction: int) -> Tuple[int, int, int]
¶Compute output shape of deskewing transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
int
|
shape of input volume, z-direction |
required |
r
|
int
|
shape of input volume, r-direction (# rows) |
required |
c
|
int
|
shape of input volume, c-direction (# cols) |
required |
pixel_size
|
float
|
size of pixels, in real units |
required |
step_size
|
float
|
spacing between steps, in real units |
required |
direction
|
int
|
scan direction (± 1) |
required |
auto_crop
|
bool
|
automatically crop the output to account for rotation of B-view |
required |
Returns:
| Type | Description |
|---|---|
Tuple[int, int, int]
|
Tuple[int,int,int] |
Source code in packages/pyspim/src/pyspim/deskew/affine.py
deskewing_transform(z: int, r: int, c: int, pixel_size: float, step_size: float, direction: int) -> Tuple[NDArray, Tuple[int, int, int]]
¶Compute the deskewing transform for the input volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
int
|
size of input volume, z-direction (pixels) |
required |
r
|
int
|
size of input volume, r-direction (pixels, # rows) |
required |
c
|
int
|
size of input volume, c-direction (pixels, # cols) |
required |
pixel_size
|
float
|
size of pixels, in real units |
required |
step_size
|
float
|
step size, in real units |
required |
direction
|
int
|
scan direction (±1) |
required |
auto_crop
|
bool
|
auto-crop outputs to account for rotation of B into coordinate system of A. |
required |
rotation_thetas
|
Tuple[int, int, int] | None
|
rotation angles for each axis. If |
required |
Returns:
| Type | Description |
|---|---|
Tuple[NDArray, Tuple[int, int, int]]
|
numpy.ndarray, List[int]: deskewing transform & the output shape |
Source code in packages/pyspim/src/pyspim/deskew/affine.py
deskew_stage_scan(im: cupy.ndarray, pixel_size: float, step_size: float, direction: int, interp_method: str, preserve_dtype: bool, block_size: Tuple[int, int, int]) -> cupy.ndarray
¶Deskew the input volume using the shear-warp algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
im
|
ndarray
|
input volume to be deskewed. |
required |
pixel_size
|
float
|
pixel size, in real units |
required |
step_size
|
float
|
step size, in real units |
required |
direction
|
int
|
scan direction (± 1) |
required |
rotation_thetas
|
Tuple[float, float, float] | None
|
rotation angles for each axis. If |
required |
interp_method
|
str
|
interpolation method to use |
required |
auto_crop
|
bool
|
auto-crop output volumes to account for rotation of view B |
required |
preserve_dtype
|
bool
|
make output volume have same datatype as input volume (probably uint16). |
required |
block_size
|
Tuple[int, int, int]
|
size of blocks for CUDA kernel launch. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
cupy.ndarray |
Source code in packages/pyspim/src/pyspim/deskew/affine.py
dispim
¶
Deskew stage-scanned volume into "normal" diSPIM coordinate system (see [1], esp. Figure 1).
We mimic the original Shroff lab Fiji plugin, but use a CUDA kernel for speed. Note that interpolation is done using CUDA texture memory.
References¶
[1] Kumar, et. al, "Using Stage- and Slit-...", doi: 10.1086/689589
deskew_stage_scan(im: NDArray, pixel_size: float, step_size: float, direction: int, **kwargs) -> NDArray
¶Deskew the input volume, im.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
im
|
NDArray
|
input volume |
required |
pixel_size
|
float
|
pixel size, in real (space) units |
required |
step_size
|
float
|
step size, in real (space) units |
required |
direction
|
int
|
±1, direction of objective movement rel. to x-axis. |
required |
**kwargs
|
|
{}
|
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/deskew/dispim.py
output_width(depth: int, width: int, step_size: float, pixel_size: float) -> int
¶output_width Compute output width of deskewed volume
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth
|
int
|
depth of input (pre-deskewing) volume |
required |
width
|
int
|
width of input (pre-deskewing) volume |
required |
step_size
|
float
|
step size, in real (space) units |
required |
pixel_size
|
float
|
pixel size, in real (space) units |
required |
Returns:
| Type | Description |
|---|---|
int
|
int |
Source code in packages/pyspim/src/pyspim/deskew/dispim.py
ortho
¶
Deskewing by orthogonal interpolation.
Uses the 'orthogonal interpolation' scheme where interpolation is done orthogonally to the direction of the light sheet. this was originally proposed/implemented in V. Maioli's Ph.D. thesis [1]. Our code is based heavily on the implementation by D. Shepherd's group [2].
References¶
[1] Vincent Miaioli's PhD Thesis doi: 10.25560/68022 [2] github.com/QI2lab/OPM
deskew_stage_scan(im: NDArray, pixel_size: float, step_size: float, direction: int, theta: float = math.pi / 4, preserve_dtype: bool = False, stream: cupy.cuda.Stream | None = None) -> NDArray
¶Deskew stage scan data into xyz coordinate system.
Output format is zyx where z is normal to the coverslip, and x & y are the coverslip, y is along the long axis of the sheet, x along is the scan direction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
im
|
NDArray
|
input volume to be deskewed |
required |
pixel_size
|
float
|
size of pixels, in real (space) units |
required |
step_size
|
float
|
real space spacing between sheets |
required |
direction
|
int
|
scan direction (±1) |
required |
theta
|
float
|
angle of objective w.r.t coverslip (in radians) |
pi / 4
|
preserve_dtype
|
bool
|
preserve input datatype in output. If |
False
|
Returns: NDArray
Source code in packages/pyspim/src/pyspim/deskew/ortho.py
output_shape(z: int, r: int, c: int, pixel_size: float, step_size: float, theta: float = math.pi / 4) -> Tuple[int, int, int]
¶output_shape Calculate output shape of deskewing a volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
int
|
size of input volume in z-direction |
required |
r
|
int
|
size of input volume in r-direction (# rows) |
required |
c
|
int
|
size of input volume in c-direction (# cols) |
required |
pixel_size
|
float
|
pixel size, in real units |
required |
step_size
|
float
|
step size, in real units |
required |
theta
|
float
|
angle of objective w.r.t coverslip. Defaults to math.pi/4. |
pi / 4
|
Returns:
| Type | Description |
|---|---|
Tuple[int, int, int]
|
Tuple[int,int,int]: (n_z, n_y, n_x) shape of deskewed volume |
Source code in packages/pyspim/src/pyspim/deskew/ortho.py
shear
¶
Deskew by shear-warp algorithm.
Deskew the input volume using an affine transformation. Should return the same result as dispim but using shear-warp algorithm and (possibly higher-order) interpolation instead of texture-based interpolation.
inv_deskew_matrix(pixel_size: float, step_size: float, direction: int) -> numpy.ndarray
¶Inverse deskewing matrix
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pixel_size
|
float
|
size of pixels, in real space |
required |
step_size
|
float
|
spacing between sheets, in real units |
required |
direction
|
int
|
scan direction (±1) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray |
Source code in packages/pyspim/src/pyspim/deskew/shear.py
output_shape(z: int, r: int, c: int, pixel_size: float, step_size: float, direction: int, auto_crop: bool) -> Tuple[int, int, int]
¶Compute output shape of deskewing transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
int
|
shape of input volume, z-direction |
required |
r
|
int
|
shape of input volume, r-direction (# rows) |
required |
c
|
int
|
shape of input volume, c-direction (# cols) |
required |
pixel_size
|
float
|
size of pixels, in real units |
required |
step_size
|
float
|
spacing between steps, in real units |
required |
direction
|
int
|
scan direction (± 1) |
required |
auto_crop
|
bool
|
automatically crop the output to account for rotation of B-view |
required |
Returns:
| Type | Description |
|---|---|
Tuple[int, int, int]
|
Tuple[int,int,int] |
Source code in packages/pyspim/src/pyspim/deskew/shear.py
deskewing_transform(z: int, r: int, c: int, pixel_size: float, step_size: float, direction: int, auto_crop: bool, rotation_thetas: Tuple[float, float, float] | None) -> Tuple[NDArray, Tuple[int, int, int]]
¶Compute the deskewing transform for the input volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
int
|
size of input volume, z-direction (pixels) |
required |
r
|
int
|
size of input volume, r-direction (pixels, # rows) |
required |
c
|
int
|
size of input volume, c-direction (pixels, # cols) |
required |
pixel_size
|
float
|
size of pixels, in real units |
required |
step_size
|
float
|
step size, in real units |
required |
direction
|
int
|
scan direction (±1) |
required |
auto_crop
|
bool
|
auto-crop outputs to account for rotation of B into coordinate system of A. |
required |
rotation_thetas
|
Tuple[int, int, int] | None
|
rotation angles for each axis. If |
required |
Returns:
| Type | Description |
|---|---|
Tuple[NDArray, Tuple[int, int, int]]
|
numpy.ndarray, List[int]: deskewing transform & the output shape |
Source code in packages/pyspim/src/pyspim/deskew/shear.py
deskew_stage_scan(im: cupy.ndarray, pixel_size: float, step_size: float, direction: int, rotation_thetas: Tuple[float, float, float] | None, interp_method: str, auto_crop: bool, preserve_dtype: bool, block_size: Tuple[int, int, int]) -> cupy.ndarray
¶Deskew the input volume using the shear-warp algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
im
|
ndarray
|
input volume to be deskewed. |
required |
pixel_size
|
float
|
pixel size, in real units |
required |
step_size
|
float
|
step size, in real units |
required |
direction
|
int
|
scan direction (± 1) |
required |
rotation_thetas
|
Tuple[float, float, float] | None
|
rotation angles for each axis. If |
required |
interp_method
|
str
|
interpolation method to use |
required |
auto_crop
|
bool
|
auto-crop output volumes to account for rotation of view B |
required |
preserve_dtype
|
bool
|
make output volume have same datatype as input volume (probably uint16). |
required |
block_size
|
Tuple[int, int, int]
|
size of blocks for CUDA kernel launch. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
cupy.ndarray |
Source code in packages/pyspim/src/pyspim/deskew/shear.py
dispimfusion
¶
Reimplementation of the diSPIMFusion API, as first described in [1].
References¶
[1] Guo M., et al. "Rapid image deconvolution and multiview fusion..." Nature Biotechnology 38.11 (2020): 1337-1346. [2] https://github.com/eguomin/diSPIMFusion [3] https://github.com/eguomin/microImageLib
filter
¶
Functions¶
Modules¶
adaptive_median
¶
Adaptive Median Filtering
as described in: Weisong Zhao et al. "Sparse deconvolution improves..." Nature Biotechnology 40, 606â617 (2022).
fftwavelet
¶
remove_stripes(im: NDArray, dec_num: int, wavelet: str, sigma: float, direction: str = 'horizontal', verbose: bool = False) -> NDArray
¶remove stripes from input image by the FFTWavelet algorithm
:param im: input image
:type im: NDArray
:param dec_num: number of decimation levels (loops)
:type dec_num: int
:param wavelet: wavelet to use
:type wavelet: str
:param sigma: description
:type sigma: float
:param direction: direction of stripes in input to be removed, defaults to 'horizontal'
:type direction: str, optional
:param verbose: show progress through loop, defaults to False
:type verbose: bool, optional
:raises ValueError: if direction isn't 'horizontal' or 'vertical'
:return: input image with stripes removed
:rtype: NDArray
Source code in packages/pyspim/src/pyspim/filter/fftwavelet.py
fsc
¶
Modules¶
checkerboard
¶
image/volume splitting by checkerboard subsampling
checkerboard_split(arr: NDArray, split: int) -> Tuple[NDArray, NDArray]
¶checkerboard split images or volumes for FSC analysis generate pairs of images for FS(R)C analysis by subsampling them, as described in Fig. 2(a) of [1]
References¶
[1] Koho, et al. "Fourier ring correlation..." doi:10.1038/s41467-019-11024-z
:param arr: input image/volume :type arr: NDArray :param split: type of split to do :type split: int :returns: checkerboard-subsampled halves of input array :rtype: Tuple[NDArray,NDArray]
Source code in packages/pyspim/src/pyspim/fsc/checkerboard.py
main
¶
fourier_ring_correlation(im1: NDArray, im2: NDArray, bin_edges: Sequence, pixel_size: Optional[float] = None) -> FRCOutput
¶compute Fourier Ring Correlation for pair of input images pair should be checkerboard-subsampled pair of images originating from a single image
:param im1: image 1
:type im1: NDArray
:param im2: image 2
:type im2: NDArray
:param bin_edges: edges of frequency bins that FRC is calculated over
:type bin_edges: Sequence
:param pixel_size: pixel size, in real-space units.
if None, output spatial frequencies will be in units pix^{-1}
if specified, output spatial frequencies will have correct units
:type pixel_size: Optional[float]
:returns: FRC values and corresponding spatial frequencies
:rtype: Tuple[NDArray,NDArray]
Source code in packages/pyspim/src/pyspim/fsc/main.py
fourier_shell_correlation(vol1: NDArray, vol2: NDArray, bin_edges: Sequence, voxel_size: Optional[float] = None) -> FSCOutput
¶compute Fourier Shell Correlation for pair of input volumes pair should be checkerboard-subsampled pair of volumes originating from a single volume
:param vol1: volume 1 :type vol1: NDArray :param vol2: volume 2 :type vol2: NDArray :param bin_edges: :type bin_edges: Sequence :param voxel_size: :type voxel_size: Optional[float] :returns: :rtype: Tuple[NDArray,NDArray,NDArray]
Source code in packages/pyspim/src/pyspim/fsc/main.py
interp
¶
Functions¶
Modules¶
affine
¶
output_shape_for_transform(T: NDArray, input_shape: tuple[int, int, int]) -> Tuple[int, int, int]
¶Calculate output shape of transformed volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
T
|
NDArray
|
affine transform matrix |
required |
input_shape
|
Iterable
|
shape of input volume (ZRC) |
required |
Returns:
| Type | Description |
|---|---|
Tuple[int, int, int]
|
Tuple[int,int,int]: output shape (ZRC) |
Source code in packages/pyspim/src/pyspim/interp/affine.py
output_shape_for_inv_transform(T: NDArray, input_shape: tuple[int, int, int]) -> Tuple[int, int, int]
¶Calculate output shape of (inverse)-transformed volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
T
|
NDArray
|
affine transform matrix (to be inverted) |
required |
input_shape
|
Iterable
|
shape of input volume (ZRC) |
required |
Returns:
| Type | Description |
|---|---|
Tuple[int, int, int]
|
Tuple[int,int,int]: shape of output volume (ZRC) |
Source code in packages/pyspim/src/pyspim/interp/affine.py
transform(A: NDArray, T: NDArray, interp_method: str, preserve_dtype: bool, out_shp: Tuple[int, int, int] | None, block_size_z: int, block_size_y: int, block_size_x: int, gpu_id: int = 0, n_gpu: int = 1) -> cupy.ndarray
¶Apply affine transform to input volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
NDArray
|
input volume (ZRC) |
required |
T
|
NDArray
|
affine transform matrix (4x4), rows of matrix corresp. to XYZ |
required |
interp_method
|
str
|
interpolation method to use when interpolating points in the transformed volume. One of |
required |
preserve_dtype
|
bool
|
make output datatype match that of the input (uint16), if False, output is single-precision float. |
required |
out_shp
|
Tuple[int, int, int] | None
|
shape of output volume. if |
required |
block_size_z
|
int
|
size of kernel launch block, in z dimension |
required |
block_size_y
|
int
|
size of kernel launch block, in y dimension |
required |
block_size_x
|
int
|
size of kernel launch block, in x dimension |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if input is not a |
Returns:
| Type | Description |
|---|---|
ndarray
|
cupy.ndarray: transformed volume |
Notes
The input transform, T, should be the forward transform mapping the input to the desired output domain. Internally, this function takes the inverse of the specified transform and then iterates over the output domain to extract values from the input array.
Source code in packages/pyspim/src/pyspim/interp/affine.py
isotropize
¶
Isotropization utilities.
Individual views from diSPIM volumes are typically acquired with uneven spacing in one of the directions, but analysis requires cubic pixels. These are utilities to upsample the axis with uneven spacing relative to the camera pixel size.
This can be done either by direct interpolation (interpolate) or by upsampling in Fourier space (fourier_upsample), using the technique described in [1].
References¶
[1] Stein, et al. "Fourier interpolation stochastic..." doi:10.1364/OE.23.016154
Functions¶
interpolate(vol: NDArray, pixel_size: float, step_size: float, axis: int = 0, **kwargs) -> NDArray
¶
interpolate Upsample an axis by interpolation. Function will upsample specified axis by assuming it has spacing step_size such that the output voxel is cubic, pixel_size**3.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vol
|
NDArray
|
input volume |
required |
pixel_size
|
float
|
pixel size in real (space) units |
required |
step_size
|
float
|
step size in real (space) units |
required |
axis
|
int
|
axis to upsample. Defaults to 0. |
0
|
**kwargs
|
passed to |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
|
Source code in packages/pyspim/src/pyspim/isotropize.py
fourier_upsample(vol: NDArray, pixel_size: float, step_size: float, axis: int = 0) -> NDArray
¶
fourier_upsample Upsample an axis by Fourier upsampling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vol
|
NDArray
|
input volume |
required |
pixel_size
|
float
|
pixel size in real (space) units. |
required |
step_size
|
float
|
step size in real (space) units |
required |
axis
|
int
|
axis to upsample. Defaults to 0. |
0
|
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/isotropize.py
psf
¶
Modules¶
gauss
¶
gaussian_fwhm(sigma: float) -> float
¶gaussian_fwhm Compute full-width at half-max for Gaussian from std. dev.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sigma
|
float
|
standard deviation of Gaussian |
required |
Returns:
| Type | Description |
|---|---|
float
|
float |
Source code in packages/pyspim/src/pyspim/psf/gauss.py
reg
¶
Functions¶
Modules¶
mutinfo
¶
mutual_information(ref: NDArray, tar: NDArray, tM: NDArray, nbin_ref: int, nbin_tar: int) -> float
¶mutual information between input images ref & tar where tar
is first transformed by matrix tM
:param ref: reference volume
:type ref: NDArray
:param tar: target (AKA "moving") volume
:type tar: NDArray
:param tM: matrix to transform tar with
:type tM: NDArray
:param nbin_ref: # of bins in histogram of ref
:type nbin_ref: int
:param nbin_tar: # of bins in histogram of tar
:type nbin_tar: int
:returns: mutual information between ref and transformed tar
:rtype: float
Source code in packages/pyspim/src/pyspim/reg/mutinfo.py
entropy_correlation_coeff(ref: NDArray, tar: NDArray, tM: NDArray, nbin_ref: int, nbin_tar: int) -> float
¶entropy correlation coefficient between input images ref & tar
where tar is first transformed by matrix tM
:param ref: reference volume
:type ref: NDArray
:param tar: target (AKA "moving") volume
:type tar: NDArray
:param tM: matrix to transform tar with
:type tM: NDArray
:param nbin_ref: # of bins in histogram of ref
:type nbin_ref: int
:param nbin_tar: # of bins in histogram of tar
:type nbin_tar: int
:returns: entropy correlation coefficient between ref and transformed tar
:rtype: float
Source code in packages/pyspim/src/pyspim/reg/mutinfo.py
pcc
¶
translation(ref: NDArray, mov: NDArray, upsample_factor: int = 1) -> NDArray
¶Determine translation between ref and mov.
:param ref: reference image
:type ref: NDArray
:param mov: image to register. must be same dimensionality as ref
:type mov: NDArray
:param upsample_factor: upsampling factor, images are registered to
1/upsample_factor. defaults to 1.
:type upsample_factor: int
:returns: translation along each axis
:rtype: NDArray
Source code in packages/pyspim/src/pyspim/reg/pcc.py
scale_rotation(ref: NDArray, mov: NDArray, upsample_factor: int = 1) -> Tuple[float, float]
¶determine scaling & rotation between ref & mov using phase cross
correlation of the log-polar transformed inputs
:param ref: reference image
:type ref: NDArray
:param mov: image to register. must be same dimensionality as ref
:type mov: NDArray
:param upsample_factor: upsampling factor, images are registered to
1/upsample_factor. defaults to 1.
:type upsample_factor: int
:returns: rotation (in degrees) and scale difference between ref & mov
:rtype: Tuple[float,float]
Source code in packages/pyspim/src/pyspim/reg/pcc.py
rotation_scale_for_volumes(ref: NDArray, mov: NDArray, upsample_factor: int = 1.0)
¶calculate rotation, and scaling between input volumes by phase cross correlation of the maximum projections in each axis
:param ref: reference volume
:type ref: NDArray
:param mov: 'moving' volume to be registered to ref
:type mov: NDArray
:param upsample_factor: upsampling factor. images are registered to
1/upsample_factor. defaults to 1
:type upsample_factor: float
:returns: rotation and scaling for each axis
:rtype: Tuple[NDArray,NDArray]
Source code in packages/pyspim/src/pyspim/reg/pcc.py
translation_for_volumes(ref: NDArray, mov: NDArray, upsample_factor: int = 1)
¶calculate relative translation, rotation, and scaling between input volumes by phase cross correlation of the maximum projections in each axis
:param ref: reference volume
:type ref: NDArray
:param mov: 'moving' volume to be registered to ref
:type mov: NDArray
:param upsample_factor: upsampling factor. images are registered to
1/upsample_factor. defaults to 1
:type upsample_factor: float
:returns: translation, rotation, and scaling for each axis
:rtype: Tuple[NDArray,NDArray,NDArray]
Source code in packages/pyspim/src/pyspim/reg/pcc.py
translation_rotation_scale_for_volumes(ref: NDArray, mov: NDArray, upsample_factor: int = 1)
¶calculate relative translation, rotation, and scaling between input volumes by phase cross correlation of the maximum projections in each axis
:param ref: reference volume
:type ref: NDArray
:param mov: 'moving' volume to be registered to ref
:type mov: NDArray
:param upsample_factor: upsampling factor. images are registered to
1/upsample_factor. defaults to 1
:type upsample_factor: float
:returns: translation, rotation, and scaling for each axis
:rtype: Tuple[NDArray,NDArray,NDArray]
Source code in packages/pyspim/src/pyspim/reg/pcc.py
powell
¶
optimize_affine(ref: cupy.ndarray, mov: cupy.ndarray, metric: str, transform: str, interp_method: str, par0: List[float], bounds: Optional[Union[OptBounds, OptBoundMargins]] = None, kernel_launch_params: Optional[CuLaunchParameters] = None, verbose: bool = False, **opt_kwargs)
¶Find optimal affine transform to register mov with ref by Powell's method
**opt_kwargs are passed to scipy.optimize.minimize
:param ref: reference volume :type ref: cupy.ndarray :param mov: moving volume, to be registered :type mov: cupy.ndarray :param metric: metric to optimize for registration one of ('nip', 'cr', 'ncc'). 'nip' : normalized inner product 'cr' : correlation ratio 'ncc' : normalized cross correlation :type metric: str :param transform: transform to optimize :type transform: str :param interp: interpolation method to use during transformation one of ('linear', 'cubspl') 'linear' : trilinear interpolation 'cubspl' : cubic b-spline interpolation :type interp: str :param par0: initial guess for parameters :type par0: list :param bounds: bounds for parameters :type bounds: list :param verbose: show intermediate results with tqdm progress bar :type verbose: bool :returns: transform and optimization results :rtype: Tuple[NDArray,OptimizeResult]
Source code in packages/pyspim/src/pyspim/reg/powell.py
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 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
roi
¶
Functions¶
detect_roi_2d(im: NDArray, method: str = 'triangle', quantile: float = 0, **kwargs) -> BBox2D
¶
detect_roi_2d Determine ROI in 2D image by thresholding. If using method=threshold, the threshold=[value] keyword arg must be passed into function.
Args:
im (NDArray): image to find ROI in
method (str, optional): thresholding method, one of ('triangle', 'otsu', 'threshold'). Defaults to 'triangle'.
quantile (float, optional): quantile to truncate coordinates with (helps get rid of outliers). Defaults to 0.
Returns:
| Name | Type | Description |
|---|---|---|
BBox2D |
BBox2D
|
bounding box ROI |
Source code in packages/pyspim/src/pyspim/roi.py
detect_roi_3d(im: NDArray, method: str = 'triangle', quantile_rc: float = 0, quantile_zc: float = 0, **kwargs) -> BBox3D
¶
detect_roi_3d Detect ROI of 3D volume by combining ROIs of 2D max-projections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
im
|
NDArray
|
volume to find ROI of |
required |
method
|
str
|
thresholding method. Defaults to 'triangle'. |
'triangle'
|
quantile_rc
|
float
|
qunatile used for determining row-col bounding box. Defaults to 0. |
0
|
quantile_zc
|
float
|
quantile used for determine z-row bounding box. Defaults to 0. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
BBox3D |
BBox3D
|
format is |
Source code in packages/pyspim/src/pyspim/roi.py
combine_rois(a: BBox3D, b: BBox3D, ensure_even: bool = False) -> BBox3D
¶
combine_rois Combine 2 ROIs into smallest possible one that encompasses both.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
BBox3D
|
3d bounding box for first ROI |
required |
b
|
BBox3D
|
3d bounding box for second ROI |
required |
ensure_even
|
bool
|
make all dimensions of output ROI even. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
BBox3D
|
BBox3D |
Source code in packages/pyspim/src/pyspim/roi.py
crop_with_roi(a: NDArray, roi: BBox3D | BBox2D) -> NDArray
¶
crop_with_roi Utility function to crop input using specified bounding box ROI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
NDArray
|
input to be cropped |
required |
roi
|
BBox3D | BBox2D
|
bounding box ROI |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if input isn't 2 or 3D |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
cropped input |
Source code in packages/pyspim/src/pyspim/roi.py
util
¶
public utility functions
Functions¶
center_crop(vol: NDArray, *args) -> NDArray
¶
crop out the center of the input volume
:param vol: input volume :type vol: NDArray :returns: crop of input volume :rtype: NDArray
Source code in packages/pyspim/src/pyspim/_util.py
launch_params_for_volume(shp: tuple[int, int, int], block_size_z: int, block_size_r: int, block_size_c: int) -> CuLaunchParameters
¶
Automatically calculate good launch parameters for CUDA kernel that will be run on a volume of specified shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shp
|
Iterable[int]
|
shape of input volume kernel will be run over (ZRC). |
required |
block_size_z
|
int
|
block size in z dimension (0 axis) |
required |
block_size_r
|
int
|
block size in r dimension (1 axis) |
required |
block_size_c
|
int
|
block size in c dimension (2 axis) |
required |
Returns:
| Type | Description |
|---|---|
CuLaunchParameters
|
CuLaunchParameters |
Source code in packages/pyspim/src/pyspim/_util.py
shared_bbox_from_proj_threshold(v1: NDArray, v2: NDArray, proj_fun: str = 'max', thresh_val: float = 0) -> BBox3D
¶
determine region shared by both volumes by thresholding 'shared' means that both have data in the region
:param v1: first volume
:type v1: NDArray
:param v2: second volume
:type v2: NDArray
:param proj_fun: function to project with
one of ('max', 'mean', 'median')
:type proj_fun: str
:param thresh_val: value to threshold with to make mask
:type thresh_val: float
:returns: 3d bounding box of region common to v1 and v2
:rtype: BBox3D
Source code in packages/pyspim/src/pyspim/_util.py
threshold_triangle(im: NDArray, nbins: int = 256) -> float
¶
threshold_triangle Compute threshold value by triangle method. Copied from skimage.filters but modified so that numpy or cupy is used based on input device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
im
|
NDArray
|
array to calculate threshold for |
required |
nbins
|
int
|
number of bins to use in histogram. Defaults to 256. |
256
|
Returns:
| Type | Description |
|---|---|
float
|
float |
Source code in packages/pyspim/src/pyspim/_util.py
pyspim.roi
¶
Functions¶
detect_roi_2d(im: NDArray, method: str = 'triangle', quantile: float = 0, **kwargs) -> BBox2D
¶
detect_roi_2d Determine ROI in 2D image by thresholding. If using method=threshold, the threshold=[value] keyword arg must be passed into function.
Args:
im (NDArray): image to find ROI in
method (str, optional): thresholding method, one of ('triangle', 'otsu', 'threshold'). Defaults to 'triangle'.
quantile (float, optional): quantile to truncate coordinates with (helps get rid of outliers). Defaults to 0.
Returns:
| Name | Type | Description |
|---|---|---|
BBox2D |
BBox2D
|
bounding box ROI |
Source code in packages/pyspim/src/pyspim/roi.py
detect_roi_3d(im: NDArray, method: str = 'triangle', quantile_rc: float = 0, quantile_zc: float = 0, **kwargs) -> BBox3D
¶
detect_roi_3d Detect ROI of 3D volume by combining ROIs of 2D max-projections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
im
|
NDArray
|
volume to find ROI of |
required |
method
|
str
|
thresholding method. Defaults to 'triangle'. |
'triangle'
|
quantile_rc
|
float
|
qunatile used for determining row-col bounding box. Defaults to 0. |
0
|
quantile_zc
|
float
|
quantile used for determine z-row bounding box. Defaults to 0. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
BBox3D |
BBox3D
|
format is |
Source code in packages/pyspim/src/pyspim/roi.py
combine_rois(a: BBox3D, b: BBox3D, ensure_even: bool = False) -> BBox3D
¶
combine_rois Combine 2 ROIs into smallest possible one that encompasses both.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
BBox3D
|
3d bounding box for first ROI |
required |
b
|
BBox3D
|
3d bounding box for second ROI |
required |
ensure_even
|
bool
|
make all dimensions of output ROI even. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
BBox3D
|
BBox3D |
Source code in packages/pyspim/src/pyspim/roi.py
crop_with_roi(a: NDArray, roi: BBox3D | BBox2D) -> NDArray
¶
crop_with_roi Utility function to crop input using specified bounding box ROI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
NDArray
|
input to be cropped |
required |
roi
|
BBox3D | BBox2D
|
bounding box ROI |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if input isn't 2 or 3D |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
cropped input |
Source code in packages/pyspim/src/pyspim/roi.py
pyspim.util
¶
public utility functions
Functions¶
center_crop(vol: NDArray, *args) -> NDArray
¶
crop out the center of the input volume
:param vol: input volume :type vol: NDArray :returns: crop of input volume :rtype: NDArray
Source code in packages/pyspim/src/pyspim/_util.py
launch_params_for_volume(shp: tuple[int, int, int], block_size_z: int, block_size_r: int, block_size_c: int) -> CuLaunchParameters
¶
Automatically calculate good launch parameters for CUDA kernel that will be run on a volume of specified shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shp
|
Iterable[int]
|
shape of input volume kernel will be run over (ZRC). |
required |
block_size_z
|
int
|
block size in z dimension (0 axis) |
required |
block_size_r
|
int
|
block size in r dimension (1 axis) |
required |
block_size_c
|
int
|
block size in c dimension (2 axis) |
required |
Returns:
| Type | Description |
|---|---|
CuLaunchParameters
|
CuLaunchParameters |
Source code in packages/pyspim/src/pyspim/_util.py
shared_bbox_from_proj_threshold(v1: NDArray, v2: NDArray, proj_fun: str = 'max', thresh_val: float = 0) -> BBox3D
¶
determine region shared by both volumes by thresholding 'shared' means that both have data in the region
:param v1: first volume
:type v1: NDArray
:param v2: second volume
:type v2: NDArray
:param proj_fun: function to project with
one of ('max', 'mean', 'median')
:type proj_fun: str
:param thresh_val: value to threshold with to make mask
:type thresh_val: float
:returns: 3d bounding box of region common to v1 and v2
:rtype: BBox3D
Source code in packages/pyspim/src/pyspim/_util.py
threshold_triangle(im: NDArray, nbins: int = 256) -> float
¶
threshold_triangle Compute threshold value by triangle method. Copied from skimage.filters but modified so that numpy or cupy is used based on input device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
im
|
NDArray
|
array to calculate threshold for |
required |
nbins
|
int
|
number of bins to use in histogram. Defaults to 256. |
256
|
Returns:
| Type | Description |
|---|---|
float
|
float |
Source code in packages/pyspim/src/pyspim/_util.py
pyspim.typing
¶
pyspim.dispimfusion
¶
Reimplementation of the diSPIMFusion API, as first described in [1].
References¶
[1] Guo M., et al. "Rapid image deconvolution and multiview fusion..." Nature Biotechnology 38.11 (2020): 1337-1346. [2] https://github.com/eguomin/diSPIMFusion [3] https://github.com/eguomin/microImageLib
pyspim.isotropize
¶
Isotropization utilities.
Individual views from diSPIM volumes are typically acquired with uneven spacing in one of the directions, but analysis requires cubic pixels. These are utilities to upsample the axis with uneven spacing relative to the camera pixel size.
This can be done either by direct interpolation (interpolate) or by upsampling in Fourier space (fourier_upsample), using the technique described in [1].
References¶
[1] Stein, et al. "Fourier interpolation stochastic..." doi:10.1364/OE.23.016154
Functions¶
interpolate(vol: NDArray, pixel_size: float, step_size: float, axis: int = 0, **kwargs) -> NDArray
¶
interpolate Upsample an axis by interpolation. Function will upsample specified axis by assuming it has spacing step_size such that the output voxel is cubic, pixel_size**3.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vol
|
NDArray
|
input volume |
required |
pixel_size
|
float
|
pixel size in real (space) units |
required |
step_size
|
float
|
step size in real (space) units |
required |
axis
|
int
|
axis to upsample. Defaults to 0. |
0
|
**kwargs
|
passed to |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
|
Source code in packages/pyspim/src/pyspim/isotropize.py
fourier_upsample(vol: NDArray, pixel_size: float, step_size: float, axis: int = 0) -> NDArray
¶
fourier_upsample Upsample an axis by Fourier upsampling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vol
|
NDArray
|
input volume |
required |
pixel_size
|
float
|
pixel size in real (space) units. |
required |
step_size
|
float
|
step size in real (space) units |
required |
axis
|
int
|
axis to upsample. Defaults to 0. |
0
|
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/isotropize.py
pyspim.decon.util
¶
pyspim.decon.rl.dualview_sep
¶
Separable deconvolution of dual-view volumes.
TODO: add more detail here.
Functions¶
deconvolve(view_a: NDArray, view_b: NDArray, est_i: NDArray | None, psf_az: NDArray | Iterable[NDArray], psf_ay: NDArray | Iterable[NDArray], psf_ax: NDArray | Iterable[NDArray], psf_bz: NDArray | Iterable[NDArray], psf_by: NDArray | Iterable[NDArray], psf_bx: NDArray | Iterable[NDArray], bp_az: NDArray | Iterable[NDArray], bp_ay: NDArray | Iterable[NDArray], bp_ax: NDArray | Iterable[NDArray], bp_bz: NDArray | Iterable[NDArray], bp_by: NDArray | Iterable[NDArray], bp_bx: NDArray | Iterable[NDArray], decon_function: str, num_iter: int, epsilon: float, boundary_correction: bool, zero_padding: PadType, boundary_sigma_a: float, boundary_sigma_b: float, verbose: bool) -> NDArray
¶
deconvolve Joint deconvolution of the 2 input views into a single volume.
Input volumes should be either 3D (ZRC) or 4D (CZRC).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
NDArray
|
input volume from first view (A) |
required |
view_b
|
NDArray
|
input volume from second view (B) |
required |
est_i
|
NDArray | None
|
initial estimate for deconvolution. If |
required |
psf_az
|
NDArray | Iterable[NDArray]
|
psf for view a in z-direction |
required |
psf_ay
|
NDArray | Iterable[NDArray]
|
psf for view a in y-direction |
required |
psf_ax
|
NDArray | Iterable[NDArray]
|
psf for view a in x-direction |
required |
psf_bz
|
NDArray | Iterable[NDArray]
|
psf for view b in z-direction |
required |
psf_by
|
NDArray | Iterable[NDArray]
|
psf for view b in y-direction |
required |
psf_bx
|
NDArray | Iterable[NDArray]
|
psf for view b in x-direction |
required |
bp_az
|
NDArray | Iterable[NDArray]
|
backprojector for view a in z-direction |
required |
bp_ay
|
NDArray | Iterable[NDArray]
|
backprojector for view a in y-direction |
required |
bp_ax
|
NDArray | Iterable[NDArray]
|
backprojector for view a in x-direction |
required |
bp_bz
|
NDArray | Iterable[NDArray]
|
backprojector for view b in z-direction |
required |
bp_by
|
NDArray | Iterable[NDArray]
|
backprojector for view b in y-direction |
required |
bp_bx
|
NDArray | Iterable[NDArray]
|
backprojector for view b in x-direction |
required |
decon_function
|
str
|
deconvolution function to use. One of |
required |
num_iter
|
int
|
number of deconvolution iterations |
required |
epsilon
|
float
|
small parameter for preventing division by zero |
required |
boundary_correction
|
bool
|
whether or not to do boundary correction |
required |
zero_padding
|
Optional[PadType]
|
zero padding for boundary correction |
required |
boundary_sigma_a
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
boundary_sigma_b
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
verbose
|
bool
|
show progress bar for iterations |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if input volume isn't 3- (single channel) or 4D (multichannel). |
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_sep.py
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 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
additive_joint_rl(view_a: cupy.ndarray, view_b: cupy.ndarray, est_i: cupy.ndarray, psf_az: cupy.ndarray, psf_ay: cupy.ndarray, psf_ax: cupy.ndarray, psf_bz: cupy.ndarray, psf_by: cupy.ndarray, psf_bx: cupy.ndarray, bp_az: cupy.ndarray, bp_ay: cupy.ndarray, bp_ax: cupy.ndarray, bp_bz: cupy.ndarray, bp_by: cupy.ndarray, bp_bx: cupy.ndarray, num_iter: int, epsilon: float, boundary_correction: bool, zero_padding: PadType, boundary_sigma_a: float, boundary_sigma_b: float, conv_module: Optional[cupy.RawModule], launch_pars: Optional[CuLaunchParameters], verbose: bool) -> cupy.ndarray
¶
additive_joint_rl Additive joint RL deconvolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
ndarray
|
input volume for view A |
required |
view_b
|
ndarray
|
input volume for view B |
required |
est_i
|
ndarray
|
initial estimate |
required |
psf_az
|
ndarray
|
PSF for view A, z-direction |
required |
psf_ay
|
ndarray
|
PSF for view A, y-direction |
required |
psf_ax
|
ndarray
|
PSF for view A, x-direction |
required |
psf_bz
|
ndarray
|
PSF for view B, z-direction |
required |
psf_by
|
ndarray
|
PSF for view B, y-direction |
required |
psf_bx
|
ndarray
|
PSF for view B, x-direction |
required |
bp_az
|
ndarray
|
backprojector for view A, z-direction |
required |
bp_ay
|
ndarray
|
backprojector for view A, y-direction |
required |
bp_ax
|
ndarray
|
backprojector for view A, x-direction |
required |
bp_bz
|
ndarray
|
backprojector for view B, z-direction |
required |
bp_by
|
ndarray
|
backprojector for view B, y-direction |
required |
bp_bx
|
ndarray
|
backprojector for view B, x-direction |
required |
num_iter
|
int
|
number of deconvolution iterations |
required |
epsilon
|
float
|
small parameter to prevent division by zero |
required |
boundary_correction
|
bool
|
whether or not to do boundary correction |
required |
zero_padding
|
Optional[PadType]
|
zero-padding for boundary correction |
required |
boundary_sigma_a
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
boundary_sigma_b
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
conv_module
|
Optional[RawModule]
|
|
required |
launch_pars
|
Optional[CuLaunchParameters]
|
kernel launch parameters. If |
required |
verbose
|
bool
|
description |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
cupy.ndarray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_sep.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | |
joint_rl_dispim(view_a: cupy.ndarray, view_b: cupy.ndarray, est_i: cupy.ndarray, psf_az: cupy.ndarray, psf_ay: cupy.ndarray, psf_ax: cupy.ndarray, psf_bz: cupy.ndarray, psf_by: cupy.ndarray, psf_bx: cupy.ndarray, bp_az: cupy.ndarray, bp_ay: cupy.ndarray, bp_ax: cupy.ndarray, bp_bz: cupy.ndarray, bp_by: cupy.ndarray, bp_bx: cupy.ndarray, num_iter: int, epsilon: float, boundary_correction: bool, zero_padding: PadType, boundary_sigma_a: float, boundary_sigma_b: float, conv_module: Optional[cupy.RawModule], launch_pars: Optional[CuLaunchParameters], verbose: bool) -> cupy.ndarray
¶
Joint deconvolution specifically for diSPIM volumes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
ndarray
|
input volume for view A |
required |
view_b
|
ndarray
|
input volume for view B |
required |
est_i
|
ndarray
|
initial estimate |
required |
psf_az
|
ndarray
|
PSF for view A, z-direction |
required |
psf_ay
|
ndarray
|
PSF for view A, y-direction |
required |
psf_ax
|
ndarray
|
PSF for view A, x-direction |
required |
psf_bz
|
ndarray
|
PSF for view B, z-direction |
required |
psf_by
|
ndarray
|
PSF for view B, y-direction |
required |
psf_bx
|
ndarray
|
PSF for view B, x-direction |
required |
bp_az
|
ndarray
|
backprojector for view A, z-direction |
required |
bp_ay
|
ndarray
|
backprojector for view A, y-direction |
required |
bp_ax
|
ndarray
|
backprojector for view A, x-direction |
required |
bp_bz
|
ndarray
|
backprojector for view B, z-direction |
required |
bp_by
|
ndarray
|
backprojector for view B, y-direction |
required |
bp_bx
|
ndarray
|
backprojector for view B, x-direction |
required |
num_iter
|
int
|
number of deconvolution iterations |
required |
epsilon
|
float
|
small parameter to prevent division by zero |
required |
boundary_correction
|
bool
|
whether or not to do boundary correction |
required |
zero_padding
|
Optional[PadType]
|
zero-padding for boundary correction |
required |
boundary_sigma_a
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
boundary_sigma_b
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
conv_module
|
Optional[RawModule]
|
|
required |
launch_pars
|
Optional[CuLaunchParameters]
|
kernel launch parameters. If |
required |
verbose
|
bool
|
description |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
cupy.ndarray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_sep.py
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 | |
deconvolve_chunkwise(view_a: zarr.Array, view_b: zarr.Array, out: zarr.Array, chunk_size: int | Tuple[int, int, int], overlap: int | Tuple[int, int, int], sigma_az: float, sigma_ay: float, sigma_ax: float, sigma_bz: float, sigma_by: float, sigma_bx: float, kernel_radius_z: int, kernel_radius_y: int, kernel_radius_x: int, decon_function: str, num_iter: int, epsilon: float, boundary_correction: bool, zero_padding: PadType, boundary_sigma_a: float, boundary_sigma_b: float, verbose: bool)
¶
Joint deconvolution of the input views A & B, done chunk-by-chunk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
Array
|
zarr array for view A data |
required |
view_b
|
Array
|
zarr array for view B data |
required |
out
|
Array
|
zarr array to place deconvolved, output data into |
required |
chunk_size
|
int | Tuple[int, int, int]
|
size of chunks |
required |
overlap
|
int | Tuple[int, int, int]
|
amount of overlap between chunks |
required |
sigma_az
|
float
|
standard deviation of PSF (assumed Gaussian) for view A in z-direction |
required |
sigma_ay
|
float
|
standard deviation of PSF (assumed Gaussian) for view A in y-direction |
required |
sigma_ax
|
float
|
standard deviation of PSF (assumed Gaussian) for view A in x-direction |
required |
sigma_bz
|
float
|
standard deviation of PSF (assumed Gaussian) for view B in z-direction |
required |
sigma_by
|
float
|
standard deviation of PSF (assumed Gaussian) for view B in y-direction |
required |
sigma_bx
|
float
|
standard deviation of PSF (assumed Gaussian) for view B in x-direction |
required |
kernel_radius_z
|
int
|
radius of PSF kernel in z-direction |
required |
kernel_radius_y
|
int
|
radius of PSF kernel in y-direction |
required |
kernel_radius_x
|
int
|
radius of PSF kernel in x-direction |
required |
decon_function
|
str
|
deconvolution function to use. Either |
required |
num_iter
|
int
|
number of deconvolution iterations. |
required |
epsilon
|
float
|
small parameter to prevent division by zero |
required |
boundary_correction
|
bool
|
whether or not to do boundary correction |
required |
zero_padding
|
Optional[PadType]
|
zero-padding for boundary correction |
required |
boundary_sigma_a
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
boundary_sigma_b
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
required |
verbose
|
bool
|
display a progress bar showing how many chunks have been/will be computed. |
required |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_sep.py
821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 | |
pyspim.decon.rl.singleview_sep
¶
Separable deconvolution for single view volumes.
TODO: more detail here.
Functions¶
deconvolve(volume: NDArray, psf_z: NDArray, psf_y: NDArray, psf_x: NDArray, bp_z: NDArray, bp_y: NDArray, bp_x: NDArray, num_iter: int, boundary_correction: bool, epsilon: Optional[float], init_constant: bool, boundary_padding: Optional[int], boundary_sigma: float, verbose: bool) -> NDArray
¶
deconvolve do deconvolution of volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
volume
|
NDArray
|
input volume to be deconvolved |
required |
psf_z
|
NDArray
|
PSF kernel in z-direction |
required |
psf_y
|
NDArray
|
PSF kernel in y-direction |
required |
psf_x
|
NDArray
|
PSF kernel in x-direction |
required |
bp_z
|
NDArray
|
backprojector kernel in z-direction |
required |
bp_y
|
NDArray
|
backprojector kernel in y-direction |
required |
bp_x
|
NDArray
|
backprojector kernel in x-direction |
required |
num_iter
|
int
|
number of iterations to do deconvolution for |
required |
boundary_correction
|
bool
|
whether or not to do boundary correction |
required |
epsilon
|
Optional[float]
|
small parameter to prevent division by zero |
required |
init_constant
|
bool
|
initialize deconvolution with a constant array (if |
required |
boundary_padding
|
Optional[int]
|
zero-padding for boundary correction |
required |
boundary_sigma
|
float
|
significance value for pixels when doing boundary correction |
required |
verbose
|
bool
|
show progress bar |
required |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
boundary correction |
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/singleview_sep.py
pyspim.decon.rl.dualview_fft
¶
Deconvolution algorithms for jointly deconvolving dual-view microscopy data.
References¶
[1] Wu, et. al., "Spatially isotropic four-dimensional...", doi:10.1038/nbt.2713 [2] Preibsch, et al. "Efficient Bayesian-based...", doi:10.1038/nmeth.2929 [3] Guo, et al. "Rapid image deconvolution..." doi:10.1038/s41587-020-0560-x [4] Anconelli, B., et al. "Reduction of boundary effects...", doi:10.1051/0004-6361:20053848
Functions¶
deconvolve(view_a: NDArray, view_b: NDArray, est_i: NDArray | None, psf_a: NDArray | Iterable[NDArray], psf_b: NDArray | Iterable[NDArray], backproj_a: NDArray | Iterable[NDArray], backproj_b: NDArray | Iterable[NDArray], decon_function: str, num_iter: int, epsilon: float, req_both: bool, boundary_correction: bool, zero_padding: Optional[PadType], boundary_sigma_a: float, boundary_sigma_b: float, verbose: bool) -> NDArray
¶
Joint deconvolution of 2 views into a single one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
NDArray
|
array from 1st view |
required |
view_b
|
NDArray
|
array from 2nd view |
required |
est_i
|
NDArray | None
|
initial estimate |
required |
psf_a
|
NDArray | Iterable[NDArray]
|
psf arrays for view A (single one, or 1 per channel) |
required |
psf_b
|
NDArray | Iterable[NDArray]
|
psf arrays for view B (single, or 1 per channel) |
required |
backproj_a
|
NDArray | Iterable[NDArray]
|
backprojector array(s) for view A |
required |
backproj_b
|
NDArray | Iterable[NDArray]
|
backprojector array(s) for view B |
required |
decon_function
|
str
|
style of deconvolution to use |
required |
num_iter
|
int
|
number of iterations |
required |
epsilon
|
float
|
small parameter to prevent division by zero |
required |
req_both
|
bool
|
set all areas where either view doesn't have data to 0 |
required |
boundary_correction
|
bool
|
do boundary correction |
required |
zero_padding
|
Optional[PadType]
|
zero padding for boundary correction |
required |
boundary_sigma_a
|
float
|
significance level for pixels, view a |
required |
boundary_sigma_b
|
float
|
significance level for pixels, view b |
required |
verbose
|
bool
|
show progressbar for iterations |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
input array is not 3 or 4D |
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_fft.py
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 | |
joint_rl_dispim(view_a: NDArray, view_b: NDArray, est_i: NDArray, psf_a: NDArray, psf_b: NDArray, backproj_a: Optional[NDArray] = None, backproj_b: Optional[NDArray] = None, num_iter: int = 10, epsilon: float = 1e-05, boundary_correction: bool = True, req_both: bool = False, zero_padding: Optional[PadType] = None, boundary_sigma_a: float = 0.01, boundary_sigma_b: float = 0.01, verbose: bool = False) -> NDArray
¶
joint_rl_dispim Modified Richardson-Lucy joint deconvolution, as described in [1].
originally developed by the Shroff group at the NIH for use in diSPIM imaging. NOTE: boundary correction is not implemented for this method, as at the time of writing, there is no known way of doing this
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
NDArray
|
data array corresponding to first view (A) |
required |
view_b
|
NDArray
|
data array corresponding to second view (B) |
required |
est_i
|
NDArray
|
initial estimate for deconvolution. If |
required |
psf_a
|
NDArray
|
array with real-space point spread function for view A |
required |
psf_b
|
NDArray
|
array with real-space point spread function for view B |
required |
backproj_a
|
NDArray
|
array with real-space backprojector for view A. If |
None
|
backproj_b
|
NDArray
|
array with real-space backprojector for view B. If |
None
|
num_iter
|
int
|
number of iterations to deconvolve for. Defaults to 10. |
10
|
epsilon
|
float
|
small parameter to prevent division by zero errors. Defaults to 1e-5. |
1e-05
|
boundary_correction
|
bool
|
correct boundary effects, defaults to True. |
True
|
req_both
|
bool
|
only deconvolve areas where views a & b have data, defaults to False. |
False
|
zero_padding
|
PadType
|
amount of zero-padding to add to each axis, defaults to None. if None, each axis of size N is padded on each side by N/2 so that the padded image has dimension 2N in that axis. |
None
|
boundary_sigma_a
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
0.01
|
boundary_sigma_b
|
float
|
threshold for determining significant pixels in view B, defaults to 1e-2. |
0.01
|
verbose
|
bool
|
display progress bar, defaults to False |
False
|
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_fft.py
efficient_bayesian_backprojectors(psf_a: NDArray, psf_b: NDArray) -> Tuple[NDArray, NDArray]
¶
efficient_bayesian_backprojectors Calculate proper backprojectors for "Efficient Bayesian" deconvolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psf_a
|
NDArray
|
point spread function for view A |
required |
psf_b
|
NDArray
|
point spread function for view B |
required |
Returns:
| Type | Description |
|---|---|
Tuple[NDArray, NDArray]
|
Tuple[NDArray,NDArray]: tuple of backprojectors, one for each view. |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_fft.py
efficient_bayesian(view_a: NDArray, view_b: NDArray, est_i: NDArray, psf_a: NDArray, psf_b: NDArray, num_iter: int = 10, epsilon: float = 1e-05, boundary_correction: bool = True, req_both: bool = False, zero_padding: Optional[PadType] = None, boundary_sigma_a: float = 0.01, boundary_sigma_b: float = 0.01, verbose: bool = False) -> NDArray
¶
efficient_bayesian Efficient bayesian multiview deconvolution.
Originally described in [2], this is just additive joint deconvolution with backprojectors calculated as described in the "quadruple-view deconvolution" section of [3]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
NDArray
|
data array corresponding to first view (A) |
required |
view_b
|
NDArray
|
data array corresponding to second view (B) |
required |
est_i
|
NDArray
|
initial estimate for deconvolution. If |
required |
psf_a
|
NDArray
|
array with real-space point spread function for view A |
required |
psf_b
|
NDArray
|
array with real-space point spread function for view B |
required |
backproj_a
|
NDArray
|
array with real-space backprojector for view A. If |
required |
backproj_b
|
NDArray
|
array with real-space backprojector for view B. If |
required |
num_iter
|
int
|
number of iterations to deconvolve for. Defaults to 10. |
10
|
epsilon
|
float
|
small parameter to prevent division by zero errors. Defaults to 1e-5. |
1e-05
|
boundary_correction
|
bool
|
correct boundary effects, defaults to True. |
True
|
req_both
|
bool
|
only deconvolve areas where views a & b have data, defaults to False. |
False
|
zero_padding
|
PadType
|
amount of zero-padding to add to each axis, defaults to None. if None, each axis of size N is padded on each side by N/2 so that the padded image has dimension 2N in that axis. |
None
|
boundary_sigma_a
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
0.01
|
boundary_sigma_b
|
float
|
threshold for determining significant pixels in view B, defaults to 1e-2. |
0.01
|
verbose
|
bool
|
display progress bar, defaults to False |
False
|
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_fft.py
additive_joint_rl(view_a: NDArray, view_b: NDArray, est_i: NDArray, psf_a: NDArray, psf_b: NDArray, backproj_a: Optional[NDArray] = None, backproj_b: Optional[NDArray] = None, num_iter: int = 10, epsilon: float = 1e-05, boundary_correction: bool = True, req_both: bool = False, zero_padding: Optional[PadType] = None, boundary_sigma_a: float = 0.01, boundary_sigma_b: float = 0.01, verbose: bool = False) -> NDArray
¶
additive_joint_rl Additive joint deconvolution.
With boundary correction turned off, each view is deconvolved separately and then averaged at each iteration. With boundary correction turned on, an ordered subset EM algorithm from [4] is used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
NDArray
|
data array corresponding to first view (A) |
required |
view_b
|
NDArray
|
data array corresponding to second view (B) |
required |
est_i
|
NDArray
|
initial estimate for deconvolution. If |
required |
psf_a
|
NDArray
|
array with real-space point spread function for view A |
required |
psf_b
|
NDArray
|
array with real-space point spread function for view B |
required |
backproj_a
|
NDArray
|
array with real-space backprojector for view A. If |
None
|
backproj_b
|
NDArray
|
array with real-space backprojector for view B. If |
None
|
num_iter
|
int
|
number of iterations to deconvolve for. Defaults to 10. |
10
|
epsilon
|
float
|
small parameter to prevent division by zero errors. Defaults to 1e-5. |
1e-05
|
boundary_correction
|
bool
|
correct boundary effects, defaults to True. |
True
|
req_both
|
bool
|
only deconvolve areas where views a & b have data, defaults to False. |
False
|
zero_padding
|
PadType
|
amount of zero-padding to add to each axis, defaults to None. if None, each axis of size N is padded on each side by N/2 so that the padded image has dimension 2N in that axis. |
None
|
boundary_sigma_a
|
float
|
threshold for determining significant pixels in view A, defaults to 1e-2. |
0.01
|
boundary_sigma_b
|
float
|
threshold for determining significant pixels in view B, defaults to 1e-2. |
0.01
|
verbose
|
bool
|
display progress bar, defaults to False |
False
|
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_fft.py
estimate_initialization(view_a: NDArray, view_b: NDArray, init_constant: bool) -> NDArray
¶
estimate_initialization Initialize estimate for deconvolution
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_a
|
NDArray
|
input volume, view A |
required |
view_b
|
NDArray
|
input volume, view B |
required |
init_constant
|
bool
|
initialize as constant matrix, otherwise (A + B)/2 |
required |
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/dualview_fft.py
pyspim.decon.rl.singleview_fft
¶
Single-view Richardson Lucy deconvolution using FFT-space convolution.
References¶
[1] Bertero & Boccacci, "A simple method...", doi:10.1051/0004-6361:20052717
Functions¶
richardson_lucy(image: NDArray, psf: NDArray, bp: NDArray, num_iter: int = 50, boundary_correction: bool = True, epsilon: Optional[float] = None, boundary_padding: Optional[int] = None, boundary_sigma: float = 0.01, verbose: bool = False) -> NDArray
¶
richardson_lucy Richardson-Lucy deconvolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray
|
input volume to be deconvolved |
required |
psf
|
NDArray
|
point spread function |
required |
bp
|
NDArray
|
back projector for deconvolution |
required |
num_iter
|
int
|
number of iterations. Defaults to 50. |
50
|
boundary_correction
|
bool
|
whether or not to do boundary correction. Defaults to True. |
True
|
epsilon
|
Optional[float]
|
small parameter to prevent division by zero. Defaults to None. |
None
|
boundary_padding
|
Optional[int]
|
zero-padding for boundary correction. Defaults to None. |
None
|
boundary_sigma
|
float
|
significance level for pixels when doing boundary correction. Defaults to 1e-2. |
0.01
|
verbose
|
bool
|
show a progress bar. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
uncorrected version of RL deconvolution. |
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/singleview_fft.py
richardson_lucy_boundcorr(image: NDArray, psf: NDArray, bp: Optional[NDArray] = None, num_iter: int = 50, epsilon: float = 0.0001, zero_padding: Optional[PadType] = None, boundary_sigma: float = 0.01, init_constant: bool = False, verbose: bool = False) -> NDArray
¶
richardson_lucy_boundcorr Richardson-Lucy deconvolution with boundary correction described in [1], this method reduces Gibbs oscillations that occur due to boundary effects when doing RL deconvolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray
|
input volume to be deconvolved |
required |
psf
|
NDArray
|
point spread function |
required |
bp
|
Optional[NDArray]
|
backprojector. Defaults to None, if so will used mirrored PSF. |
None
|
num_iter
|
int
|
number of iterations. Defaults to 50. |
50
|
epsilon
|
float
|
small parameter to prevent division by zero. Defaults to 1e-4. |
0.0001
|
zero_padding
|
Optional[PadType]
|
amount of zero-padding. Defaults to None. |
None
|
boundary_sigma
|
float
|
significance level for pixels when doing boundary correction. Defaults to 1e-2. |
0.01
|
init_constant
|
bool
|
whether to make the inital guess a constant array, ( |
False
|
verbose
|
bool
|
show progress bar. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/decon/rl/singleview_fft.py
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 | |
pyspim.filter.adaptive_median
¶
Adaptive Median Filtering
as described in: Weisong Zhao et al. "Sparse deconvolution improves..." Nature Biotechnology 40, 606â617 (2022).
Functions¶
pyspim.filter.fftwavelet
¶
Functions¶
remove_stripes(im: NDArray, dec_num: int, wavelet: str, sigma: float, direction: str = 'horizontal', verbose: bool = False) -> NDArray
¶
remove stripes from input image by the FFTWavelet algorithm
:param im: input image
:type im: NDArray
:param dec_num: number of decimation levels (loops)
:type dec_num: int
:param wavelet: wavelet to use
:type wavelet: str
:param sigma: description
:type sigma: float
:param direction: direction of stripes in input to be removed, defaults to 'horizontal'
:type direction: str, optional
:param verbose: show progress through loop, defaults to False
:type verbose: bool, optional
:raises ValueError: if direction isn't 'horizontal' or 'vertical'
:return: input image with stripes removed
:rtype: NDArray
Source code in packages/pyspim/src/pyspim/filter/fftwavelet.py
pyspim.psf.gauss
¶
Functions¶
gaussian_fwhm(sigma: float) -> float
¶
gaussian_fwhm Compute full-width at half-max for Gaussian from std. dev.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sigma
|
float
|
standard deviation of Gaussian |
required |
Returns:
| Type | Description |
|---|---|
float
|
float |
Source code in packages/pyspim/src/pyspim/psf/gauss.py
pyspim.opt.powell
¶
Powell's method
pyspim.deskew.ortho
¶
Deskewing by orthogonal interpolation.
Uses the 'orthogonal interpolation' scheme where interpolation is done orthogonally to the direction of the light sheet. this was originally proposed/implemented in V. Maioli's Ph.D. thesis [1]. Our code is based heavily on the implementation by D. Shepherd's group [2].
References¶
[1] Vincent Miaioli's PhD Thesis doi: 10.25560/68022 [2] github.com/QI2lab/OPM
Functions¶
deskew_stage_scan(im: NDArray, pixel_size: float, step_size: float, direction: int, theta: float = math.pi / 4, preserve_dtype: bool = False, stream: cupy.cuda.Stream | None = None) -> NDArray
¶
Deskew stage scan data into xyz coordinate system.
Output format is zyx where z is normal to the coverslip, and x & y are the coverslip, y is along the long axis of the sheet, x along is the scan direction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
im
|
NDArray
|
input volume to be deskewed |
required |
pixel_size
|
float
|
size of pixels, in real (space) units |
required |
step_size
|
float
|
real space spacing between sheets |
required |
direction
|
int
|
scan direction (±1) |
required |
theta
|
float
|
angle of objective w.r.t coverslip (in radians) |
pi / 4
|
preserve_dtype
|
bool
|
preserve input datatype in output. If |
False
|
Returns: NDArray
Source code in packages/pyspim/src/pyspim/deskew/ortho.py
output_shape(z: int, r: int, c: int, pixel_size: float, step_size: float, theta: float = math.pi / 4) -> Tuple[int, int, int]
¶
output_shape Calculate output shape of deskewing a volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
int
|
size of input volume in z-direction |
required |
r
|
int
|
size of input volume in r-direction (# rows) |
required |
c
|
int
|
size of input volume in c-direction (# cols) |
required |
pixel_size
|
float
|
pixel size, in real units |
required |
step_size
|
float
|
step size, in real units |
required |
theta
|
float
|
angle of objective w.r.t coverslip. Defaults to math.pi/4. |
pi / 4
|
Returns:
| Type | Description |
|---|---|
Tuple[int, int, int]
|
Tuple[int,int,int]: (n_z, n_y, n_x) shape of deskewed volume |
Source code in packages/pyspim/src/pyspim/deskew/ortho.py
pyspim.deskew._util
¶
Functions¶
extract_coefficients(p, degree)
¶
Extract polynomial coefficients from a polynomial function.
Given a polynomial function p(x) of specified degree, this function extracts the coefficients by evaluating the polynomial at n+1 points and solving a linear system to find the coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
callable
|
A polynomial function that takes a single argument. |
required |
degree
|
int
|
The degree of the polynomial. |
required |
Returns:
| Type | Description |
|---|---|
|
numpy.ndarray: Array of coefficients from highest to lowest degree. |
Source code in packages/pyspim/src/pyspim/deskew/_util.py
characteristic_polynomial(A)
¶
Compute the characteristic polynomial of a matrix.
This function is currently a placeholder and not implemented.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
ndarray
|
Input matrix. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NotImplemented |
This function is not yet implemented. |
Source code in packages/pyspim/src/pyspim/deskew/_util.py
pyspim.deskew.dispim
¶
Deskew stage-scanned volume into "normal" diSPIM coordinate system (see [1], esp. Figure 1).
We mimic the original Shroff lab Fiji plugin, but use a CUDA kernel for speed. Note that interpolation is done using CUDA texture memory.
References¶
[1] Kumar, et. al, "Using Stage- and Slit-...", doi: 10.1086/689589
Functions¶
deskew_stage_scan(im: NDArray, pixel_size: float, step_size: float, direction: int, **kwargs) -> NDArray
¶
Deskew the input volume, im.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
im
|
NDArray
|
input volume |
required |
pixel_size
|
float
|
pixel size, in real (space) units |
required |
step_size
|
float
|
step size, in real (space) units |
required |
direction
|
int
|
±1, direction of objective movement rel. to x-axis. |
required |
**kwargs
|
|
{}
|
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/deskew/dispim.py
output_width(depth: int, width: int, step_size: float, pixel_size: float) -> int
¶
output_width Compute output width of deskewed volume
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth
|
int
|
depth of input (pre-deskewing) volume |
required |
width
|
int
|
width of input (pre-deskewing) volume |
required |
step_size
|
float
|
step size, in real (space) units |
required |
pixel_size
|
float
|
pixel size, in real (space) units |
required |
Returns:
| Type | Description |
|---|---|
int
|
int |
Source code in packages/pyspim/src/pyspim/deskew/dispim.py
pyspim.deskew.shear
¶
Deskew by shear-warp algorithm.
Deskew the input volume using an affine transformation. Should return the same result as dispim but using shear-warp algorithm and (possibly higher-order) interpolation instead of texture-based interpolation.
Functions¶
inv_deskew_matrix(pixel_size: float, step_size: float, direction: int) -> numpy.ndarray
¶
Inverse deskewing matrix
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pixel_size
|
float
|
size of pixels, in real space |
required |
step_size
|
float
|
spacing between sheets, in real units |
required |
direction
|
int
|
scan direction (±1) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray |
Source code in packages/pyspim/src/pyspim/deskew/shear.py
output_shape(z: int, r: int, c: int, pixel_size: float, step_size: float, direction: int, auto_crop: bool) -> Tuple[int, int, int]
¶
Compute output shape of deskewing transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
int
|
shape of input volume, z-direction |
required |
r
|
int
|
shape of input volume, r-direction (# rows) |
required |
c
|
int
|
shape of input volume, c-direction (# cols) |
required |
pixel_size
|
float
|
size of pixels, in real units |
required |
step_size
|
float
|
spacing between steps, in real units |
required |
direction
|
int
|
scan direction (± 1) |
required |
auto_crop
|
bool
|
automatically crop the output to account for rotation of B-view |
required |
Returns:
| Type | Description |
|---|---|
Tuple[int, int, int]
|
Tuple[int,int,int] |
Source code in packages/pyspim/src/pyspim/deskew/shear.py
deskewing_transform(z: int, r: int, c: int, pixel_size: float, step_size: float, direction: int, auto_crop: bool, rotation_thetas: Tuple[float, float, float] | None) -> Tuple[NDArray, Tuple[int, int, int]]
¶
Compute the deskewing transform for the input volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
int
|
size of input volume, z-direction (pixels) |
required |
r
|
int
|
size of input volume, r-direction (pixels, # rows) |
required |
c
|
int
|
size of input volume, c-direction (pixels, # cols) |
required |
pixel_size
|
float
|
size of pixels, in real units |
required |
step_size
|
float
|
step size, in real units |
required |
direction
|
int
|
scan direction (±1) |
required |
auto_crop
|
bool
|
auto-crop outputs to account for rotation of B into coordinate system of A. |
required |
rotation_thetas
|
Tuple[int, int, int] | None
|
rotation angles for each axis. If |
required |
Returns:
| Type | Description |
|---|---|
Tuple[NDArray, Tuple[int, int, int]]
|
numpy.ndarray, List[int]: deskewing transform & the output shape |
Source code in packages/pyspim/src/pyspim/deskew/shear.py
deskew_stage_scan(im: cupy.ndarray, pixel_size: float, step_size: float, direction: int, rotation_thetas: Tuple[float, float, float] | None, interp_method: str, auto_crop: bool, preserve_dtype: bool, block_size: Tuple[int, int, int]) -> cupy.ndarray
¶
Deskew the input volume using the shear-warp algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
im
|
ndarray
|
input volume to be deskewed. |
required |
pixel_size
|
float
|
pixel size, in real units |
required |
step_size
|
float
|
step size, in real units |
required |
direction
|
int
|
scan direction (± 1) |
required |
rotation_thetas
|
Tuple[float, float, float] | None
|
rotation angles for each axis. If |
required |
interp_method
|
str
|
interpolation method to use |
required |
auto_crop
|
bool
|
auto-crop output volumes to account for rotation of view B |
required |
preserve_dtype
|
bool
|
make output volume have same datatype as input volume (probably uint16). |
required |
block_size
|
Tuple[int, int, int]
|
size of blocks for CUDA kernel launch. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
cupy.ndarray |
Source code in packages/pyspim/src/pyspim/deskew/shear.py
pyspim.reg.mutinfo
¶
Functions¶
mutual_information(ref: NDArray, tar: NDArray, tM: NDArray, nbin_ref: int, nbin_tar: int) -> float
¶
mutual information between input images ref & tar where tar
is first transformed by matrix tM
:param ref: reference volume
:type ref: NDArray
:param tar: target (AKA "moving") volume
:type tar: NDArray
:param tM: matrix to transform tar with
:type tM: NDArray
:param nbin_ref: # of bins in histogram of ref
:type nbin_ref: int
:param nbin_tar: # of bins in histogram of tar
:type nbin_tar: int
:returns: mutual information between ref and transformed tar
:rtype: float
Source code in packages/pyspim/src/pyspim/reg/mutinfo.py
entropy_correlation_coeff(ref: NDArray, tar: NDArray, tM: NDArray, nbin_ref: int, nbin_tar: int) -> float
¶
entropy correlation coefficient between input images ref & tar
where tar is first transformed by matrix tM
:param ref: reference volume
:type ref: NDArray
:param tar: target (AKA "moving") volume
:type tar: NDArray
:param tM: matrix to transform tar with
:type tM: NDArray
:param nbin_ref: # of bins in histogram of ref
:type nbin_ref: int
:param nbin_tar: # of bins in histogram of tar
:type nbin_tar: int
:returns: entropy correlation coefficient between ref and transformed tar
:rtype: float
Source code in packages/pyspim/src/pyspim/reg/mutinfo.py
pyspim.reg.powell
¶
Functions¶
optimize_affine(ref: cupy.ndarray, mov: cupy.ndarray, metric: str, transform: str, interp_method: str, par0: List[float], bounds: Optional[Union[OptBounds, OptBoundMargins]] = None, kernel_launch_params: Optional[CuLaunchParameters] = None, verbose: bool = False, **opt_kwargs)
¶
Find optimal affine transform to register mov with ref by Powell's method
**opt_kwargs are passed to scipy.optimize.minimize
:param ref: reference volume :type ref: cupy.ndarray :param mov: moving volume, to be registered :type mov: cupy.ndarray :param metric: metric to optimize for registration one of ('nip', 'cr', 'ncc'). 'nip' : normalized inner product 'cr' : correlation ratio 'ncc' : normalized cross correlation :type metric: str :param transform: transform to optimize :type transform: str :param interp: interpolation method to use during transformation one of ('linear', 'cubspl') 'linear' : trilinear interpolation 'cubspl' : cubic b-spline interpolation :type interp: str :param par0: initial guess for parameters :type par0: list :param bounds: bounds for parameters :type bounds: list :param verbose: show intermediate results with tqdm progress bar :type verbose: bool :returns: transform and optimization results :rtype: Tuple[NDArray,OptimizeResult]
Source code in packages/pyspim/src/pyspim/reg/powell.py
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 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
pyspim.reg.pcc
¶
Functions¶
translation(ref: NDArray, mov: NDArray, upsample_factor: int = 1) -> NDArray
¶
Determine translation between ref and mov.
:param ref: reference image
:type ref: NDArray
:param mov: image to register. must be same dimensionality as ref
:type mov: NDArray
:param upsample_factor: upsampling factor, images are registered to
1/upsample_factor. defaults to 1.
:type upsample_factor: int
:returns: translation along each axis
:rtype: NDArray
Source code in packages/pyspim/src/pyspim/reg/pcc.py
scale_rotation(ref: NDArray, mov: NDArray, upsample_factor: int = 1) -> Tuple[float, float]
¶
determine scaling & rotation between ref & mov using phase cross
correlation of the log-polar transformed inputs
:param ref: reference image
:type ref: NDArray
:param mov: image to register. must be same dimensionality as ref
:type mov: NDArray
:param upsample_factor: upsampling factor, images are registered to
1/upsample_factor. defaults to 1.
:type upsample_factor: int
:returns: rotation (in degrees) and scale difference between ref & mov
:rtype: Tuple[float,float]
Source code in packages/pyspim/src/pyspim/reg/pcc.py
rotation_scale_for_volumes(ref: NDArray, mov: NDArray, upsample_factor: int = 1.0)
¶
calculate rotation, and scaling between input volumes by phase cross correlation of the maximum projections in each axis
:param ref: reference volume
:type ref: NDArray
:param mov: 'moving' volume to be registered to ref
:type mov: NDArray
:param upsample_factor: upsampling factor. images are registered to
1/upsample_factor. defaults to 1
:type upsample_factor: float
:returns: rotation and scaling for each axis
:rtype: Tuple[NDArray,NDArray]
Source code in packages/pyspim/src/pyspim/reg/pcc.py
translation_for_volumes(ref: NDArray, mov: NDArray, upsample_factor: int = 1)
¶
calculate relative translation, rotation, and scaling between input volumes by phase cross correlation of the maximum projections in each axis
:param ref: reference volume
:type ref: NDArray
:param mov: 'moving' volume to be registered to ref
:type mov: NDArray
:param upsample_factor: upsampling factor. images are registered to
1/upsample_factor. defaults to 1
:type upsample_factor: float
:returns: translation, rotation, and scaling for each axis
:rtype: Tuple[NDArray,NDArray,NDArray]
Source code in packages/pyspim/src/pyspim/reg/pcc.py
translation_rotation_scale_for_volumes(ref: NDArray, mov: NDArray, upsample_factor: int = 1)
¶
calculate relative translation, rotation, and scaling between input volumes by phase cross correlation of the maximum projections in each axis
:param ref: reference volume
:type ref: NDArray
:param mov: 'moving' volume to be registered to ref
:type mov: NDArray
:param upsample_factor: upsampling factor. images are registered to
1/upsample_factor. defaults to 1
:type upsample_factor: float
:returns: translation, rotation, and scaling for each axis
:rtype: Tuple[NDArray,NDArray,NDArray]
Source code in packages/pyspim/src/pyspim/reg/pcc.py
pyspim.reg.kernels
¶
pyspim.data.dispim
¶
utilities for loading data acquired in micro-manager with the ASI diSPIM plugin
Functions¶
uManagerAcquisition(path: os.PathLike, multi_pos: bool = False, xp: ModuleType = numpy)
¶
uManagerAcquisition Create new acquisition object for fetching raw acquisition data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
PathLike
|
path to root directory of acquisition |
required |
multi_pos
|
bool
|
flag for if this is a multi-position acquisition. Defaults to False. |
False
|
xp
|
ModuleType
|
array module to load data into ( |
numpy
|
Source code in packages/pyspim/src/pyspim/data/dispim.py
parse_position_list(path: os.PathLike) -> numpy.ndarray
¶
parse_position_list Parse uManager position list into numpy array
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
PathLike
|
path to the PositionList.pos file |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: 6-column array [position_index, grid_z, grid_y, z, y, x] |
Source code in packages/pyspim/src/pyspim/data/dispim.py
subtract_constant_uint16arr(arr: NDArray, const: int) -> NDArray
¶
subtract_constant_uint16arr Subtract constant value from uint16 array, preventing underflow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
NDArray
|
input array |
required |
const
|
int
|
value to subtract |
required |
Returns:
| Type | Description |
|---|---|
NDArray
|
NDArray |
Source code in packages/pyspim/src/pyspim/data/dispim.py
pyspim.interp.affine
¶
Functions¶
output_shape_for_transform(T: NDArray, input_shape: tuple[int, int, int]) -> Tuple[int, int, int]
¶
Calculate output shape of transformed volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
T
|
NDArray
|
affine transform matrix |
required |
input_shape
|
Iterable
|
shape of input volume (ZRC) |
required |
Returns:
| Type | Description |
|---|---|
Tuple[int, int, int]
|
Tuple[int,int,int]: output shape (ZRC) |
Source code in packages/pyspim/src/pyspim/interp/affine.py
output_shape_for_inv_transform(T: NDArray, input_shape: tuple[int, int, int]) -> Tuple[int, int, int]
¶
Calculate output shape of (inverse)-transformed volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
T
|
NDArray
|
affine transform matrix (to be inverted) |
required |
input_shape
|
Iterable
|
shape of input volume (ZRC) |
required |
Returns:
| Type | Description |
|---|---|
Tuple[int, int, int]
|
Tuple[int,int,int]: shape of output volume (ZRC) |
Source code in packages/pyspim/src/pyspim/interp/affine.py
transform(A: NDArray, T: NDArray, interp_method: str, preserve_dtype: bool, out_shp: Tuple[int, int, int] | None, block_size_z: int, block_size_y: int, block_size_x: int, gpu_id: int = 0, n_gpu: int = 1) -> cupy.ndarray
¶
Apply affine transform to input volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
NDArray
|
input volume (ZRC) |
required |
T
|
NDArray
|
affine transform matrix (4x4), rows of matrix corresp. to XYZ |
required |
interp_method
|
str
|
interpolation method to use when interpolating points in the transformed volume. One of |
required |
preserve_dtype
|
bool
|
make output datatype match that of the input (uint16), if False, output is single-precision float. |
required |
out_shp
|
Tuple[int, int, int] | None
|
shape of output volume. if |
required |
block_size_z
|
int
|
size of kernel launch block, in z dimension |
required |
block_size_y
|
int
|
size of kernel launch block, in y dimension |
required |
block_size_x
|
int
|
size of kernel launch block, in x dimension |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if input is not a |
Returns:
| Type | Description |
|---|---|
ndarray
|
cupy.ndarray: transformed volume |
Notes
The input transform, T, should be the forward transform mapping the input to the desired output domain. Internally, this function takes the inverse of the specified transform and then iterates over the output domain to extract values from the input array.
Source code in packages/pyspim/src/pyspim/interp/affine.py
pyspim.fsc.checkerboard
¶
image/volume splitting by checkerboard subsampling
Functions¶
checkerboard_split(arr: NDArray, split: int) -> Tuple[NDArray, NDArray]
¶
checkerboard split images or volumes for FSC analysis generate pairs of images for FS(R)C analysis by subsampling them, as described in Fig. 2(a) of [1]
References¶
[1] Koho, et al. "Fourier ring correlation..." doi:10.1038/s41467-019-11024-z
:param arr: input image/volume :type arr: NDArray :param split: type of split to do :type split: int :returns: checkerboard-subsampled halves of input array :rtype: Tuple[NDArray,NDArray]
Source code in packages/pyspim/src/pyspim/fsc/checkerboard.py
pyspim.fsc.main
¶
Functions¶
fourier_ring_correlation(im1: NDArray, im2: NDArray, bin_edges: Sequence, pixel_size: Optional[float] = None) -> FRCOutput
¶
compute Fourier Ring Correlation for pair of input images pair should be checkerboard-subsampled pair of images originating from a single image
:param im1: image 1
:type im1: NDArray
:param im2: image 2
:type im2: NDArray
:param bin_edges: edges of frequency bins that FRC is calculated over
:type bin_edges: Sequence
:param pixel_size: pixel size, in real-space units.
if None, output spatial frequencies will be in units pix^{-1}
if specified, output spatial frequencies will have correct units
:type pixel_size: Optional[float]
:returns: FRC values and corresponding spatial frequencies
:rtype: Tuple[NDArray,NDArray]
Source code in packages/pyspim/src/pyspim/fsc/main.py
fourier_shell_correlation(vol1: NDArray, vol2: NDArray, bin_edges: Sequence, voxel_size: Optional[float] = None) -> FSCOutput
¶
compute Fourier Shell Correlation for pair of input volumes pair should be checkerboard-subsampled pair of volumes originating from a single volume
:param vol1: volume 1 :type vol1: NDArray :param vol2: volume 2 :type vol2: NDArray :param bin_edges: :type bin_edges: Sequence :param voxel_size: :type voxel_size: Optional[float] :returns: :rtype: Tuple[NDArray,NDArray,NDArray]