Skip to content

Commit

Permalink
Fix colour "auto"
Browse files Browse the repository at this point in the history
  • Loading branch information
sharoncy committed Apr 3, 2024
1 parent 2ac2759 commit 4026753
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions PyNutil/coordinate_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion test/test10_PyNutil_web.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 4026753

Please sign in to comment.