Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
575 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[run] | ||
omit = setup.py |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
#Add custom tests here | ||
# this test is run first so we will also do a little setup here | ||
|
||
import ivadomed.models as imed_models | ||
import torch | ||
import os | ||
|
||
|
||
def test_sample(): | ||
assert 1 == 1 | ||
|
||
|
||
def test_model_creation(): | ||
# creating basic model for test | ||
model = imed_models.Unet() | ||
torch.save(model, "testing_data/model_unet_test.pt") | ||
assert os.path.isfile("testing_data/model_unet_test.pt") | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import ivadomed.metrics as imed_metrics | ||
import numpy as np | ||
|
||
|
||
def test_multi_class_dice_score(): | ||
# create fake image | ||
image = np.array([[[1, 1], [1, 1]], [[0, 0], [0, 0]]]) | ||
results = imed_metrics.multi_class_dice_score(image, image) | ||
|
||
|
||
def test_mse(): | ||
# create fake image | ||
image = np.array([[[1, 1], [1, 1]], [[0, 0], [0, 0]]]) | ||
results = imed_metrics.mse(image, image) | ||
|
||
|
||
def test_haussdorf_4d(): | ||
# create fake image | ||
image = np.array([[[[1, 1], [1, 1]], [[0, 0], [0, 0]]]]) | ||
results = imed_metrics.hausdorff_score(image, image) | ||
|
||
|
||
def test_err_prec(): | ||
# create fake image | ||
image = np.array([[[0, 0], [0, 0]], [[0, 0], [0, 0]]]) | ||
image_2 = np.array([[[0, 0], [0, 0]], [[0, 0], [0, 0]]]) | ||
results = imed_metrics.precision_score(image, image_2) | ||
assert results == 0.0 | ||
|
||
|
||
def test_err_rec(): | ||
# create fake image | ||
image = np.array([[[0, 0], [0, 0]], [[0, 0], [0, 0]]]) | ||
image_2 = np.array([[[0, 0], [0, 0]], [[0, 0], [0, 0]]]) | ||
results = imed_metrics.recall_score(image, image_2, err_value=1) | ||
assert results == 1 | ||
|
||
|
||
def test_err_spec(): | ||
# create fake image | ||
image = np.array([[[1, 1], [1, 1]], [[1, 1], [1, 1]]]) | ||
image_2 = np.array([[[1, 1], [1, 1]], [[1, 1], [1, 1]]]) | ||
results = imed_metrics.specificity_score(image, image_2, err_value=12) | ||
assert results == 12 | ||
|
||
|
||
def test_err_iou(): | ||
image = np.array([[[0, 0], [0, 0]], [[0, 0], [0, 0]]]) | ||
image_2 = np.array([[[0, 0], [0, 0]], [[0, 0], [0, 0]]]) | ||
results = imed_metrics.intersection_over_union(image, image_2, err_value=12) | ||
assert results == 12 | ||
|
||
|
||
def test_plot_roc_curve(): | ||
tpr = [0, 0.1, 0.5, 0.6, 0.9] | ||
fpr = [1, 0.8, 0.5, 0.3, 0.1] | ||
opt_thr_idx = 3 | ||
imed_metrics.plot_roc_curve(tpr, fpr, opt_thr_idx, "roc_test.png") | ||
|
||
|
||
def test_dice_plot(): | ||
thr_list = [0.1, 0.3, 0.5, 0.7] | ||
dice_list = [0.6, 0.7, 0.8, 0.75] | ||
imed_metrics.plot_dice_thr(thr_list, dice_list, 2, "test_dice.png") | ||
|
||
|
||
|
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,20 @@ | ||
import ivadomed.models as imed_model | ||
import torch | ||
|
||
|
||
# testing countception model | ||
def test_countception(): | ||
a = [[[[0 for i in range(10)] for i in range(10)]]] | ||
inp = torch.tensor(a).float() | ||
model = imed_model.Countception(in_channel=1, out_channel=1) | ||
inf = model(inp) | ||
assert (type(inf) == torch.Tensor) | ||
|
||
|
||
def test_model_3d_att(): | ||
# verifying if 3d attention model can be created | ||
a = [[[[[0 for i in range(48)] for j in range(48)] for k in range(16)]]] | ||
inp = torch.tensor(a).float() | ||
model = imed_model.UNet3D(in_channel=1, out_channel=1, attention=True) | ||
inf = model(inp) | ||
assert(type(inf) == torch.Tensor) |
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.