Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
Im
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王肇一
Im
Commits
dedd9c69
Commit
dedd9c69
authored
Jan 16, 2020
by
王肇一
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sns plot barchart and scatter
parent
779e4979
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
UnetBasedMethod.py
UnetBasedMethod.py
+15
-14
resCalc.py
resCalc.py
+3
-2
No files found.
UnetBasedMethod.py
View file @
dedd9c69
...
...
@@ -45,9 +45,10 @@ def step_1(net, args, device, list, position):
def
step_2
(
list
,
position
):
for
dir
in
list
:
for
num
,
dir
in
enumerate
(
list
)
:
df
=
pd
.
DataFrame
(
columns
=
(
'ug'
,
'iter'
,
'id'
,
'size'
,
'area_mean'
,
'back_mean'
))
for
name
in
tqdm
(
filter
(
lambda
x
:
x
!=
'.DS_Store'
,
os
.
listdir
(
'data/imgs/'
+
dir
)),
position
=
position
):
names
=
[
x
for
x
in
filter
(
lambda
x
:
x
!=
'.DS_Store'
,
os
.
listdir
(
'data/imgs/'
+
dir
))]
for
name
in
tqdm
(
names
,
desc
=
f
'Period{num+1}/{len(list)}'
,
position
=
position
):
match_group
=
re
.
match
(
'.*
\
s([dD]2[oO]|[lL][bB]|.*ug).*
\
s(.+)
\
.tif'
,
name
)
img
=
cv
.
imread
(
'data/imgs/'
+
dir
+
'/'
+
name
,
0
)
mask
=
cv
.
imread
(
'data/masks/'
+
dir
+
'/'
+
name
,
0
)
...
...
@@ -57,12 +58,13 @@ def step_2(list, position):
'ug'
)
else
str
.
lower
(
match_group
.
group
(
1
))
tmp_df
[
'iter'
]
=
str
.
lower
(
match_group
.
group
(
2
))
df
=
df
.
append
(
tmp_df
,
ignore_index
=
True
,
sort
=
True
)
df
[
'
pure
'
]
=
df
[
'area_mean'
]
-
df
[
'back_mean'
]
df
[
'
Intensity (a. u.)
'
]
=
df
[
'area_mean'
]
-
df
[
'back_mean'
]
df
.
sort_values
(
'ug'
,
inplace
=
True
)
baseline
=
df
[
df
[
'ug'
]
==
'd2o'
][
'
pure
'
]
.
mean
()
*
0.62
baseline
=
df
[
df
[
'ug'
]
==
'd2o'
][
'
Intensity (a. u.)
'
]
.
mean
()
*
0.62
sns
.
set_style
(
"darkgrid"
)
sns
.
catplot
(
x
=
'ug'
,
y
=
'pure'
,
kind
=
'bar'
,
data
=
df
)
sns
.
lineplot
(
x
=
'ug'
,
y
=
baseline
,
data
=
df
)
sns
.
catplot
(
x
=
'ug'
,
y
=
'Intensity (a. u.)'
,
kind
=
'bar'
,
palette
=
'vlag'
,
data
=
df
)
sns
.
swarmplot
(
x
=
"ug"
,
y
=
"Intensity (a. u.)"
,
data
=
df
,
size
=
2
,
color
=
".3"
,
linewidth
=
0
)
plt
.
axhline
(
y
=
baseline
)
plt
.
savefig
(
'data/output/'
+
dir
+
'.png'
)
...
...
@@ -108,11 +110,10 @@ if __name__ == '__main__':
elif
args
.
step
==
2
:
dir
=
[
x
for
x
in
filter
(
lambda
x
:
x
!=
'.DS_Store'
,
os
.
listdir
(
'data/imgs/'
))]
sep_dir
=
divide_list
(
dir
,
args
.
process
)
step_2
(
dir
,
0
)
# pool = Pool(args.process)
# for i, list in enumerate(sep_dir):
# pool.apply_async(step_2, args = (list, i))
# pool.close()
# pool.join()
sep_dir
=
divide_list
(
dir
,
args
.
process
)
pool
=
Pool
(
args
.
process
)
for
i
,
list
in
enumerate
(
sep_dir
):
pool
.
apply_async
(
step_2
,
args
=
(
list
,
i
))
pool
.
close
()
pool
.
join
()
resCalc.py
View file @
dedd9c69
...
...
@@ -20,10 +20,10 @@ def save_img(img_list, dir, name):
plt
.
title
(
title
)
plt
.
imshow
(
img
,
'gray'
)
try
:
os
.
makedirs
(
'data/output/'
+
dir
+
'/graph'
)
os
.
makedirs
(
'data/output/'
+
dir
)
except
:
logging
.
info
(
'Existing dir: data/output/'
+
dir
)
plt
.
savefig
(
'data/output/'
+
dir
+
'/
graph/
'
+
name
[:
-
4
]
+
'.png'
)
plt
.
savefig
(
'data/output/'
+
dir
+
'/'
+
name
[:
-
4
]
+
'.png'
)
plt
.
close
()
...
...
@@ -42,6 +42,7 @@ def get_subarea_info(img, mask):
pos
=
[(
group
[
0
][
k
],
group
[
1
][
k
])
for
k
in
range
(
len
(
group
[
0
]))]
area_points
=
np
.
array
([
mask
[
x
,
y
]
if
(
x
,
y
)
in
pos
else
0
for
x
in
range
(
200
)
for
y
in
range
(
200
)],
dtype
=
np
.
uint8
)
.
reshape
([
200
,
200
])
#cv.imwrite('mask.png',area_points)
kernel
=
np
.
ones
((
15
,
15
),
np
.
uint8
)
bg_area_mask
=
cv
.
erode
(
area_points
,
kernel
)
surround_bg_mask
=
cv
.
bitwise_xor
(
bg_area_mask
,
255
-
area_points
)
...
...
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