If image is 3d, get the central slice. If is already 2d, return as-is. If image is label, set 0 to np.nan.
(image, view: int, is_label)
| 278 | |
| 279 | |
| 280 | def get_2d_slice(image, view: int, is_label): |
| 281 | """If image is 3d, get the central slice. If is already 2d, return as-is. |
| 282 | If image is label, set 0 to np.nan. |
| 283 | """ |
| 284 | if image.ndim == 2: |
| 285 | out = image |
| 286 | else: |
| 287 | shape = image.shape |
| 288 | slices = [slice(0, s) for s in shape] |
| 289 | _slice = shape[view] // 2 |
| 290 | slices[view] = slice(_slice, _slice + 1) |
| 291 | out = np.squeeze(image[tuple(slices)], view) |
| 292 | if is_label: |
| 293 | out[out == 0] = np.nan |
| 294 | return out |
| 295 | |
| 296 | |
| 297 | def get_stacked_2d_ims(im, is_label): |
no outgoing calls
no test coverage detected
searching dependent graphs…