Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ngreenwald committed Aug 28, 2020
1 parent cb17a10 commit 71d5dff
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion caliban_toolbox/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ def pad_image_stack(images, crop_size):
# don't need to pad
return images
else:
new_images = np.zeros((images.shape[0], new_row_len, new_col_len, images.shape[3]))
new_images = np.zeros((images.shape[0], new_row_len, new_col_len, images.shape[3]),
dtype=images.dtype)
new_images[:, :row_len, :col_len, :] = images
return new_images

Expand Down
4 changes: 2 additions & 2 deletions caliban_toolbox/dataset_benchmarker.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _benchmark_category(self, category_ids):
stats_dict = {}
for cat in unique_categories:
# cat the index of metrics corresponding to current category
cat_idx = np.isin(unique_categories, cat)
cat_idx = np.isin(category_ids, cat)
cat_dict = {}

# sum metrics across individual images within current category
Expand All @@ -96,7 +96,7 @@ def _benchmark_category(self, category_ids):
# compute additional metrics not produced by Metrics class
cat_dict['recall'] = cat_dict['correct_detections'] / cat_dict['n_true']

cat_dict['precision'] = cat_dict['correct_detections'] / stats_dict['n_pred']
cat_dict['precision'] = cat_dict['correct_detections'] / cat_dict['n_pred']

cat_dict['f1'] = hmean([cat_dict['recall'], cat_dict['precision']])

Expand Down
1 change: 1 addition & 0 deletions caliban_toolbox/dataset_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ def build_dataset(self, tissues='all', platforms='all', output_shape=(512, 512),
current_dict = self._clean_labels(data_dict=current_dict, relabel=relabel,
small_object_threshold=small_object_threshold,
min_objects=min_objects)
print("index is {}, unique is {}".format(idx, np.unique(current_dict['y'])))
dicts[idx] = current_dict

return dicts
Expand Down
4 changes: 2 additions & 2 deletions caliban_toolbox/dataset_builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

def _create_test_npz(path, constant_value=1, X_shape=(10, 20, 20, 3), y_shape=(10, 20, 20, 1)):
X_data = np.full(X_shape, constant_value)
y_data = np.full(y_shape, constant_value, dtype='int16')
y_data = np.full(y_shape, constant_value * 2, dtype='int16')
np.savez(path, X=X_data, y=y_data)


Expand Down Expand Up @@ -553,7 +553,7 @@ def test_build_dataset(tmp_path):
assert X_base.shape[0] * 4 == X_crop.shape[0]

# check that NPZs have been relabeled
for current_dict in output_dicts:
for current_dict in output_dicts_crop:
assert len(np.unique(current_dict['y'])) == 2

# different sizes for different splits
Expand Down

0 comments on commit 71d5dff

Please sign in to comment.