Skip to content

Commit 3c1f3cc

Browse files
committed
Fix network trying to train on time points without images
The training script would crash if a position was annotated, but no image existed for that time point.
1 parent fde0ca6 commit 3c1f3cc

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

organoid_tracker/neural_network/position_detection_cnn/training_data_creator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,11 @@ def create_image_with_positions_list(experiments: Iterable[Experiment]):
178178
for experiment in experiments:
179179
# read a complete experiment
180180

181-
for time_point in experiment.positions.time_points():
181+
for time_point in experiment.images.time_points():
182182
# read a single time point
183183
positions = experiment.positions.of_time_point(time_point)
184+
if len(positions) == 0:
185+
continue # Skip this time point, nothing to train on
184186
offset = experiment.images.offsets.of_time_point(time_point)
185187

186188
# read positions to numpy array
@@ -199,7 +201,7 @@ def create_image_with_positions_list(experiments: Iterable[Experiment]):
199201
def create_image_list_without_positions(experiment: Experiment) -> List[ImageWithPositions]:
200202
image_list = []
201203

202-
for time_point in experiment.time_points():
204+
for time_point in experiment.images.time_points():
203205
image_list.append(
204206
ImageWithPositions(str(experiment.name), experiment.images, time_point, numpy.empty((0, 3), dtype=numpy.float32)))
205207

0 commit comments

Comments
 (0)