From 8ffdf33ae5013917cdce00c0e4ffaf92cc70e204 Mon Sep 17 00:00:00 2001 From: sharoncy <s.c.yates@medisin.uio.no> Date: Wed, 3 Apr 2024 12:58:59 +0200 Subject: [PATCH] Fix colour "auto" --- PyNutil/coordinate_extraction.py | 6 +++--- test/test10_PyNutil_web.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/PyNutil/coordinate_extraction.py b/PyNutil/coordinate_extraction.py index a58ae14..a459c06 100644 --- a/PyNutil/coordinate_extraction.py +++ b/PyNutil/coordinate_extraction.py @@ -243,13 +243,13 @@ def load_segmentation(segmentation_path: str): else: return cv2.imread(segmentation_path) -def remove_background(segmentation: np.array): +def detect_pixel_id(segmentation: np.array): """Remove the background from the segmentation and return the pixel id.""" segmentation_no_background = segmentation[~np.all(segmentation == 0, axis=2)] print("length of non background pixels: ", len(segmentation_no_background)) pixel_id = segmentation_no_background[0] print("detected pixel_id: ", pixel_id) - return segmentation_no_background, pixel_id + return pixel_id def get_region_areas(use_flat, atlas_labels, flat_file_atlas, seg_width, seg_height, slice_dict, atlas_volume, triangulation): if use_flat: @@ -299,7 +299,7 @@ def segmentation_to_atlas_space( ): segmentation = load_segmentation(segmentation_path) if pixel_id == "auto": - segmentation, pixel_id = remove_background(segmentation) + pixel_id = detect_pixel_id(segmentation) seg_height, seg_width = segmentation.shape[:2] reg_height, reg_width = slice_dict["height"], slice_dict["width"] if non_linear and "markers" in slice_dict: diff --git a/test/test10_PyNutil_web.json b/test/test10_PyNutil_web.json index 81a2f91..fd8a95a 100644 --- a/test/test10_PyNutil_web.json +++ b/test/test10_PyNutil_web.json @@ -4,6 +4,6 @@ "segmentation_folder": "PyNutil/test_data/PyTest_web", "alignment_json": "PyNutil/test_data/PyNutil_test.waln", "nonlinear": true, - "colour": [0, 0, 0], + "colour": "auto", "points_json_path": "PyNutil/outputs/test.json" } -- GitLab