-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* preemptive bump * Add 502 and sorted eval * Remove large keys from Planner, add more documentation and FLOP measurement * . * Biiiiig commit * A lot of minor changes * add wandb log image * add fvcore * Fix log * moved key dropping to plan config * Lint and minor changes * more lint and add aug param dict * add plans to return * add empty list * Fix bug with way too large pickle files * add mask value to aug params * add new args * Remove abs call * Minor changes to test augs * updates * add cval and update illustrations * Add F1 * Add F1 * add F1 to val * add self * remove unused import
- Loading branch information
Showing
28 changed files
with
744 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
264 changes: 170 additions & 94 deletions
264
yucca/documentation/illustrations/augmentation_illustrations.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import numpy as np | ||
from yucca.utils.nib_utils import get_nib_spacing | ||
from surface_distance import metrics | ||
|
||
|
||
def get_surface_metrics_for_label(gt, pred, label, as_binary: bool = False): | ||
spacing = get_nib_spacing(pred) | ||
pred = pred.get_fdata() | ||
gt = gt.get_fdata() | ||
labeldict = {} | ||
|
||
if label == 0: | ||
labeldict["Average Surface Distance"] = 0 | ||
return labeldict | ||
if as_binary: | ||
gt = gt.astype(bool) | ||
pred = pred.astype(bool) | ||
else: | ||
pred = np.where(pred == label, 1, 0).astype(bool) | ||
gt = np.where(gt == label, 1, 0).astype(bool) | ||
|
||
surface_distances = metrics.compute_surface_distances( | ||
mask_gt=gt, | ||
mask_pred=pred, | ||
spacing_mm=spacing, | ||
) | ||
|
||
labeldict["Average Surface Distance"] = metrics.compute_surface_dice_at_tolerance( | ||
surface_distances=surface_distances, tolerance_mm=1 | ||
) | ||
return labeldict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from torchmetrics.classification import MulticlassF1Score | ||
from torch import Tensor | ||
|
||
|
||
class F1(MulticlassF1Score): | ||
def forward(self, input: Tensor, target: Tensor) -> Tensor: | ||
if len(target.shape) == len(input.shape): | ||
assert target.shape[1] == 1 | ||
target = target[:, 0] | ||
return super().forward(input, target) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.