Skip to content

Commit

Permalink
path plotter with roi option
Browse files Browse the repository at this point in the history
  • Loading branch information
sronilsson committed Aug 4, 2024
1 parent f669bb0 commit f1d587b
Show file tree
Hide file tree
Showing 5 changed files with 385 additions and 695 deletions.
52 changes: 11 additions & 41 deletions simba/mixins/plotting_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1625,47 +1625,17 @@ def polygons_onto_image(
return img

@staticmethod
def roi_dict_onto_img(
img: np.ndarray,
roi_dict: Dict[str, pd.DataFrame],
circle_size: Optional[int] = 2,
show_center: Optional[bool] = False,
show_tags: Optional[bool] = False,
) -> np.ndarray:

check_valid_array(
data=img, source=f"{PlottingMixin.roi_dict_onto_img.__name__} img"
)
check_if_keys_exist_in_dict(
data=roi_dict,
key=[
Keys.ROI_POLYGONS.value,
Keys.ROI_CIRCLES.value,
Keys.ROI_RECTANGLES.value,
],
name=PlottingMixin.roi_dict_onto_img.__name__,
)
img = PlottingMixin.rectangles_onto_image(
img=img,
rectangles=roi_dict[Keys.ROI_RECTANGLES.value],
circle_size=circle_size,
show_center=show_center,
show_tags=show_tags,
)
img = PlottingMixin.circles_onto_image(
img=img,
circles=roi_dict[Keys.ROI_CIRCLES.value],
circle_size=circle_size,
show_center=show_center,
show_tags=show_tags,
)
img = PlottingMixin.polygons_onto_image(
img=img,
polygons=roi_dict[Keys.ROI_POLYGONS.value],
circle_size=circle_size,
show_center=show_center,
show_tags=show_tags,
)
def roi_dict_onto_img(img: np.ndarray,
roi_dict: Dict[str, pd.DataFrame],
circle_size: Optional[int] = 2,
show_center: Optional[bool] = False,
show_tags: Optional[bool] = False) -> np.ndarray:

check_valid_array(data=img, source=f"{PlottingMixin.roi_dict_onto_img.__name__} img")
check_if_keys_exist_in_dict(data=roi_dict, key=[Keys.ROI_POLYGONS.value, Keys.ROI_CIRCLES.value, Keys.ROI_RECTANGLES.value], name=PlottingMixin.roi_dict_onto_img.__name__)
img = PlottingMixin.rectangles_onto_image(img=img, rectangles=roi_dict[Keys.ROI_RECTANGLES.value], circle_size=circle_size, show_center=show_center, show_tags=show_tags)
img = PlottingMixin.circles_onto_image(img=img, circles=roi_dict[Keys.ROI_CIRCLES.value], circle_size=circle_size, show_center=show_center, show_tags=show_tags)
img = PlottingMixin.polygons_onto_image(img=img, polygons=roi_dict[Keys.ROI_POLYGONS.value], circle_size=circle_size, show_center=show_center, show_tags=show_tags)
return img

@staticmethod
Expand Down
Loading

0 comments on commit f1d587b

Please sign in to comment.