whistlesAndMoans
Class ConnectedRegion

java.lang.Object
  extended by whistlesAndMoans.ConnectedRegion

public class ConnectedRegion
extends java.lang.Object


Field Summary
private  int channel
           
private  SliceData currentSlice
           
private  int firstSlice
           
private  int[] freqRange
           
private  boolean growing
           
private  int maxPeaks
           
private  int nJoinedEnd
          After splitting of complex regions, these are Number of fragments connected to this at the start and at the end.
private  int nJoinedStart
          After splitting of complex regions, these are Number of fragments connected to this at the start and at the end.
private  int[] peakFreqsBins
           
private  int regionNumber
           
private  java.util.List<SliceData> sliceData
           
private  int sliceHeight
           
private  int[] timesBins
          list of time bins - there may be gaps in the whistle !
private  int totalPixels
           
 
Constructor Summary
ConnectedRegion(ConnectedRegion oldRegion, SliceData oldSlice, int peakNumber, int nJoinedStart)
          Constructor to create a new connected region during fragmentation.
ConnectedRegion(int channel, int firstSlice, int regionNumber, int height)
          Constructor used during initial region detection process.
 
Method Summary
 void addOfflineSlice(SliceData newSlice)
          Add in a slice during offline mode.
 void addPixel(int iCol, int iRow, FFTDataUnit fftDataUnit)
           
private  SliceData addSlice(int iSlice, int sliceLen, FFTDataUnit fftDataUnit)
           
private  void addSlicePeak(SliceData oldSlice, int peakNumber)
          Extend a region during fragmentation
protected  void breakShortBridges()
          Break short bridges in time.
 double calculateRMSAmplitude()
           
 boolean checkRepeatslices()
          Check for slices repeating twice.
 void cleanFragmentedFragment()
          similar to condenseInfo, but for refragmetned fragments.
 void condenseInfo()
          Go through the data and remove create triplets of into about each part of each slice in the region.
 void extendRegion(SliceData oldSlice, int peakNumber)
          Extend a region during fragmentation taking a single peak from a new slice.
private  void fillHoles(SliceData slice, int maxHeight, int nHoles)
          Fill in small holes in the slice.
protected  void fillSmallHoles()
           
protected  void fillSmallHoles(int maxHeight, int maxWidth)
          Fill small holes in the regions which will mess up later fragmentation
private  SliceData findSlice(int iSlice)
           
 int getChannel()
           
 long getDuration()
           
 double getEndGradient(int nBins)
          Gradient at the end of the shape for the first peak in pixels per pixel.
 int getFirstSlice()
           
 SliceData getFirstSliceData()
           
 int[] getFreqRange()
           
 SliceData getLastSliceData()
           
 int getMaxPeaks()
           
 int getNJoinedEnd()
           
 int getNJoinedStart()
           
 int getNumSlices()
           
 int[] getPeakFreqsBins()
           
 int getRegionNumber()
           
 java.util.List<SliceData> getSliceData()
           
 int getSliceHeight()
           
 double getStartGradient(int nBins)
          Gradient at the start of the shape for the first peak in pixels per pixel.
 long getStartMillis()
           
 long getStartSample()
           
 int[] getTimesBins()
           
 int getTotalPixels()
           
 boolean isCross(int maxCrossLength)
           
 boolean isGrowing()
           
 boolean isMerge(int maxCrossLength)
           
 boolean isRightMess()
           
 boolean isSplit(int maxCrossLength)
           
 void mergeFragmentedRegion(ConnectedRegion r2)
          for merging two regions during the fragmentation process.
 void mergeRegion(ConnectedRegion region)
          Merge another region into this region and then tell the array of regions that all references to that other region now refer to this one.
 void recycle()
           
 void resetRegion(int channel, int firstSlice, int regionNumber, int height)
          Prepare a region for re-use (saves some time reallocating the object if they were only used very briefly).
 void sayRegion()
           
 void setGrowing(boolean growing)
           
 void setNJoinedEnd(int nJoinedEnd)
           
 void setNJoinedStart(int nJoinedStart)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

channel

private int channel

regionNumber

private int regionNumber

firstSlice

private int firstSlice

currentSlice

private SliceData currentSlice

sliceHeight

private int sliceHeight

sliceData

private java.util.List<SliceData> sliceData

totalPixels

private int totalPixels

growing

private boolean growing

freqRange

private int[] freqRange

peakFreqsBins

private int[] peakFreqsBins

timesBins

private int[] timesBins
list of time bins - there may be gaps in the whistle !


maxPeaks

private int maxPeaks

nJoinedStart

private int nJoinedStart
After splitting of complex regions, these are Number of fragments connected to this at the start and at the end. These are set in FragmentingFragmenter and used in RejoiningFragmenter.


nJoinedEnd

private int nJoinedEnd
After splitting of complex regions, these are Number of fragments connected to this at the start and at the end. These are set in FragmentingFragmenter and used in RejoiningFragmenter.

Constructor Detail

ConnectedRegion

public ConnectedRegion(int channel,
                       int firstSlice,
                       int regionNumber,
                       int height)
Constructor used during initial region detection process.

Parameters:
channel - channel number
firstSlice - first slice number
regionNumber - region number
height - fft length

ConnectedRegion

public ConnectedRegion(ConnectedRegion oldRegion,
                       SliceData oldSlice,
                       int peakNumber,
                       int nJoinedStart)
