Commit e5af27f5 authored by 3Yan's avatar 3Yan
Browse files

Added arrows control of the chromatogram

parent b5048827
......@@ -55,7 +55,7 @@ def main():
xtics=20)
chrom = dict(x=[0], y=[0], line=None, t_start=None, t_end=None,
name="Chromatogram", xlabel="time(min)",
ylabel="total ion count")
ylabel="total ion count", timesarg=None)
filename = [None]
drlcache = [None, None, None]
......@@ -78,6 +78,7 @@ def main():
gt.pan_factory(chromatogram)
gt.zoom_factory(chromatogram, 1.15)
gt.arrow_factory(spectrum, chromatogram, ds, ms, chrom)
gt.pan_factory(spectrum, ms)
gt.zoom_factory(spectrum, 1.15, ms)
mass_selector = SpanSelector(
......@@ -121,7 +122,7 @@ def main():
layout.addWidget(mpl_canvas)
mpl_canvas.setFocus()
mpl_canvas.mpl_connect('key_press_event',lambda event:
mpl_canvas.mpl_connect('key_press_event', lambda event:
update_spectrum(event, chromatogram, spectrum, ds, ms,
filename, chrom, config))
......
......@@ -37,9 +37,8 @@ def zoom_factory(axis, base_scale, plot_data=None):
ax.figure.canvas.draw()
fig = axis.get_figure()
fig.canvas.mpl_connect('scroll_event',
lambda event: zoom_fun(
event, plot_data, axis, base_scale))
fig.canvas.mpl_connect('scroll_event', lambda event: zoom_fun(
event, plot_data, axis, base_scale))
def pan_factory(axis, plot=None):
......@@ -90,28 +89,58 @@ def pick_masses(x_min, x_max, mpl_spectrum, mass_spect):
ann_spec(mpl_spectrum, mass_spect)
def pick_times(x_min, x_max, mpl_spectrum, data_set, mpl_chromatogram,
mass_spect, chrom_spect):
def plot_subtime(mpl_spectrum, mpl_chromatogram, data_set, mass_spect,
chrom_spect):
"""plot averaged spectrum of subselected part of the chromatogram"""
chrom_spect['t_start'] = x_min
chrom_spect['t_end'] = x_max
times = data_set['chrom_dat'][0, :]
timesarg = dt.argsubselect(times, x_min, x_max)
slims = [mpl_spectrum.get_xlim(), mpl_spectrum.get_ylim()]
mpl_spectrum.clear()
mass_spect['annotation'].clear()
mass_spect['x'] = data_set['masses']
mass_spect['y'] = np.mean(
data_set['matrix'][timesarg], axis=0)
data_set['matrix'][chrom_spect['timesarg']], axis=0)
pop_plot(mpl_spectrum, mass_spect)
mpl_spectrum.set_xlim(slims[0])
mpl_spectrum.set_ylim(slims[1])
mpl_chromatogram.clear()
pop_plot(mpl_chromatogram, chrom_spect)
dots_x = data_set['chrom_dat'][0, timesarg]
dots_y = data_set['chrom_dat'][1, timesarg]
dots_x = data_set['chrom_dat'][0, chrom_spect['timesarg']]
dots_y = data_set['chrom_dat'][1, chrom_spect['timesarg']]
mpl_chromatogram.plot(dots_x, dots_y, 'b.')
mpl_chromatogram.get_figure().canvas.draw()
def pick_times(x_min, x_max, mpl_spectrum, data_set, mpl_chromatogram,
mass_spect, chrom_spect):
"""subselect part of the chromatogram and plot it"""
chrom_spect['t_start'] = x_min
chrom_spect['t_end'] = x_max
times = data_set['chrom_dat'][0, :]
chrom_spect['timesarg'] = dt.argsubselect(times, x_min, x_max)
plot_subtime(mpl_spectrum, mpl_chromatogram, data_set, mass_spect,
chrom_spect)
def arrow_factory(spectrum, chromatogram, ds, mass_spect,
chrom_spect):
def arrow_fun(event, mpl_spectrum, mpl_chromatogram, data_set,
mass_spect, chrom_spect):
times = chrom_spect['timesarg']
alltimes = np.arange(len(data_set['chrom_dat'][0]))
if event.key is "right" and not isinstance(times, type(None)):
times = dt.argsubselect(alltimes, times[0]+1, times[-1]+1)
elif event.key is "left" and not isinstance(
times, type(None)):
times = dt.argsubselect(alltimes, times[0]-1, times[-1]-1)
else:
return
chrom_spect['timesarg'] = times
plot_subtime(mpl_spectrum, mpl_chromatogram, data_set,
mass_spect, chrom_spect)
fig = chromatogram.get_figure()
fig.canvas.mpl_connect('key_press_event', lambda event: arrow_fun(
event, spectrum, chromatogram, ds, mass_spect, chrom_spect))
def ann_spec(ms_spec, msdata, ann_limit=0.01):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment