Skip to content

Commit

Permalink
Merge pull request #350 from w-k-jones/PBC_feature_location_fix
Browse files Browse the repository at this point in the history
PBC feature location fix
  • Loading branch information
w-k-jones authored Oct 5, 2023
2 parents aa8f0d1 + ec8d401 commit f87ea1e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
7 changes: 5 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
version: 2
formats: all
build:
os: ubuntu-22.04
tools:
python: "3.9"
python:
version: 3
install:
- requirements: doc/requirements.txt
- requirements: doc/requirements.txt
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ipykernel
nbsphinx
numpy
sphinx_rtd_theme
13 changes: 9 additions & 4 deletions tobac/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ def add_markers(
marker_arr = marker_arr[np.newaxis, :, :]

if seed_3D_flag == "column":
for index, row in features.iterrows():
marker_arr[level, int(row["hdim_1"]), int(row["hdim_2"])] = row["feature"]
for _, row in features.iterrows():
# Offset marker locations by 0.5 to find nearest pixel
marker_arr[
level,
int(row["hdim_1"] + 0.5) % h1_len,
int(row["hdim_2"] + 0.5) % h2_len,
] = row["feature"]

elif seed_3D_flag == "box":
# Get the size of the seed box from the input parameter
Expand All @@ -123,7 +128,7 @@ def add_markers(
seed_h1 = seed_3D_size
seed_h2 = seed_3D_size

for index, row in features.iterrows():
for _, row in features.iterrows():
if is_3D:
# If we have a 3D input and we need to do box seeding
# we need to have 3D features.
Expand Down Expand Up @@ -781,7 +786,7 @@ def segmentation_timestep(
if buddy == 0:
continue
# isolate feature from set of buddies
buddy_feat = features_in[features_in["feature"] == buddy]
buddy_feat = features_in[features_in["feature"] == buddy].iloc[0]

# transform buddy feature position if needed for positioning in z2/y2/x2 space
# MAY be redundant with what is done just below here
Expand Down
5 changes: 4 additions & 1 deletion tobac/utils/periodic_boundaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@ def weighted_circmean(
angle_average = np.arctan2(sin_average, cos_average) % (2 * np.pi)
rescaled_average = (angle_average * scaling_factor) + low
# Round return value to try and supress rounding errors
return np.round(rescaled_average, 12)
rescaled_average = np.round(rescaled_average, 12)
if rescaled_average == high:
rescaled_average = low
return rescaled_average


def transfm_pbc_point(in_dim, dim_min, dim_max):
Expand Down

0 comments on commit f87ea1e

Please sign in to comment.