Constructor to create a new connected region during fragmentation. Constructor starts by making a single peak in a single slice.

Parameters:
oldRegion - old mother region which is being fragmented
sliceData - start slice in the old region
peakNumber - peak number in the slice
nJoinedStart - number of contours that joined this one before the were fragmented.
Method Detail

extendRegion

public void extendRegion(SliceData oldSlice,
                         int peakNumber)
Extend a region during fragmentation taking a single peak from a new slice.

Parameters:
oldSlice - reference to slice in old unit
peakNumber - number of peak to copy

addOfflineSlice

public void addOfflineSlice(SliceData newSlice)
Add in a slice during offline mode.

Parameters:
i - slice number (or slice index as it's read back !
peakInfo -

checkRepeatslices

public boolean checkRepeatslices()
Check for slices repeating twice.

Returns:

addSlicePeak

private void addSlicePeak(SliceData oldSlice,
                          int peakNumber)
Extend a region during fragmentation

Parameters:
oldSlice - old slice
peakNumber - peak to steal.

resetRegion

public void resetRegion(int channel,
                        int firstSlice,
                        int regionNumber,
                        int height)
Prepare a region for re-use (saves some time reallocating the object if they were only used very briefly).

Parameters:
channel -
firstSlice -
regionNumber -
height -

addPixel

public void addPixel(int iCol,
                     int iRow,
                     FFTDataUnit fftDataUnit)

addSlice

private SliceData addSlice(int iSlice,
                           int sliceLen,
                           FFTDataUnit fftDataUnit)

findSlice

private SliceData findSlice(int iSlice)

fillSmallHoles

protected void fillSmallHoles(int maxHeight,
                              int maxWidth)
Fill small holes in the regions which will mess up later fragmentation

Parameters:
maxHeight - max height of hole in pixels
maxWidth - max width of hole in pixels

fillHoles

private void fillHoles(SliceData slice,
                       int maxHeight,
                       int nHoles)
Fill in small holes in the slice.

Parameters:
slice - slice to fill
maxHeight - max hole height.

mergeRegion

public void mergeRegion(ConnectedRegion region)
Merge another region into this region and then tell the array of regions that all references to that other region now refer to this one.

Parameters:
region - other region
regionArray - array of region references to update.

mergeFragmentedRegion

public void mergeFragmentedRegion(ConnectedRegion r2)
for merging two regions during the fragmentation process. Can be assumed that all slices in r2 come AFTER those in this.

Parameters:
r2 -

recycle

public void recycle()

condenseInfo

public void condenseInfo()
Go through the data and remove create triplets of into about each part of each slice in the region. Called durign initial detection, not after refragmentation of complex shapes.


cleanFragmentedFragment

public void cleanFragmentedFragment()
similar to condenseInfo, but for refragmetned fragments.


breakShortBridges

protected void breakShortBridges()
Break short bridges in time.


fillSmallHoles

protected void fillSmallHoles()

isGrowing

public boolean isGrowing()

setGrowing

public void setGrowing(boolean growing)

getChannel

public int getChannel()

getRegionNumber

public int getRegionNumber()

getFirstSlice

public int getFirstSlice()

getSliceHeight

public int getSliceHeight()

getSliceData

public java.util.List<SliceData> getSliceData()

getNumSlices

public int getNumSlices()

getTotalPixels

public int getTotalPixels()

getStartMillis

public long getStartMillis()

getDuration

public long getDuration()

getStartSample

public long getStartSample()

sayRegion

public void sayRegion()

calculateRMSAmplitude

public double calculateRMSAmplitude()

getFreqRange

public int[] getFreqRange()

getMaxPeaks

public int getMaxPeaks()

getPeakFreqsBins

public int[] getPeakFreqsBins()

getTimesBins

public int[] getTimesBins()

getFirstSliceData

public SliceData getFirstSliceData()

getLastSliceData

public SliceData getLastSliceData()

setNJoinedStart

public void setNJoinedStart(int nJoinedStart)
Parameters:
nJoinedStart - the nJoinedStart to set

getNJoinedStart

public int getNJoinedStart()
Returns:
the nJoinedStart

setNJoinedEnd

public void setNJoinedEnd(int nJoinedEnd)
Parameters:
nJoinedEnd - the nJoinedEnd to set

getNJoinedEnd

public int getNJoinedEnd()
Returns:
the nJoinedEnd

getStartGradient

public double getStartGradient(int nBins)
Gradient at the start of the shape for the first peak in pixels per pixel.
Used for rapid region matching in RejoiningFragmenter

Parameters:
nBins - number of bins to measure over.
Returns:
gradient.

getEndGradient

public double getEndGradient(int nBins)
Gradient at the end of the shape for the first peak in pixels per pixel.
Used for rapid region matching in RejoiningFragmenter

Parameters:
nBins - number of bins to measure over.
Returns:
gradient.

isCross

public boolean isCross(int maxCrossLength)
Returns:
true if two or more whistles cross in this region

isMerge

public boolean isMerge(int maxCrossLength)
Returns:
true if two or more whistles merged into this Region

isSplit

public boolean isSplit(int maxCrossLength)
Returns:
true if this region splits into two or more parts

isRightMess

public boolean isRightMess()
Returns:
true if > 2 sounds joined this region at the start and > 2 left at the end, but they were not the same number of sounds.