Commit 69d9975c authored by Yan's avatar Yan
Browse files

Dataset get_spectra - arbitrary times

* spectrum for arbitrary timeframe can be requested
parent 6287aa50
......@@ -25,10 +25,11 @@ class Dataset():
self.mintime = -np.inf
self.maxtime = np.inf
def get_chromargs(self):
def get_chromargs(self, mint=None, maxt=None):
mint = mint or self.mintime
maxt = maxt or self.maxtime
times = dt.argsubselect(np.concatenate(
[subset[0] for subset in self.chromatograms]),
self.mintime, self.maxtime)
[subset[0] for subset in self.chromatograms]), mint, maxt)
args = []
for subset in self.chromatograms:
goodtimes = np.where((times < len(subset[0])) & ~(times < 0))[0]
......@@ -44,7 +45,9 @@ class Dataset():
"""implement per-case"""
raise NotImplementedError
def get_spectra(self):
def get_spectra(self, mint=None, maxt=None):
mint = mint or self.mintime
maxt = maxt or self.maxtime
"""implement per-case"""
raise NotImplementedError
......@@ -81,8 +84,10 @@ class ThermoRawDataset(Dataset):
chroms = [i[0] for i in self.dataset]
return chroms
def get_spectra(self):
args = self.get_chromargs()
def get_spectra(self, mint=None, maxt=None):
mint = mint or self.mintime
maxt = maxt or self.maxtime
args = self.get_chromargs(mint, maxt)
spectra = []
for i,subset in enumerate(self.dataset):
if cf.settings().value("view/oddeven", type=bool):
......@@ -123,8 +128,10 @@ class BrukerTimsDataset(Dataset):
self.dataset.ms1_frames, columns=('intensity',))])
return [[times,intensities]]
def get_spectra(self):
massints = self.dataset.rt_query(self.mintime*60, self.maxtime*60,
def get_spectra(self, mint=None, maxt=None):
mint = mint or self.mintime
maxt = maxt or self.maxtime
massints = self.dataset.rt_query(mint*60, maxt*60,
columns=('mz', 'intensity'))
sortmasses = np.sort(massints['mz'])
masssteps = sortmasses[1:] - sortmasses[:-1]
......
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