Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Contrast Enhancement with UNet
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nuno Pimpão Santos Martins
Contrast Enhancement with UNet
Commits
56aa8455
Commit
56aa8455
authored
1 year ago
by
Nuno Pimpão Santos Martins
Browse files
Options
Downloads
Patches
Plain Diff
script to concatenate iou metrics
parent
60014bc1
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
processing_concatenate_iou_metrics.py
+100
-0
100 additions, 0 deletions
processing_concatenate_iou_metrics.py
with
100 additions
and
0 deletions
processing_concatenate_iou_metrics.py
0 → 100644
+
100
−
0
View file @
56aa8455
# -*- coding: utf-8 -*-
import
os
import
csv
from
pathlib
import
Path
import
numpy
as
np
import
datetime
from
tqdm
import
tqdm
def
list_find
(
array
,
substr
):
index
=
-
1
for
i
in
range
(
len
(
array
)):
if
array
[
i
].
find
(
substr
)
>=
0
:
index
=
i
return
index
data_dir
=
'
w:
\\
NPC_adult_new
\\
quantification_data
\\
iou_quantification
\\
'
dir_list
=
os
.
listdir
(
data_dir
)
dir_list
.
sort
()
dir_list
=
[
x
for
x
in
dir_list
if
os
.
path
.
isdir
(
os
.
path
.
join
(
data_dir
,
x
))
==
True
]
print
(
"
Nb of subdirs in path:
"
,
len
(
dir_list
))
conditions
=
[
'
fcenettoinput
'
,
'
dlbiasfreetoinput
'
]
for
i
in
range
(
len
(
dir_list
)
-
1
,
0
,
-
1
):
# print(dir_list[i])
item_name
=
dir_list
[
i
][
4
:
dir_list
[
i
].
index
(
'
_
'
)]
# print(item_name)
if
list_find
(
conditions
,
item_name
)
==
-
1
:
dir_list
.
pop
(
i
)
# print(dir_list)
# stop
for
folder
in
tqdm
(
dir_list
):
condition
=
folder
[
4
:
folder
.
index
(
'
_2023
'
)]
data_path
=
data_dir
+
folder
# print(data_path)
file_list
=
os
.
listdir
(
data_path
)
# print(len(file_list))
file_list
=
[
name
for
name
in
file_list
if
name
.
find
(
'
.csv
'
)
>
0
]
# print(len(file_list))
outdata
=
[]
for
filename
in
file_list
:
name_no_ext
=
condition
+
'
_
'
+
filename
[
filename
.
index
(
'
metrics_
'
)
+
8
:
filename
.
index
(
'
_ch
'
)]
data_file
=
[]
with
open
(
os
.
path
.
join
(
data_path
,
filename
),
'
r
'
)
as
infile
:
reader
=
csv
.
reader
(
infile
)
for
line
in
reader
:
try
:
zindex_check
=
float
(
line
[
0
])
# to remove header line from being passed
pci_check
=
float
(
line
[
1
])
# to remove outlier lines where PCI is inf, result of dividing by zero
# removes outliers, last line column is empty space
if
pci_check
!=
np
.
Inf
:
data_file
.
append
(
line
)
except
:
continue
# if line[0] == str(15):
# data_file.append(line)
# if line[0] == str(135):
# data_file.append(line)
# if line[0] == str(281):
# data_file.append(line)
for
i
in
range
(
len
(
data_file
)):
data_file
[
i
].
insert
(
0
,
condition
)
#data_file[i][0] = name_no_ext + '_'+ data_file[i][0]
real_z
=
str
((
len
(
data_file
)
+
1
)
-
float
(
data_file
[
i
][
1
]))
data_file
[
i
].
insert
(
2
,
real_z
)
position
=
''
if
data_file
[
i
][
1
]
==
'
15
'
:
position
=
'
Deep
'
elif
data_file
[
i
][
1
]
==
'
135
'
:
position
=
'
Intermediate
'
elif
data_file
[
i
][
1
]
==
'
281
'
:
position
=
'
Surface
'
else
:
position
=
'
Undefined
'
data_file
[
i
][
-
1
]
=
position
data_file
[
i
].
insert
(
1
,
name_no_ext
)
# I don't like this insertion here
outdata
.
append
(
data_file
[
i
])
path
=
Path
(
data_path
)
parent_path
=
str
(
path
.
parent
.
absolute
())
today_date
=
str
(
datetime
.
date
.
today
())
table_save_name
=
condition
+
'
_iou_metrics_%s.csv
'
%
today_date
with
open
(
os
.
path
.
join
(
parent_path
,
table_save_name
),
'
w
'
)
as
outfile
:
outfile
.
write
(
'
Condition,Name,Z,Real Z,iou x1,thresh x1,iou x2,trehs x2,iou x3,thresh x3,
\n
'
)
for
item
in
outdata
:
line
=
''
for
cell
in
item
:
line
+=
cell
+
'
,
'
outfile
.
write
(
line
+
'
\n
'
)
outfile
.
close
()
# print('Done')
\ No newline at end of file
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