Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mu-map
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tamino Huxohl
mu-map
Commits
fe448f7a
Commit
fe448f7a
authored
2 years ago
by
Tamino Huxohl
Browse files
Options
Downloads
Patches
Plain Diff
eval dataset_sets now also prints protocols by patient
parent
4d245893
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mu_map/eval/dataset_stats.py
+25
-3
25 additions, 3 deletions
mu_map/eval/dataset_stats.py
with
25 additions
and
3 deletions
mu_map/eval/dataset_stats.py
+
25
−
3
View file @
fe448f7a
from
typing
import
Dict
import
numpy
as
np
import
pandas
as
pd
from
mu_map.data.prepare
import
headers
from
mu_map.data.split
import
split_csv
...
...
@@ -8,9 +11,24 @@ def body_mass_index(weight: np.ndarray, size: np.ndarray) -> np.ndarray:
return
weight
/
(
size
**
2
)
def
evaluate_protocols
(
data
:
pd
.
DataFrame
)
->
Dict
[
str
,
int
]:
data
[
headers
.
datetime_acquisition
]
=
pd
.
to_datetime
(
data
[
headers
.
datetime_acquisition
]
)
protocols
=
{
"
stress
"
:
0
,
"
rest
"
:
0
,
"
stress/rest
"
:
0
,
"
rest/stress
"
:
0
}
for
patient_id
in
data
[
headers
.
patient_id
].
unique
():
_data
=
data
[
data
[
headers
.
patient_id
]
==
patient_id
]
_data
=
_data
.
sort_values
(
by
=
headers
.
datetime_acquisition
)
protocol
=
_data
[
headers
.
protocol
].
unique
()
protocol
=
list
(
map
(
lambda
_str
:
_str
.
lower
(),
protocol
))
protocol
=
"
/
"
.
join
(
protocol
)
protocols
[
protocol
]
+=
1
return
protocols
if
__name__
==
"
__main__
"
:
import
argparse
import
pandas
as
pd
parser
=
argparse
.
ArgumentParser
(
description
=
"
Evaluate dataset patient stats.
"
,
...
...
@@ -23,12 +41,16 @@ if __name__ == "__main__":
print
()
data
=
pd
.
read_csv
(
args
.
meta_csv
)
splits
=
split_csv
(
data
,
args
.
split_csv
)
_from
=
data
[
headers
.
datetime_acquisition
].
min
().
split
(
"
"
)[
0
]
_to
=
data
[
headers
.
datetime_acquisition
].
max
().
split
(
"
"
)[
0
]
print
(
f
"
Scans were performed from
{
_from
}
to
{
_to
}
"
)
protocols
=
evaluate_protocols
(
data
)
print
(
"
Protocols:
"
)
for
protocol
,
count
in
protocols
.
items
():
print
(
f
"
-
{
protocol
:
>
12
}
:
{
str
(
count
)
:
>
3
}
"
)
print
()
splits
=
split_csv
(
data
,
args
.
split_csv
)
for
split_name
,
split
in
splits
.
items
():
print
(
f
"
{
split_name
[
0
].
upper
()
}{
split_name
[
1
:
]
}
:
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment