code: def filter_headers(criterion):
      
      ip = get_ipython()
      for headerkind in ['processed', 'raw']:
          for h in ip.user_ns['_headers'][headerkind][:]:
              if not criterion(h):
                  ip.user_ns['_headers'][headerkind].remove(h)
      ip.user_ns['allsamplenames'] = {h.title for h in ip.user_ns['_headers']['processed']}
docs: Filter already loaded headers against some criterion.
  
      The criterion function must accept a single argument, which is an instance
      of sastool.classes2.header.Header, or one of its subclasses. The function
      must return True if the header is to be kept or False if it needs to be
      discarded. All manipulations on the header (including sample name changes,
      etc.) carried out by this function are preserved.