Skip to content

Commit fd8ead1

Browse files
committed
remove origin check
1 parent 034b677 commit fd8ead1

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

evaluation/lesionwise/validate2024.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414

1515
DIM = (240, 240, 155)
1616
DIM_GLI_POSTOP = (182, 218, 182)
17-
ORIGIN = [[-1., 0., 0., -0.],
18-
[ 0., -1., 0., 239.],
19-
[ 0., 0., 1., 0.],
20-
[ 0., 0., 0., 1.]]
21-
ORIGIN_GLI_POSTOP = [[-1., 0., 0., 90.],
22-
[ 0., 1., 0., -126.],
23-
[ 0., 0., 1., -72.],
24-
[ 0., 0., 0., 1.]]
2517

2618

2719
def get_args():
@@ -50,25 +42,24 @@ def _check_header(img, label):
5042
error = ""
5143
match label:
5244
case "BraTS-GLI":
53-
if img.header.get_data_shape() != DIM_GLI_POSTOP or \
54-
not (img.header.get_qform() == ORIGIN_GLI_POSTOP).all():
45+
if img.header.get_data_shape() != DIM_GLI_POSTOP:
5546
error = ("One or more predictions is not a NIfTI file with "
56-
"dimension of 182x218x182 or origin at [-90, 126, -72].")
47+
"dimension of 182x218x182.")
5748
case "BraTS-MEN-RT":
5849
# MEN-RT doesn't have a set dimension and origin for all scans,
5950
# so don't perform any checks.
6051
pass
6152
case _:
62-
if img.header.get_data_shape() != DIM or \
63-
not (img.header.get_qform() == ORIGIN).all():
53+
if img.header.get_data_shape() != DIM:
6454
error = ("One or more predictions is not a NIfTI file with "
65-
"dimension of 240x240x155 or origin at [0, -239, 0].")
55+
"dimension of 240x240x155.")
6656
return error
6757

6858

6959
def check_file_contents(img, parent, label):
7060
"""Check that the file can be opened as NIfTI."""
7161
try:
62+
print(img)
7263
img = nib.load(os.path.join(parent, img))
7364
return _check_header(img, label)
7465
except nib.filebasedimages.ImageFileError:
@@ -80,7 +71,6 @@ def validate_file_format(preds, parent, label):
8071
"""Check that all files are NIfTI files (*.nii.gz)."""
8172
error = []
8273
if all(pred.endswith(".nii.gz") for pred in preds):
83-
8474
# Ensure that all file contents are NIfTI with correct params.
8575
if not all((res := check_file_contents(pred, parent, label)) == "" for pred in preds):
8676
error = [res]

0 commit comments

Comments
 (0)