|
1 |
| - |
2 | 1 | # Copyright 2023 Rosalind Franklin Institute
|
3 | 2 | #
|
4 | 3 | # Licensed under the Apache License, Version 2.0 (the "License");
|
|
17 | 16 | ## Module : GeoLlama.calc_by_slice ##
|
18 | 17 | ## Created : Neville Yee ##
|
19 | 18 | ## Date created : 02-Oct-2023 ##
|
20 |
| -## Date last modified : 09-Oct-2023 ## |
| 19 | +## Date last modified : 19-Apr-2024 ## |
21 | 20 | ##################################################
|
22 | 21 |
|
23 | 22 | import itertools
|
@@ -88,7 +87,20 @@ def create_slice_views(volume: npt.NDArray[any],
|
88 | 87 | coords: list,
|
89 | 88 | std_window: int=15,
|
90 | 89 | gaussian_sigma: int=None,
|
91 |
| -) -> (npt.NDArray[any], npt.NDArray[any], npt.NDArray[any]): |
| 90 | +) -> (npt.NDArray[any], npt.NDArray[any]): |
| 91 | + """ |
| 92 | + Create slice views from full tomogram for downstream processes |
| 93 | +
|
| 94 | + Args: |
| 95 | + volume (ndarray) : input 3D image (tomogram) |
| 96 | + coords (list) : list of coordinates for creation of 2D slice views |
| 97 | + std_window (int) : width of window for metric calculation for 2D slices |
| 98 | + gaussian_sigma (int) : Sigma parameter for Gaussian blurring kernal |
| 99 | +
|
| 100 | + Returns: |
| 101 | + ndarray, ndarray |
| 102 | + """ |
| 103 | + |
92 | 104 | std_half = std_window // 2
|
93 | 105 | z_range = (max(0, coords[0]-std_half), min(coords[0]+std_window-std_half, volume.shape[0]-1))
|
94 | 106 | x_range = (max(0, coords[1]-std_half), min(coords[1]+std_window-std_half, volume.shape[1]-1))
|
@@ -233,6 +245,20 @@ def evaluate_slice(slice_coords: list,
|
233 | 245 | ) -> (float, float, float, int,
|
234 | 246 | npt.NDArray, npt.NDArray, npt.NDArray, npt.NDArray,
|
235 | 247 | ):
|
| 248 | + """ |
| 249 | + Function for creation and evaluation of one 2D slice from tomogram given coordinates of intersection point |
| 250 | +
|
| 251 | + Args: |
| 252 | + slice_coords (list) : list containing coordinates of intersection point for image slicing |
| 253 | + volume (ndarray) : tomogram for evaluation |
| 254 | + pixel_size_nm (float) : pixel size of tomogram (internally binned) |
| 255 | + use_view (str) : view (orientation of slice) used for evaluation |
| 256 | + pt_thres (int) : acceptance limit (number of feature pixels) of slices |
| 257 | + autocontrast (bool) : whether to apply autocontrast on slices before evaluation |
| 258 | +
|
| 259 | + Returns: |
| 260 | + float, float, float, int, ndarray, ndarray, ndarray, ndarray |
| 261 | + """ |
236 | 262 |
|
237 | 263 | view_zy, view_zx = create_slice_views(
|
238 | 264 | volume=volume,
|
@@ -367,11 +393,26 @@ def evaluate_slice(slice_coords: list,
|
367 | 393 | surface_bottom_1, surface_bottom_2)
|
368 | 394 |
|
369 | 395 |
|
370 |
| -def evaluate_full_lamella(volume, |
371 |
| - pixel_size_nm, |
372 |
| - autocontrast, |
373 |
| - cpu=1, |
| 396 | +def evaluate_full_lamella(volume: npt.NDArray[any], |
| 397 | + pixel_size_nm: float, |
| 398 | + autocontrast: bool, |
| 399 | + cpu: int=1, |
| 400 | +) -> ( |
| 401 | + npt.NDArray, npt.NDArray, float, float, float, float, tuple |
374 | 402 | ):
|
| 403 | + """ |
| 404 | + Evaluation of full lamella geometry |
| 405 | +
|
| 406 | + Args: |
| 407 | + volume (ndarray) : Tomogram to be evaluated |
| 408 | + pixel_size_nm (float) : Pixel size (after binning) of tomogram |
| 409 | + autocontrast (bool) : whether to apply autocontrast on slices before evaluation |
| 410 | + cpu (int) : number of cores used in parallel calculation of slices |
| 411 | +
|
| 412 | + Returns: |
| 413 | + ndarray, ndarray, float, float, float, float, tuple |
| 414 | +
|
| 415 | + """ |
375 | 416 | x_slice_list = np.arange(int(volume.shape[1]*0.2),
|
376 | 417 | int(volume.shape[1]*0.8),
|
377 | 418 | int(volume.shape[1]*0.025))
|
|
0 commit comments