Skip to content

Commit

Permalink
raise lower bound for ROI creation
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlinLiao committed Dec 1, 2023
1 parent 72a270c commit a31d680
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion spatialprofilingtoolbox/cggnn/generate_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
SETS_type,
)

# Set the minimum threshold for creating an ROI from a "small" slide to be if the slide is at least
# 10% of the size of the desired ROI size.
MIN_THRESHOLD_TO_CREATE_ROI = 0.1


def generate_graphs(
df_cell: DataFrame,
Expand Down Expand Up @@ -333,7 +337,10 @@ def create_graphs_from_specimen(
# Create as many ROIs such that the total area of the ROIs will equal the area of the source
# image times the proportion of cells on that image that have the target phenotype
slide_area = prod(df[['pixel x', 'pixel y']].max() - df[['pixel x', 'pixel y']].min())
n_rois = rint(proportion_of_target * slide_area / roi_area)
rois_in_slide = proportion_of_target * slide_area / roi_area
n_rois: int = rint(rois_in_slide)
if (n_rois == 0) and (rois_in_slide > MIN_THRESHOLD_TO_CREATE_ROI):
n_rois = 1
while (len(bounding_boxes) < n_rois) and (df_target.shape[0] > 0):
# Find the cell with the most target cells in its vicinity
tree = KDTree(df_target[['pixel x', 'pixel y']].values)
Expand Down

0 comments on commit a31d680

Please sign in to comment.