Package clickDetector

Class ClickSpectrumTemplateEditDialog

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class ClickSpectrumTemplateEditDialog extends PamDialog
The edit template dialog allows users to create mean spectrums from marked out events. A created mean spectrum can be exported as .csv file and displayed on the Click Spectrum window. Templates contain data on species ,sample rate, and standard deviation of each frequency bin along with the mean FFT. The idea behind these templates is that they can be used to help the user identify dolphin clicks and perhaps highlight common features over multiple clicks. The problem of classifying dolphin clicks is a difficult one. Different clicks from the same animal often have highly different spectral properties. For some species the average spectrum of multiple clicks does contain peaks and features which can be useful. The aim of this class is to allow the user to gain some kind of handle on these features. Further development must look at some sort of statistical analysis to quantify the similarity between a template and click/click event.

A note on creating mean spectrums;

The rules of logarithms are, to the casual mathematician, a bit strange. We need to be careful when constructing a mean or standard deviation of logarithmic spectrums mainly because log(x)+log(y) does NOT equal log(x+y). So if we create a mean spectrum, then take the log of that, it is not the same as calculating the log of each click fft and then taking the mean. The same applies to standard deviation.

Author:
Jamie Macaulay
See Also:
  • Constructor Details

    • ClickSpectrumTemplateEditDialog

      public ClickSpectrumTemplateEditDialog(Window parentFrame, Point pt, ClickControl clickControl)
  • Method Details

    • showDialog

      public static ClickSpectrumTemplateParams showDialog(Window parentFrame, Point pt, ClickSpectrum clickSpectrum, ClickSpectrumTemplateParams clickSpectrumTemplateParams, ClickControl clickControl)
      Creates an instance of the edit template dialog, associated with the Click Spectrum window it was opened from.
      Parameters:
      parentFrame -
      pt -
      clickSpectrum -
      clickSpectrumTemplateParams -
      clickControl -
      Returns:
      new clickSpectrumTemplateParams
    • setClickSpectrum

      public void setClickSpectrum(ClickSpectrum clickSpectrum)
    • addListSelectionListener

      public void addListSelectionListener(ListSelectionListener listSelectionListener)
    • controls

      public JPanel controls()
    • getEventFFTs

      public ArrayList<double[]> getEventFFTs(Integer channel, boolean normalise)
      Get the event ffts for the selected channel. If channel is null then then all ffts from every event are selected. Have to be careful here with channel numbers here. If an event does not have any clicks form the selected channel then an empty ArrayList is returned.
      Parameters:
      channel -
      Returns:
    • openFileBrowser

      public String openFileBrowser()
    • loadTemplate

      public void loadTemplate()
    • saveTemplate

      public void saveTemplate()
      Saves the current template and standard deviation to a .csv file.
    • saveTemplatePlusSpectrums

      public void saveTemplatePlusSpectrums()
      Saves a template plus a list of all the spectrums used in creating that template- note the template is from normalised spectrums but the list of spectrums is not normalised- this gives the maximum amount of data to the user.
    • addToSpectrum

      public void addToSpectrum()
      Save the average event data to a ClickTemplate class and add to list of click templates. Make visible as a default.
    • fftMean

      public double[] fftMean(ArrayList<double[]> fftAll)
      Calculates the average fft for an ArrayList of fft's. Ignores any NaN values.
      Parameters:
      fftAll -
      Returns:
      average fft.
    • fftstd

      public double[] fftstd(ArrayList<double[]> fftAll, double[] meanVals)
      Create standard deviation of all fft's.
      Parameters:
      fftAll - - all the fft's
      meanVals - - ArrayList of the means if the fft's ;
      Returns:
    • deleteTemplate

      public void deleteTemplate(int row)
      Deletes template from memory; -both the template and corresponding setVisble boolean must be deleted.
    • saveFileBrowser

      public String saveFileBrowser()
      Opens file save dialog and allows user to select save location.
      Returns:
      Path to save file to
    • convertToDoubleArray

      public static double[] convertToDoubleArray(ArrayList<Double> array)
      Converts and ArrayList to a double[]
      Parameters:
      array -
      Returns:
      double[] array with same values as inputed ArrayList
    • convertToArrayList

      public static ArrayList<Double> convertToArrayList(double[] array)
    • createTemplate

      public ClickTemplate createTemplate()
      Creates a click template from the saved instance variables. Be careful that these variables have been updated when using this function.
      Returns:
      ClickTemplate
    • setParams

      public boolean setParams()
    • updateClickSpectrum

      public void updateClickSpectrum()
      Updates the clickSpectrum whenever a template is added or removed. This function basically changes the clickSpectrum before the dialog box is closed.
    • getParams

      public boolean getParams()
      Description copied from class: PamDialog
      called when the Ok button is pressed. This must return true in order that the dialog may close. It should also copy all parameters into an object that will be returned by showDialog.
      Specified by:
      getParams in class PamDialog
    • cancelButtonPressed

      public void cancelButtonPressed()
      Description copied from class: PamDialog
      called when the cancel button is pressed before the dialog closes. Generally you should set the parameters returned by the dialog to null or some default value, or in some other way indicate that Cancel was pressed.
      Specified by:
      cancelButtonPressed in class PamDialog
    • restoreDefaultSettings

      public void restoreDefaultSettings()
      Description copied from class: PamDialog
      standard function which should us used to copy default parameters into the dialog controls.
      Specified by:
      restoreDefaultSettings in class PamDialog