# 4.6.5.1.2. eqcorrscan.core.template_gen.extract_from_stack

`eqcorrscan.core.template_gen.``extract_from_stack`(stack, template, length, pre_pick, pre_pad, Z_include=False, pre_processed=True, samp_rate=None, lowcut=None, highcut=None, filt_order=3)

  Extract a multiplexed template from a stack of detections.

  Function to extract a new template from a stack of previous detections. Requires the stack, the template used to make the detections for the stack, and we need to know if the stack has been pre-processed.

  Parameters: | stack (obspy.core.stream.Stream) Waveform stack from detections. Can be of any length and can have delays already included, or not. template (obspy.core.stream.Stream) Template used to make the detections in the stack. Will use the delays of this for the new template. length (float) Length of new template in seconds pre_pick (float) Extract additional data before the detection, seconds pre_pad (float) Pad used in seconds when extracting the data, e.g. the time before the detection extracted. If using clustering.extract_detections this half the length of the extracted waveform. Z_include (bool) If True will include any Z-channels even if there is no template for this channel, as long as there is a template for this station at a different channel. If this is False and Z channels are included in the template Z channels will be included in the new_template anyway. pre_processed (bool) Have the data been pre-processed, if True (default) then we will only cut the data here. samp_rate (float) If pre_processed=False then this is required, desired sampling rate in Hz, defaults to False. lowcut (float) If pre_processed=False then this is required, lowcut in Hz, defaults to False. highcut (float) If pre_processed=False then this is required, highcut in Hz, defaults to False filt_order (int) If pre_processed=False then this is required, filter order, defaults to False
  Returns: | Newly cut template.
  Return type: | `obspy.core.stream.Stream`