def  filter_data(self, data, labels):
    """filter_data(data, labels)

    Filter out bad quality data, using criteria provided by Nina Lanza:
    1) Large, broad features (don't correspond to narrow peaks)
    2) Low SNR

    For each item thus filtered, write out a plot of the data
    with an explanation:
    1) Annotate in red the large, broad feature, or
    2) Annotate in text the SNR.

    Returns updated (filtered) data and label arrays.
    """

    n = data.shape[1]

    newdata = data
    remove_ind = []

    printt("Filtering out data with large, broad features.")
    #for i in [78]: # test data gap
    #for i in [1461]: # test broad feature
    #for i in [3400]: # test broad feature
    for i in range(n):
      waves     = range(data.shape[0])
      this_data = data[waves,i]
      peak_ind  = this_data.argmax()
      peak_wave = self.xvals[waves[peak_ind]]

      # Set min peak to examine as 30% of max
      min_peak = 0.15 * this_data[peak_ind]

      # Track red_waves: indices of bands that contribute to deciding
      # to filter out this item (if indeed it is).
      # These same wavelengths will be removed from further consideration
      # regardless of filtering decision
      red_waves = []