Skip to content

Commit

Permalink
ENH: Return number of pixels in each image
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellepace committed Jul 26, 2024
1 parent 8d9c736 commit 4e4091b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ml4h/explorations.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,14 @@ def _compute_masked_stats(img, y):
medians = np.ma.median(masked_img, axis=1).data
stds = masked_img.std(axis=1).data

# TODO take me out
print(y.shape)
print(np.unique(y))
assert(y.shape[0] == 1)
print(np.count_nonzero(y[0], axis=1))
assert(False)
# end TODO take me out

assert(masked_img.shape[0] == 1)
nb_labels = masked_img.shape[-1]
iqrs = np.zeros((1, nb_labels))
Expand Down Expand Up @@ -994,8 +1002,8 @@ def postprocess_seg_and_write_stats(y, inference_writer):
else:
for i in range(nb_out_channels):
y[...,i] = binary_erosion(y[...,i], structures[i]).astype(y.dtype)

assert(y.shape[-1] == nb_out_channels)

means, medians, stds, iqrs = _compute_masked_stats(rescaled_img, y)
csv_row = _get_csv_row(sample_id, means, medians, stds, iqrs, date)
inference_writer.writerow(csv_row)
Expand Down

0 comments on commit 4e4091b

Please sign in to comment.