Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yaoyuping
nnDetection
Commits
1235f737
Commit
1235f737
authored
Apr 30, 2021
by
mibaumgartner
Browse files
WIP check
parent
0cd12185
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
0 deletions
+65
-0
README.md
README.md
+2
-0
nndet/utils/check.py
nndet/utils/check.py
+63
-0
No files found.
README.md
View file @
1235f737
...
...
@@ -191,6 +191,8 @@ task: Task000D3_Example
name
:
"
Example"
# [Optional]
dim
:
3
# number of spatial dimensions of the data
# TODO: check these
target_class
:
# define class of interest for patient level evaluations # TODO: check if this should be included
test_labels
:
True
# manually splitted test set
...
...
nndet/utils/check.py
0 → 100644
View file @
1235f737
from
nndet.io.paths
import
get_task
from
nndet.utils.config
import
load_dataset_info
def
_check_key_missing
(
cfg
:
dict
,
key
:
str
,
ktype
=
None
):
if
key
not
in
cfg
:
raise
ValueError
(
f
"Dataset information did not contain "
f
"'
{
key
}
' key, found
{
list
(
cfg
.
keys
())
}
"
)
if
ktype
is
not
None
:
if
not
isinstance
(
cfg
[
key
],
ktype
):
raise
ValueError
(
f
"Found
{
key
}
of type
{
type
(
cfg
[
key
])
}
in "
f
"dataset information but expected type
{
ktype
}
"
)
def
check_dataset_file
(
task_name
:
str
):
"""
Run a sequence of checks to confirm correct format of dataset information
Args:
task_name: task identifier to check info for
"""
cfg
=
load_dataset_info
(
get_task
(
task_name
))
_check_key_missing
(
cfg
,
"task"
,
ktype
=
str
)
_check_key_missing
(
cfg
,
"dim"
,
ktype
=
int
)
_check_key_missing
(
cfg
,
"labels"
,
ktype
=
dict
)
_check_key_missing
(
cfg
,
"modalities"
,
ktype
=
dict
)
# check dim
if
dim
:
=
cfg
[
"dim"
]
not
in
[
2
,
3
]:
raise
ValueError
(
f
"Found dim
{
dim
}
in dataset info but only support dim=2 or dim=3."
)
# check labels
for
key
,
item
in
cfg
[
"labels"
].
items
():
if
not
isinstance
(
key
,
(
str
,
int
)):
raise
ValueError
(
"Expected key of type string in dataset "
f
"info labels but found
{
type
(
key
)
}
:
{
key
}
"
)
if
not
isinstance
(
item
,
(
str
,
int
)):
raise
ValueError
(
"Expected name of type string in dataset "
f
"info labels but found
{
type
(
item
)
}
:
{
item
}
"
)
found_classes
=
sorted
(
list
(
map
(
int
,
cfg
[
"labels"
].
keys
())))
for
ic
,
idx
in
enumerate
(
found_classes
):
if
ic
!=
idx
:
raise
ValueError
(
"Found wrong order of label classes in dataset info."
f
"Found
{
found_classes
}
but expected
{
list
(
range
(
len
(
found_classes
)))
}
"
)
# check modalities
for
key
,
item
in
cfg
[
"modalities"
].
items
():
if
not
isinstance
(
key
,
(
str
,
int
)):
raise
ValueError
(
"Expected key of type string in dataset "
f
"info labels but found
{
type
(
key
)
}
:
{
key
}
"
)
if
not
isinstance
(
item
,
(
str
,
int
)):
raise
ValueError
(
"Expected name of type string in dataset "
f
"info labels but found
{
type
(
item
)
}
:
{
item
}
"
)
found_mods
=
sorted
(
list
(
map
(
int
,
cfg
[
"modalities"
].
keys
())))
for
ic
,
idx
in
enumerate
(
found_classes
):
if
ic
!=
idx
:
raise
ValueError
(
"Found wrong order of modalities in dataset info."
f
"Found
{
found_mods
}
but expected
{
list
(
range
(
len
(
found_mods
)))
}
"
)
def
check_data_and_label_splitted
():
pass
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment