Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Cittena
cittena
Commits
b3ecf438
Commit
b3ecf438
authored
Dec 29, 2016
by
Niels-Oliver Walkowski
Browse files
add class to visualize frame sequences with multiple features
parent
deb09af0
Changes
2
Hide whitespace changes
Inline
Side-by-side
itten/visuals.py
0 → 100644
View file @
b3ecf438
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
matplotlib.pyplot
as
plt
import
matplotlib.ticker
as
plticker
class
SequencePlot
(
object
):
"""Key class for visualizations with two axis"""
def
__init__
(
self
,
width
=
40
,
height
=
3
):
self
.
width
=
width
self
.
height
=
height
def
_timelabels
(
self
,
val
,
pos
):
min
,
sec
=
divmod
(
int
(
val
),
60
)
timelabel
=
"{0}:{1:02d}"
.
format
(
min
,
sec
)
return
timelabel
# TODO styling und plotten sind hier noch etwas zusammengemischt
def
ittenstyle
(
self
,
ax
,
view
):
plt
.
style
.
use
(
'ggplot'
)
fig_coef
=
self
.
width
/
self
.
height
tick_cnt
=
fig_coef
/
0.3605405405
tick_step
=
int
(
view
.
_frames
.
frm_cnt
/
tick_cnt
)
# loc = plticker.MultipleLocator(base=tick_freq) # this locator puts ticks at regular intervals (0.0005)
loc
=
plticker
.
FixedLocator
(
range
(
0
,
view
.
_frames
.
end
,
tick_step
))
fmt
=
plticker
.
FuncFormatter
(
self
.
_timelabels
)
ax
.
xaxis
.
set_major_locator
(
loc
)
ax
.
xaxis
.
set_major_formatter
(
fmt
)
ax
.
set_xlim
(
view
.
_frames
.
start
-
20
,
view
.
_frames
.
end
+
20
)
# Beschriftung der Y-Achse
ax
.
set_ylim
(
-
1
,
view
.
_bins
+
1
)
loc
=
plticker
.
FixedLocator
(
range
(
0
,
view
.
_bins
+
1
,
int
(
view
.
_bins
/
8
)))
ax
.
yaxis
.
set_major_locator
(
loc
)
# TODO mit iter_ticks evtl noch die angegebenen Sekunden auf base 60 setzen
# obere x-achse mit zeitlich versetzten werten
axt
=
ax
.
twiny
()
axt
.
set_xlim
(
ax
.
get_xlim
())
# loc = plticker.MultipleLocator(base=tick_freq)
# loc = plticker.LinearLocator(20)
loc
=
plticker
.
FixedLocator
(
range
(
int
(
tick_step
/
2
),
view
.
_frames
.
end
,
tick_step
))
fmt
=
plticker
.
FuncFormatter
(
self
.
_timelabels
)
axt
.
xaxis
.
set_major_locator
(
loc
)
axt
.
xaxis
.
set_major_formatter
(
fmt
)
ax
.
set_axis_bgcolor
((
1
,
1
,
1
))
# TODO: gradient
chn_label
=
view
.
_contrast
plt_title
=
' Scatter Plot of the '
+
chn_label
+
' Channel in '
+
view
.
_frames
.
folder
ax
.
set_title
(
plt_title
,
{
'fontsize'
:
14
},
y
=
1.18
)
ax
.
set_ylabel
(
chn_label
,
{
'fontsize'
:
8
})
ax
.
set_xlabel
(
'Time'
,
{
'fontsize'
:
8
},
y
=
0.5
)
ax
.
yaxis
.
grid
(
False
)
axt
.
yaxis
.
grid
(
False
)
ax
.
tick_params
(
length
=
0
)
axt
.
tick_params
(
length
=
0
)
ax
.
xaxis
.
grid
(
c
=
(
0.90
,
0.90
,
0.90
))
axt
.
xaxis
.
grid
(
c
=
(
0.90
,
0.90
,
0.90
))
return
(
ax
,
axt
)
class
MultivariatePlot
(
SequencePlot
):
"""Scatterplot that shows n features per frame"""
def
__init__
(
self
):
super
(
MultivariatePlot
,
self
).
__init__
()
self
.
fig
=
plt
.
figure
()
self
.
_ax
=
plt
.
axes
()
def
plot
(
self
,
view
):
x
=
view
[:,
0
]
y
=
view
[:,
1
]
value
=
view
[:,
2
]
print
(
'x: {0} | y: {1} | value: {2}'
.
format
(
x
,
y
,
value
))
thickness
=
list
([
int
((
v
-
view
.
_threshold
)
/
4000
)
for
v
in
value
])
self
.
_ax
,
axt
=
self
.
ittenstyle
(
self
.
_ax
,
view
)
# Plotten
axt
.
scatter
(
x
,
y
,
c
=
(
0
,
0
,
0
),
s
=
thickness
,
linewidths
=
0
)
# axt.scatter(x, y, c=y, cmap='Greys_r', s=thickness, linewidths=0) # DOC: vmin/vmax sorgt für die Verteilung der Fraben der Colorm
# ax.scatter(x, y, c=y, cmap='hsv', s=thickness, linewidths=0)
self
.
fig
.
tight_layout
()
self
.
fig
.
set_size_inches
(
self
.
width
,
self
.
height
)
self
.
fig
.
savefig
(
"intest.png"
,
dpi
=
200
)
return
self
.
fig
,
self
.
_ax
testing/bootstrap.py
View file @
b3ecf438
from
itten.movie
import
Movie
from
itten.views
import
UnivariateSequence
from
itten.views
import
MultivariateSequence
from
itten.visuals
import
MultivariatePlot
movie
=
Movie
(
prefix
=
'rec_'
,
folder
=
'../DHd-2017/Data/Frames/Rec/'
)
mean
=
UnivariateSequence
(
movie
.
_frames
)
cont
=
MultivariateSequence
(
movie
.
_frames
)
cont
.
populate
(
frm_stp
=
50
)
viz
=
MultivariatePlot
()
fig
,
ax
=
viz
.
plot
(
cont
)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment