def air_hist(self, id=None, channel_num=0, *args, **kwargs): from qtools.lib.nstats.peaks import gap_air from pyqlb.nstats.well import accepted_peaks from pyqlb.nstats.peaks import color_uncorrected_peaks, channel_amplitudes, peak_times from qtools.lib.mplot import air_hist, cleanup, render as plt_render qlwell = self.__qlwell_from_threshold_form(id) self.__set_threshold_context(qlwell) c.channel_num = int(channel_num) threshold = c.vic_threshold if c.channel_num == 1 else c.fam_threshold cutoff = request.params.get('cutoff', 500) # can detect air on either channel (especially if VICs super low) # but always report VIC amplitude air_drops = gap_air(qlwell, c.channel_num, threshold=threshold) uncorrected_air = color_uncorrected_peaks(air_drops, qlwell.color_compensation_matrix) # count number of accepted peak times air_drop_times = peak_times(air_drops) accepted_times = peak_times(accepted_peaks(qlwell)) num_air_accepted = len([t for t in air_drop_times if t in accepted_times]) # always gate on VIC air_amps = channel_amplitudes(uncorrected_air, 1) title = 'Air Droplet Histogram - %s, %s (%s)' % (c.well.plate.plate.name, c.well.well_name, 'VIC' if c.channel_num == 1 else 'FAM') fig = air_hist(title, air_amps, cutoff=cutoff, num_accepted=num_air_accepted) response.content_type = 'image/png' imgdata = plt_render(fig, dpi=72) cleanup(fig) return imgdata
def compute(self, qlwell, well_metric): if qlwell.sample_name not in self.test_well_names: return well_metric air_drops = gap_air(qlwell, self.channel_num, max_amp=self.air_max_threshold, threshold=qlwell.channels[self.channel_num].statistics.threshold or None) # Rev A: droplets would not be there if below min amplitude # Rev B: droplets will have min amplitude flag if they were below 500 # in the VIC channel accepted_times = peak_times(accepted_peaks(qlwell)) air_times = peak_times(air_drops) well_metric.air_droplets = len([t for t in air_times if t in accepted_times]) well_metric.air_droplets_threshold = qlwell.channels[1].statistics.trigger_min_amplitude
def air_plot(self, id=None, channel_num=0, *args, **kwargs): from qtools.lib.nstats.peaks import gap_air from qtools.lib.mplot import airtime, cleanup, render as plt_render qlwell = self.__qlwell_from_threshold_form(id) self.__set_threshold_context(qlwell) c.channel_num = int(channel_num) threshold = c.vic_threshold if c.channel_num == 1 else c.fam_threshold #cutoff = request.params.get('cutoff', 500) air_drops = gap_air(qlwell, c.channel_num, threshold=threshold) title = 'Air - %s - %s, %s' % (c.well.plate.plate.name, c.well.well_name, 'VIC' if c.channel_num == 1 else 'FAM') fig = airtime(title, qlwell.peaks, air_drops, c.vic_threshold if c.channel_num == 1 else c.fam_threshold, c.channel_num) response.content_type = 'image/png' imgdata = plt_render(fig, dpi=72) cleanup(fig) return imgdata