Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86717801
artifact_plot.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Oct 8, 05:22
Size
1 KB
Mime Type
text/x-python
Expires
Thu, Oct 10, 05:22 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
21473560
Attached To
R6289 Motion correction paper
artifact_plot.py
View Options
import
matplotlib
from
matplotlib.backends.backend_agg
import
FigureCanvasAgg
as
FigureCanvas
from
matplotlib.figure
import
Figure
from
matplotlib
import
pyplot
as
plt
import
numpy
as
np
from
skimage
import
io
import
os
import
cv2
experiments
=
[
'1_170426_fly1_013'
,
'2_170608_fly1_007'
,
'4_170609_fly1_000'
]
ls
=
[
100
,
200
,
300
,
400
,
500
,
600
,
700
,
800
,
900
,
1000
]
gs
=
[
0
,
2
,
4
,
6
,
8
,
10
,
12
,
14
,
16
,
18
,
20
]
results
=
np
.
zeros
((
len
(
experiments
),
11
,
10
))
for
experiment
,
eidx
in
zip
(
experiments
,
range
(
len
(
experiments
))):
for
l
,
i
in
zip
(
ls
,
range
(
11
)):
for
g
,
j
in
zip
(
gs
,
range
(
11
)):
path
=
'/scratch/aymanns/Data_R57C10s/'
+
experiment
+
'/results/div_l{}g{}/'
.
format
(
l
,
g
)
div
=
io
.
imread
(
path
+
'div_out.tif'
)
mask
=
np
.
where
(
div
<-
1.2
)
z
=
np
.
zeros
(
div
.
shape
,
dtype
=
np
.
uint8
)
z
[
mask
]
=
255
for
frame
in
range
(
len
(
z
)):
output
=
cv2
.
connectedComponentsWithStats
(
z
[
frame
],
8
,
cv2
.
CV_32S
)
stats
=
output
[
2
]
results
[
eidx
,
j
,
i
]
+=
sum
((
stats
[
1
:,
cv2
.
CC_STAT_AREA
]
>
20
))
vmin
=
min
(
results
.
flatten
())
vmax
=
max
(
results
.
flatten
())
print
(
vmin
)
print
(
vmax
)
for
experiment
,
eidx
in
zip
(
experiments
,
range
(
len
(
experiments
))):
#plt.figure()
fig
,
ax
=
plt
.
subplots
()
im
=
ax
.
imshow
(
results
[
eidx
],
vmin
=
vmin
,
vmax
=
vmax
)
cbar
=
ax
.
figure
.
colorbar
(
im
,
ax
=
ax
)
cbar
.
ax
.
set_ylabel
(
'Number of artifacts'
,
rotation
=-
90
,
va
=
"bottom"
)
ax
.
set_xticks
(
np
.
arange
(
len
(
ls
)))
ax
.
set_yticks
(
np
.
arange
(
len
(
gs
)))
ax
.
set_xticklabels
(
ls
)
ax
.
set_yticklabels
(
gs
)
ax
.
set_ylabel
(
'gamma'
)
ax
.
set_xlabel
(
'lambda'
)
plt
.
setp
(
ax
.
get_xticklabels
(),
rotation
=
45
,
ha
=
"right"
,
rotation_mode
=
"anchor"
)
plt
.
savefig
(
'artifacts_'
+
experiment
+
'.eps'
)
Event Timeline
Log In to Comment