Commit 1ad0289e authored by Yan's avatar Yan
Browse files

EXPERIMENTAL!! - intensities speedup

parent b8b3a0dd
......@@ -14,7 +14,7 @@ from . import zcetools_help
from . import reactivitytools
__version__ = "0.0.51"
__version__ = "0.0.52"
__all__ = ['config', 'datatools', 'docks', 'drltools', 'datasets',
......
......@@ -221,8 +221,6 @@ class BrukerTimsDataset(Dataset):
@logdecor
def get_mzmobpeakchrom(self, startmz, endmz, startmob, endmob):
"""getting mz/mob peak ion chromatogram..."""
boundsmz = sorted([startmz, endmz])
boundsmob = sorted([startmob, endmob])
intensity = np.divide([
np.sum(i['intensity'][dt.argsubselect_2d(
i['mz'], startmz, endmz,
......@@ -233,6 +231,23 @@ class BrukerTimsDataset(Dataset):
np.clip(self.chromatograms[0][1], np.finfo(np.float32).eps, None))
return intensity
@logdecor
def get_mzmobpeakchroms(self, intranges):
"""getting mz/mob peak ion chromatograms..."""
intensities = [[]] * len(intranges)
for i in self.dataset.query_iter(
np.arange(self.dataset.max_frame)+1,
columns=('intensity', 'mz', 'inv_ion_mobility')):
for j,k in enumerate(intranges):
intensities[j].append(np.sum(i['intensity'][dt.argsubselect_2d(
i['mz'], k[0], k[1], i['inv_ion_mobility'], k[2], k[3])]))
for i,j in enumerate(intensities):
if j:
intensities[i] = np.divide(intensities[i],
np.clip(self.chromatograms[0][1],
np.finfo(np.float32).eps, None))
return intensities
def get_subspace(self, xax, subselect, start, end, bins,
mint=None, maxt=None):
mint = mint or self.mintime
......
......@@ -411,6 +411,13 @@ def get_intensity(row, ds, drls):
intensity = ds.get_mzmobpeakchrom(startm, endm, startmob, endmob)
return intensity
def get_intensrange(row, ds, drls):
startm, endm = drl.get_range(drl.floatize(drls['pt'], row, 1),
drl.floatize(drls['pt'], row, 2))
startmob, endmob = drl.get_range(drl.floatize(drls['pt'], row, 4),
drl.floatize(drls['pt'], row, 5))
return [startm, endm, startmob, endmob]
def get_daughterset(ds, drls):
"""Fuction to acquire the curves of the daugher ions"""
......@@ -418,16 +425,28 @@ def get_daughterset(ds, drls):
names = []
times = np.concatenate([sub[0] - drls['tshift'].value()
for sub in ds.chromatograms])
intensityranges = [None] * drls['pt'].rowCount()
ids = []
for row in range(drls['dt'].rowCount()):
if drls['dt'].cellWidget(row, 0).checkState() == 2:
ids.append(row)
for i in range(drls['cors'].value()):
cor = drls['dt'].cellWidget(row, 1+i*2).currentIndex() - 1
if cor not in (-2, -1):
ids.append(cor)
for i in np.unique(ids):
intensityranges[i] = get_intensrange(i, ds, drls)
intensitycache = ds.get_mzmobpeakchroms(intensityranges)
intensities = []
for row in range(drls['dt'].rowCount()):
if drls['dt'].cellWidget(row, 0).checkState() == 2:
intensity = get_intensity(row, ds, drls)
intensity = intensitycache[row]
corlist = []
for i in range(drls['cors'].value()):
cor = drls['dt'].cellWidget(row, 1+i*2).currentIndex() - 1
if cor not in (-2, -1):
factor = drl.floatize(drls['dt'], row, 2+i*2, False)
correction = get_intensity(cor, ds, drls) * factor
correction = intensitycache[row] * factor
intensity = intensity - correction
corlist.append("{} * {}".format(
drls['dt'].item(row, 2+i*2).text(),
......
......@@ -42,7 +42,7 @@ def update_profile(pt, row, dataset):
spectrum = pt.cellWidget(row, 3).figure.get_axes()[0]
spectrum.clear()
limits = []
spectra = dataset.get_spectra(-np.inf, np.inf)
spectra = dataset.fullspectra
for i, spectxy in enumerate(spectra):
massargs = drl.get_subargs(pt, row, spectxy[0], 1, 2)
spectrum.plot(spectxy[0], spectxy[1], ':', color='gray')
......
Markdown is supported
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