Class SegmentedSavitzkyGolay

  • All Implemented Interfaces:
    Serializable, weka.core.CapabilitiesHandler, weka.core.CapabilitiesIgnorer, weka.core.CommandlineRunnable, weka.core.OptionHandler, weka.core.RevisionHandler, weka.core.TechnicalInformationHandler, weka.filters.UnsupervisedFilter

    public class SegmentedSavitzkyGolay
    extends weka.filters.SimpleBatchFilter
    implements weka.core.TechnicalInformationHandler, weka.filters.UnsupervisedFilter
    Configures a weka.filters.unsupervised.attribute.PartitionedMultiFilter, using the supplied number of splits and the number of points to configure the weka.filters.unsupervised.attribute.SavitzkyGolay2 filter to apply to the subsets.

    BibTeX:

     @article{Savitzky1964,
        author = {A. Savitzky and Marcel J.E. Golay},
        journal = {Analytical Chemistry},
        pages = {1627-1639},
        title = {Smoothing and Differentiation of Data by Simplified Least Squares Procedures},
        volume = {36},
        year = {1964},
        HTTP = {http://dx.doi.org/10.1021/ac60214a047}
     }
     
     @inbook{Press1992,
        author = {William H. Press and Saul A. Teukolsky and William T. Vetterling and Brian P. Flannery},
        chapter = {14.8},
        edition = {Second},
        pages = {650-655},
        publisher = {Cambridge University Press},
        series = {Numerical Recipes in C},
        title = {Savitzky-Golay Smoothing Filters},
        year = {1992},
        PDF = {http://www.nrbook.com/a/bookcpdf/c14-8.pdf}
     }
     

    Valid options are:

     -num-points <list>
      The blank-separated list of number of points to use for the savitzky-golay window.
      (default: 3).
     -polynomial <int>
      The polynomial order to use for savitzky-golay.
      (default: 2)
     -derivative <int>
      The derivative order to use for savitzky-golay.
      (default: 1)
     -exclude <expr>
      The regular expression for identifying attributes to exclude from
      the splits (default: ^(sample_id)$)
     -U
      Flag for leaving unused attributes out of the output, by default
      these are included in the filter output.
     -output-debug-info
      If set, filter is run in debug mode and
      may output additional info to the console
     -do-not-check-capabilities
      If set, filter capabilities are not checked before filter is built
      (use with caution).
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_DERIVATIVE_ORDER
      the default for the derivative order.
      static String DEFAULT_EXCLUDE
      the default for the exclude expression.
      static int DEFAULT_NUM_POINTS
      the default for the number of points.
      static int DEFAULT_POLYNOMIAL_ORDER
      the default for the polynomial order.
      protected int m_DerivativeOrder
      the order of the derivative.
      protected adams.core.base.BaseRegExp m_Exclude
      the regular expression for attributes to exclude from the splits.
      protected weka.filters.unsupervised.attribute.PartitionedMultiFilter2 m_Filter
      the filter used internally.
      protected weka.core.Instances m_FirstPassData
      the filtered data from the first pass.
      protected List<Integer> m_NumPoints
      the blank-separated list of number of savgol points to use.
      protected int m_PolynomialOrder
      the polynomial order.
      protected boolean m_RemoveUnused
      Whether unused attributes are left out of the output.
      static String PREFIX_AMPLITUDE
      the prefix for a spectral attribute.
      • Fields inherited from class weka.filters.Filter

        m_Debug, m_DoNotCheckCapabilities, m_FirstBatchDone, m_InputRelAtts, m_InputStringAtts, m_NewBatch, m_OutputRelAtts, m_OutputStringAtts
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean allowAccessToFullInputFormat()  
      String derivativeOrderTipText()
      Returns the tip text for this property.
      protected weka.core.Instances determineOutputFormat​(weka.core.Instances inputFormat)
      Determines the output format based on the input format and returns this.
      String excludeTipText()
      Returns the tip text for this property.
      int getDerivativeOrder()
      Returns the order of the derivative.
      adams.core.base.BaseRegExp getExclude()
      Returns the regular expression that identifies attributes to be excluded from the splits.
      String getNumPoints()
      Returns the blank-separated list number of points to use for the savitzky-golay window (>= 1).
      String[] getOptions()
      Gets the current settings of the filter.
      int getPolynomialOrder()
      Returns the polynominal order.
      boolean getRemoveUnused()
      Gets whether unused attributes (ones that are not covered by any of the ranges) are removed from the output.
      weka.core.TechnicalInformation getTechnicalInformation()
      Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.
      String globalInfo()
      Returns a string describing this filter.
      Enumeration listOptions()
      Returns an enumeration describing the available options.
      String numPointsTipText()
      Returns the tip text for this property.
      String polynomialOrderTipText()
      Returns the tip text for this property.
      protected weka.core.Instances process​(weka.core.Instances instances)
      Processes the given data (may change the provided dataset) and returns the modified version.
      String removeUnusedTipText()
      Returns the tip text for this property.
      protected void reset()
      resets the filter, i.e., m_NewBatch to true and m_FirstBatchDone to false.
      void setDerivativeOrder​(int value)
      Sets the order of the derivative.
      void setExclude​(adams.core.base.BaseRegExp value)
      Sets the regular expression that identifies attributes to be excluded from the splits.
      void setNumPoints​(String value)
      Sets the blank-separated list number of points to use for the savitzky-golay window (>= 1).
      void setOptions​(String[] options)
      Parses a list of options for this object.
      void setPolynomialOrder​(int value)
      Sets the polynomial order.
      void setRemoveUnused​(boolean value)
      Sets whether unused attributes (ones that are not covered by any of the ranges) are removed from the output.
      • Methods inherited from class weka.filters.SimpleBatchFilter

        batchFinished, hasImmediateOutputFormat, input
      • Methods inherited from class weka.filters.SimpleFilter

        setInputFormat
      • Methods inherited from class weka.filters.Filter

        batchFilterFile, bufferInput, copyValues, copyValues, debugTipText, doNotCheckCapabilitiesTipText, filterFile, flushInput, getCapabilities, getCapabilities, getDebug, getDoNotCheckCapabilities, getInputFormat, getOutputFormat, getRevision, initInputLocators, initOutputLocators, inputFormatPeek, isFirstBatchDone, isNewBatch, isOutputFormatDefined, main, makeCopies, makeCopy, mayRemoveInstanceAfterFirstBatchDone, numPendingOutput, output, outputFormatPeek, outputPeek, postExecution, preExecution, push, push, resetQueue, run, runFilter, setDebug, setDoNotCheckCapabilities, setOutputFormat, testInputFormat, toString, useFilter, wekaStaticWrapper
    • Field Detail

      • DEFAULT_NUM_POINTS

        public static final int DEFAULT_NUM_POINTS
        the default for the number of points.
        See Also:
        Constant Field Values
      • DEFAULT_POLYNOMIAL_ORDER

        public static final int DEFAULT_POLYNOMIAL_ORDER
        the default for the polynomial order.
        See Also:
        Constant Field Values
      • DEFAULT_DERIVATIVE_ORDER

        public static final int DEFAULT_DERIVATIVE_ORDER
        the default for the derivative order.
        See Also:
        Constant Field Values
      • DEFAULT_EXCLUDE

        public static final String DEFAULT_EXCLUDE
        the default for the exclude expression.
      • m_NumPoints

        protected List<Integer> m_NumPoints
        the blank-separated list of number of savgol points to use.
      • m_PolynomialOrder

        protected int m_PolynomialOrder
        the polynomial order.
      • m_DerivativeOrder

        protected int m_DerivativeOrder
        the order of the derivative.
      • m_Exclude

        protected adams.core.base.BaseRegExp m_Exclude
        the regular expression for attributes to exclude from the splits.
      • m_RemoveUnused

        protected boolean m_RemoveUnused
        Whether unused attributes are left out of the output.
      • m_Filter

        protected weka.filters.unsupervised.attribute.PartitionedMultiFilter2 m_Filter
        the filter used internally.
      • m_FirstPassData

        protected weka.core.Instances m_FirstPassData
        the filtered data from the first pass.
    • Constructor Detail

      • SegmentedSavitzkyGolay

        public SegmentedSavitzkyGolay()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing this filter.
        Specified by:
        globalInfo in class weka.filters.SimpleFilter
        Returns:
        a description of the filter suitable for displaying in the explorer/experimenter gui
      • getTechnicalInformation

        public weka.core.TechnicalInformation getTechnicalInformation()
        Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.
        Specified by:
        getTechnicalInformation in interface weka.core.TechnicalInformationHandler
        Returns:
        the technical information about this class
      • listOptions

        public Enumeration listOptions()
        Returns an enumeration describing the available options.
        Specified by:
        listOptions in interface weka.core.OptionHandler
        Overrides:
        listOptions in class weka.filters.Filter
        Returns:
        an enumeration of all the available options.
      • setOptions

        public void setOptions​(String[] options)
                        throws Exception
        Parses a list of options for this object. Also resets the state of the filter (this reset doesn't affect the options).
        Specified by:
        setOptions in interface weka.core.OptionHandler
        Overrides:
        setOptions in class weka.filters.Filter
        Parameters:
        options - the list of options as an array of strings
        Throws:
        Exception - if an option is not supported
        See Also:
        reset()
      • getOptions

        public String[] getOptions()
        Gets the current settings of the filter.
        Specified by:
        getOptions in interface weka.core.OptionHandler
        Overrides:
        getOptions in class weka.filters.Filter
        Returns:
        an array of strings suitable for passing to setOptions
      • setNumPoints

        public void setNumPoints​(String value)
        Sets the blank-separated list number of points to use for the savitzky-golay window (>= 1).
        Parameters:
        value - the number of points
      • getNumPoints

        public String getNumPoints()
        Returns the blank-separated list number of points to use for the savitzky-golay window (>= 1).
        Returns:
        the number of points
      • numPointsTipText

        public String numPointsTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setPolynomialOrder

        public void setPolynomialOrder​(int value)
        Sets the polynomial order.
        Parameters:
        value - the order
      • getPolynomialOrder

        public int getPolynomialOrder()
        Returns the polynominal order.
        Returns:
        the order
      • polynomialOrderTipText

        public String polynomialOrderTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setDerivativeOrder

        public void setDerivativeOrder​(int value)
        Sets the order of the derivative.
        Parameters:
        value - the order
      • getDerivativeOrder

        public int getDerivativeOrder()
        Returns the order of the derivative.
        Returns:
        the order
      • derivativeOrderTipText

        public String derivativeOrderTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setExclude

        public void setExclude​(adams.core.base.BaseRegExp value)
        Sets the regular expression that identifies attributes to be excluded from the splits.
        Parameters:
        value - the expression
      • getExclude

        public adams.core.base.BaseRegExp getExclude()
        Returns the regular expression that identifies attributes to be excluded from the splits.
        Returns:
        the expression
      • excludeTipText

        public String excludeTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setRemoveUnused

        public void setRemoveUnused​(boolean value)
        Sets whether unused attributes (ones that are not covered by any of the ranges) are removed from the output.
        Parameters:
        value - if true then the unused attributes get removed
      • getRemoveUnused

        public boolean getRemoveUnused()
        Gets whether unused attributes (ones that are not covered by any of the ranges) are removed from the output.
        Returns:
        true if unused attributes are removed
      • removeUnusedTipText

        public String removeUnusedTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • reset

        protected void reset()
        resets the filter, i.e., m_NewBatch to true and m_FirstBatchDone to false.
        Overrides:
        reset in class weka.filters.SimpleFilter
      • allowAccessToFullInputFormat

        public boolean allowAccessToFullInputFormat()
        Overrides:
        allowAccessToFullInputFormat in class weka.filters.SimpleBatchFilter
      • determineOutputFormat

        protected weka.core.Instances determineOutputFormat​(weka.core.Instances inputFormat)
                                                     throws Exception
        Determines the output format based on the input format and returns this. In case the output format cannot be returned immediately, i.e., immediateOutputFormat() returns false, then this method will be called from batchFinished().
        Specified by:
        determineOutputFormat in class weka.filters.SimpleFilter
        Parameters:
        inputFormat - the input format to base the output format on
        Returns:
        the output format
        Throws:
        Exception - in case the determination goes wrong
      • process

        protected weka.core.Instances process​(weka.core.Instances instances)
                                       throws Exception
        Processes the given data (may change the provided dataset) and returns the modified version. This method is called in batchFinished().
        Specified by:
        process in class weka.filters.SimpleFilter
        Parameters:
        instances - the data to process
        Returns:
        the modified data
        Throws:
        Exception - in case the processing goes wrong