Skip to content

Commit

Permalink
fix implementation mistakes
Browse files Browse the repository at this point in the history
now these two fixes are made, when the algorithm is run using a deterministic matrix solver, it is exactly equal to the official implementation
  • Loading branch information
MrGranddy committed Jun 24, 2024
1 parent 08d5728 commit 9b68188
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions monai/data/ultrasound_confidence_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,18 @@ def confidence_laplacian(self, padded_index: NDArray, padded_image: NDArray, bet
s = self.normalize(s)

# Horizontal penalty
s[:vertical_end] += gamma
# s[vertical_end:diagonal_end] += gamma * np.sqrt(2) # --> In the paper it is sqrt(2)
# since the diagonal edges are longer yet does not exist in the original code
s[vertical_end:] += gamma
# Here there is a difference between the official MATLAB code and the paper
# on the edge penalty. We directly implement what the official code does.

# Normalize differences
s = self.normalize(s)

# Gaussian weighting function
s = -(
(np.exp(-beta * s, dtype="float64")) + 1.0e-6
) # --> This epsilon changes results drastically default: 1.e-6
(np.exp(-beta * s, dtype="float64")) + 10e-6
) # --> This epsilon changes results drastically default: 10e-6
# Please notice that it is not 1e-6, it is 10e-6 which is actually different.

# Create Laplacian, diagonal missing
lap = csc_matrix((s, (i, j)))
Expand Down

0 comments on commit 9b68188

Please sign in to comment.