Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91445649
histograms.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
Mon, Nov 11, 04:55
Size
1 KB
Mime Type
text/x-python
Expires
Wed, Nov 13, 04:55 (2 d)
Engine
blob
Format
Raw Data
Handle
22264231
Attached To
R6289 Motion correction paper
histograms.py
View Options
from
matplotlib
import
pyplot
as
plt
from
mpl_toolkits.mplot3d
import
Axes3D
import
numpy
as
np
import
glob
path
=
'.'
n_frames
=
int
(
len
(
glob
.
glob1
(
path
,
"*.dat"
))
/
2
)
wx
=
np
.
genfromtxt
(
'tmp201804201803wx_frame1.dat'
,
delimiter
=
','
)
wy
=
np
.
genfromtxt
(
'tmp201804201803wy_frame1.dat'
,
delimiter
=
','
)
wx2
=
np
.
square
(
wx
)
wy2
=
np
.
square
(
wy
)
l2
=
wx2
+
wy2
l
=
np
.
sqrt
(
l2
)
lengths
=
np
.
empty
([
n_frames
,
wx
.
size
])
lengths
[
0
,:]
=
l
.
flatten
()
for
i
in
range
(
1
,
n_frames
):
wx
=
np
.
genfromtxt
(
'tmp201804201803wx_frame{}.dat'
.
format
(
i
+
1
),
delimiter
=
','
)
wy
=
np
.
genfromtxt
(
'tmp201804201803wy_frame{}.dat'
.
format
(
i
+
1
),
delimiter
=
','
)
wx2
=
np
.
square
(
wx
)
wy2
=
np
.
square
(
wy
)
l2
=
wx2
+
wy2
l
=
np
.
sqrt
(
l2
)
lengths
[
i
,:]
=
l
.
flatten
()
plt
.
figure
()
plt
.
hist
(
lengths
.
flatten
())
plt
.
xlabel
(
'Displacement [pixels]'
)
plt
.
ylabel
(
'Frequency'
)
plt
.
show
()
plt
.
figure
()
plt
.
hist2d
(
lengths
.
flatten
(),
np
.
repeat
(
range
(
1
,
n_frames
+
1
),
wx
.
size
),
bins
=
9
)
plt
.
show
()
fig
=
plt
.
figure
()
ax
=
fig
.
add_subplot
(
111
,
projection
=
'3d'
)
hist
,
xedges
,
yedges
=
np
.
histogram2d
(
lengths
.
flatten
(),
np
.
repeat
(
range
(
1
,
n_frames
+
1
),
wx
.
size
),
bins
=
9
,
range
=
[[
0
,
50
],
[
1
,
n_frames
]])
xpos
,
ypos
=
np
.
meshgrid
(
xedges
[:
-
1
],
yedges
[:
-
1
])
xpos
=
xpos
.
flatten
(
'F'
)
ypos
=
ypos
.
flatten
(
'F'
)
zpos
=
np
.
zeros_like
(
xpos
)
dx
=
2.5
*
np
.
ones_like
(
zpos
)
dy
=
(
n_frames
-
1
)
/
20
*
np
.
ones_like
(
zpos
)
dz
=
hist
.
flatten
()
ax
.
bar3d
(
xpos
,
ypos
,
zpos
,
dx
,
dy
,
dz
,
color
=
'b'
,
zsort
=
'average'
)
plt
.
show
()
plt
.
figure
()
max_lengths
=
np
.
amax
(
lengths
,
axis
=
1
)
plt
.
hist
(
max_lengths
)
plt
.
show
()
plt
.
figure
()
mean_lengths
=
np
.
mean
(
lengths
,
axis
=
1
)
plt
.
hist
(
mean_lengths
)
plt
.
show
()
Event Timeline
Log In to Comment