mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2025-02-19 18:53:08 +00:00
Updates to click train detector
New GUI for click train classification - more intuitive and allows users to build more powerful classifiers. CPOD data can now build average waveforms. CPOD click trains can be viewed in TDisplayFX pop up menu displays Fixed Peak Frequency symbol chooser so it saves the colour box settings
This commit is contained in:
parent
07752f3dd3
commit
127074c6ab
1
.gitignore
vendored
1
.gitignore
vendored
@ -35,3 +35,4 @@ bin/
|
||||
target/WMM.COF
|
||||
|
||||
settings.xml
|
||||
.classpath
|
||||
|
@ -1,8 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
||||
org.eclipse.jdt.core.compiler.compliance=11
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=16
|
||||
org.eclipse.jdt.core.compiler.compliance=16
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=11
|
||||
org.eclipse.jdt.core.compiler.source=16
|
||||
|
@ -152,6 +152,41 @@ public class AverageWaveform {
|
||||
count++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to an average spectra when no raw data is present e.g. CPOD. Here the average spectra is an amplitude weighted historgram
|
||||
* of the bandwidth of the detection.
|
||||
* @param minFreq - the minimum frequency in Hz
|
||||
* @param maxFreq - the maximum frequency in Hz
|
||||
* @param amplitude - the amplitude of the detection in dB
|
||||
* @param sampleRate2 - the sample rate in samples per second.
|
||||
* @param defaultFFTLen - the defaultFFT length.
|
||||
*/
|
||||
public void addWaveform(double minFreq, double maxFreq, double amplitude, float sampleRate2, int defaultFFTLen) {
|
||||
this.fftLength = defaultFFTLen;
|
||||
|
||||
//System.out.println("Add to averagewaveform: minFreq " + minFreq + " maxFreq: " + maxFreq + " amplitude: " + amplitude + " sR: " + sampleRate2);
|
||||
|
||||
if (avrgSpectra==null) {
|
||||
//the FFT length is the length of the first waveform
|
||||
avrgSpectra = new double[this.fftLength];
|
||||
return;
|
||||
}
|
||||
|
||||
double amplitudebin = amplitude/(maxFreq-minFreq);
|
||||
|
||||
double minFreqBin;
|
||||
double maxFreqBin;
|
||||
for (int i= 0; i <avrgSpectra.length; i++) {
|
||||
minFreqBin = (i/(double) avrgSpectra.length)*(sampleRate2/2);
|
||||
maxFreqBin = (i/(double) avrgSpectra.length)*(sampleRate2/2);
|
||||
|
||||
if (minFreqBin > minFreq && maxFreqBin<=maxFreq) {
|
||||
avrgSpectra[i]+=amplitudebin;
|
||||
}
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the average waveform. Not normalised.
|
||||
* @return the average waveform
|
||||
@ -230,7 +265,7 @@ public class AverageWaveform {
|
||||
|
||||
/**
|
||||
* Get the sample rate for the average spectra.
|
||||
* @return the smaple rate.
|
||||
* @return the sample rate in samples per second.
|
||||
*/
|
||||
public float getSampleRate() {
|
||||
return sampleRate;
|
||||
@ -239,11 +274,14 @@ public class AverageWaveform {
|
||||
|
||||
/**
|
||||
* Set the sample rate for the average spectra.
|
||||
* @param the smaple rate.
|
||||
* @param the sample rate in samples per second.
|
||||
*/
|
||||
public void setSampleRate(float sampleRate) {
|
||||
this.sampleRate = sampleRate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -45,6 +45,8 @@ public class PeakFreqModifier extends SymbolModifier {
|
||||
*/
|
||||
private ColourArrayType colourArrayType;
|
||||
|
||||
private PeakFreqOptionsPane peakFreqOptions;
|
||||
|
||||
public PeakFreqModifier(PamSymbolChooser symbolChooser) {
|
||||
super(PEAK_FREQ_MODIFIER_NAME, symbolChooser, SymbolModType.FILLCOLOUR | SymbolModType.LINECOLOUR );
|
||||
checkColourArray();
|
||||
@ -124,11 +126,17 @@ public class PeakFreqModifier extends SymbolModifier {
|
||||
|
||||
@Override
|
||||
public SymbolModifierPane getOptionsPane() {
|
||||
return new PeakFreqOptionsPane(this);
|
||||
//System.out.println("PEAK FREQ COLOUR ARRAY2: " + peakFreqSymbolOptions.freqColourArray);
|
||||
if (this.peakFreqOptions==null) {
|
||||
peakFreqOptions = new PeakFreqOptionsPane(this);
|
||||
peakFreqOptions.setParams();
|
||||
}
|
||||
return peakFreqOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SymbolModifierParams getSymbolModifierParams() {
|
||||
//System.out.println("PEAK FREQ COLOUR ARRAY3: " + peakFreqSymbolOptions.freqColourArray);
|
||||
if (peakFreqSymbolOptions==null) peakFreqSymbolOptions = new PeakFreqSymbolOptions();
|
||||
return peakFreqSymbolOptions;
|
||||
}
|
||||
@ -138,9 +146,15 @@ public class PeakFreqModifier extends SymbolModifier {
|
||||
if (!(symbolModifierParams instanceof PeakFreqSymbolOptions)) {
|
||||
System.err.println("PeakFreqModifier: warning: the saved parameters were not an instance of PeakFreqSymbolOptions");
|
||||
peakFreqSymbolOptions = new PeakFreqSymbolOptions();
|
||||
checkColourArray();
|
||||
return;
|
||||
}
|
||||
else this.peakFreqSymbolOptions = (PeakFreqSymbolOptions) symbolModifierParams;
|
||||
else {
|
||||
this.peakFreqSymbolOptions = (PeakFreqSymbolOptions) symbolModifierParams;
|
||||
//System.out.println("PEAK FREQ COLOUR ARRAY: " + peakFreqSymbolOptions.freqColourArray);
|
||||
checkColourArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -149,6 +149,12 @@ public class CTDataUnit extends CTDetectionGroupDataUnit implements RawDataHolde
|
||||
// Debug.println("CTDataUnit: Add data to raw data holder: " +
|
||||
// averageWaveform.getAverageWaveform());
|
||||
}
|
||||
else {
|
||||
//here we simply create a histogram of frequencies and add the freq limits to the histogram.
|
||||
averageWaveform.addWaveform(dataUnit.getBasicData().getFrequency()[0],dataUnit.getBasicData().getFrequency()[1],
|
||||
dataUnit.getAmplitudeDB(),
|
||||
dataUnit.getParentDataBlock().getSampleRate(), defaultFFTLen);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,6 +86,11 @@ public class ClickTrainDataBlock<T extends CTDetectionGroupDataUnit> extends Sup
|
||||
this.sortData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSampleRate() {
|
||||
return super.getSampleRate();
|
||||
}
|
||||
|
||||
|
||||
// /* (non-Javadoc)
|
||||
// * @see PamguardMVC.PamDataBlock#removeOldUnitsT(long)
|
||||
|
@ -94,6 +94,8 @@ public class ClickTrainProcess extends PamInstantProcess {
|
||||
getClickTrainParams().dataSourceName);
|
||||
|
||||
}
|
||||
|
||||
//System.out.println("CPOD sample rate: " + sourceDataBlock.getSampleRate());
|
||||
// if (sourceDataBlock!=null) System.out.println("Click train process: Source data" + sourceDataBlock.getDataName());
|
||||
// else System.out.println("The source data is null: " + getClickTrainParams().dataSourceName);
|
||||
|
||||
@ -101,6 +103,9 @@ public class ClickTrainProcess extends PamInstantProcess {
|
||||
setParentDataBlock(sourceDataBlock);
|
||||
|
||||
prepareProcess();
|
||||
|
||||
//System.out.println("CLICK TRAIN sample rate: " + this.getSampleRate());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,6 +56,13 @@ public interface CTClassifier {
|
||||
* Set the classifier parameters.
|
||||
* @param ctClassifierParams - the ct classifier paratmers
|
||||
*/
|
||||
public void setParams(CTClassifierParams ctClassifierParams);
|
||||
public void setParams(CTClassifierParams ctClassifierParams);
|
||||
|
||||
|
||||
/**
|
||||
* Get the CT classifier params.
|
||||
* @return the CT classifier params.
|
||||
*/
|
||||
public CTClassifierParams getParams();
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ import clickTrainDetector.classification.bearingClassifier.BearingClassification
|
||||
import clickTrainDetector.classification.bearingClassifier.BearingClassifier;
|
||||
import clickTrainDetector.classification.simplechi2classifier.Chi2CTClassification;
|
||||
import clickTrainDetector.classification.simplechi2classifier.Chi2ThresholdClassifier;
|
||||
import clickTrainDetector.classification.standardClassifier.StandardClassification;
|
||||
import clickTrainDetector.classification.standardClassifier.StandardClassifier;
|
||||
import clickTrainDetector.classification.templateClassifier.TemplateClassification;
|
||||
import clickTrainDetector.classification.templateClassifier.CTTemplateClassifier;
|
||||
|
||||
@ -43,18 +45,22 @@ public class CTClassifierManager {
|
||||
this.preClassifier = new Chi2ThresholdClassifier(clickTrainControl, -1);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getClassifierName(CTClassifierType classifierType) {
|
||||
switch (classifierType) {
|
||||
case CHI2THRESHOLD:
|
||||
return "X\u00b2 threshold classifier";
|
||||
case TEMPLATECLASSIFIER:
|
||||
return "Spectral Template";
|
||||
case BEARINGCLASSIFIER:
|
||||
return "Bearing Classifier";
|
||||
/////****ADD NEW CLASSIFIERS HERE****/////
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
return classifierType.toString();
|
||||
// switch (classifierType) {
|
||||
// case CHI2THRESHOLD:
|
||||
// return "X\u00b2 threshold classifier";
|
||||
// case TEMPLATECLASSIFIER:
|
||||
// return "Spectral Template";
|
||||
// case BEARINGCLASSIFIER:
|
||||
// return "Bearing Classifier";
|
||||
// case STANDARDCLASSIFIER:
|
||||
// return "Click Train Classifier";
|
||||
// /////****ADD NEW CLASSIFIERS HERE****/////
|
||||
// default:
|
||||
// return "";
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,6 +78,7 @@ public class CTClassifierManager {
|
||||
* @return the CT classifier
|
||||
*/
|
||||
public CTClassifier createClassifier(CTClassifierType classifierType) {
|
||||
if (classifierType==null) return null;
|
||||
switch (classifierType) {
|
||||
case CHI2THRESHOLD:
|
||||
return new Chi2ThresholdClassifier(clickTrainControl, 1);
|
||||
@ -79,6 +86,8 @@ public class CTClassifierManager {
|
||||
return new CTTemplateClassifier(clickTrainControl, 1);
|
||||
case BEARINGCLASSIFIER:
|
||||
return new BearingClassifier(clickTrainControl, -1);
|
||||
case STANDARDCLASSIFIER:
|
||||
return new StandardClassifier(clickTrainControl, -1);
|
||||
/////****ADD NEW CLASSIFIERS HERE****/////
|
||||
default:
|
||||
return new Chi2ThresholdClassifier(clickTrainControl, 1);
|
||||
@ -113,6 +122,8 @@ public class CTClassifierManager {
|
||||
return new TemplateClassification(jsonstring);
|
||||
case BEARINGCLASSIFIER:
|
||||
return new BearingClassification(jsonstring);
|
||||
case STANDARDCLASSIFIER:
|
||||
return new StandardClassification(jsonstring);
|
||||
/////****ADD NEW CLASSIFICATIONTYPES HERE****/////
|
||||
default:
|
||||
return null;
|
||||
@ -216,6 +227,10 @@ public class CTClassifierManager {
|
||||
CTClassifier aClassifier;
|
||||
for (int i=0; i<ctParams.length; i++) {
|
||||
aClassifier = createClassifier(ctParams[i].type);
|
||||
if (aClassifier==null) {
|
||||
System.err.println("CTCLassifier manager: the classifier is null");
|
||||
continue;
|
||||
}
|
||||
aClassifier.setParams(ctParams[i]);
|
||||
cTClassifiers.add(aClassifier);
|
||||
}
|
||||
|
@ -9,9 +9,51 @@ import java.io.Serializable;
|
||||
*/
|
||||
public enum CTClassifierType implements Serializable {
|
||||
|
||||
CHI2THRESHOLD, //very simple chi^2 threshold classifier.
|
||||
TEMPLATECLASSIFIER,//template based classifier
|
||||
BEARINGCLASSIFIER, // bearing based classification
|
||||
MATCHEDCLICK //external matched click classifier which uses average waveforms of click trains.
|
||||
CHI2THRESHOLD("X\\u00b2 threshold classifier", false), //very simple chi^2 threshold classifier.
|
||||
TEMPLATECLASSIFIER("Template correlation", false),//template based classifier
|
||||
BEARINGCLASSIFIER("Bearing classifier",false), // bearing based classification
|
||||
IDICLASSIFIER("IDI classifier", false), //IDI.
|
||||
STANDARDCLASSIFIER("Standard Classifier", true), //COMBINES THE IDI, BEARINGS, TEMPLATE AND CHI2THRESHOLD into one classifier
|
||||
MATCHEDCLICK("Matched click classifier", false); //external matched click classifier which uses average waveforms of click trains.
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* True to enable the classifier.
|
||||
*/
|
||||
private boolean enable;
|
||||
|
||||
/**
|
||||
* The name to use for the classifier.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The name of the classifier type.
|
||||
* @return the name.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the classifier should be used or not.
|
||||
* @return true of the classifier is enabled.
|
||||
*/
|
||||
public boolean isEnable() {
|
||||
return enable;
|
||||
}
|
||||
|
||||
|
||||
CTClassifierType(String name, boolean enable){
|
||||
this.name = name;
|
||||
this.enable = enable;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return name;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import PamguardMVC.debug.Debug;
|
||||
import clickTrainDetector.classification.simplechi2classifier.Chi2CTClassification;
|
||||
|
||||
public class SimpleClassifierJSONLogging extends ClassifierJSONLogging {
|
||||
|
||||
@ -27,7 +26,7 @@ public class SimpleClassifierJSONLogging extends ClassifierJSONLogging {
|
||||
JsonFactory jf = new JsonFactory();
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
try {
|
||||
JsonGenerator jg = jf.createJsonGenerator(os, JsonEncoding.UTF8);
|
||||
JsonGenerator jg = jf.createGenerator(os, JsonEncoding.UTF8);
|
||||
jg.writeStartObject();
|
||||
jg.writeStringField(TYPEFIELD, ctClassification.getClassifierType().toString());
|
||||
jg.writeNumberField(SPECIESFIELD, ctClassification.getSpeciesID());
|
||||
|
@ -0,0 +1,118 @@
|
||||
package clickTrainDetector.classification.idiClassifier;
|
||||
|
||||
import clickTrainDetector.ClickTrainControl;
|
||||
import clickTrainDetector.classification.CTClassification;
|
||||
import clickTrainDetector.classification.CTClassifierType;
|
||||
import clickTrainDetector.classification.ClassifierJSONLogging;
|
||||
|
||||
/**
|
||||
* Classification result from the bearing classifier.
|
||||
*
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class IDIClassification implements CTClassification {
|
||||
|
||||
/**
|
||||
* Mean bearing derivative.
|
||||
*/
|
||||
private double medianIDI;
|
||||
|
||||
/**
|
||||
* Median bearing derivative.
|
||||
*/
|
||||
private double meanIDI;
|
||||
|
||||
/**
|
||||
* Standard bearing derivative.
|
||||
*/
|
||||
private double stdIDI;
|
||||
|
||||
/**
|
||||
* The current species ID.
|
||||
*/
|
||||
private int speciesID;
|
||||
|
||||
/**
|
||||
* Bearing classifier JSON logging.
|
||||
*/
|
||||
private IDIClassifierJSON idiClassifierJSONLogging;
|
||||
|
||||
/**
|
||||
* Constructor for the bearing classifier.
|
||||
* @param speciesID - the speciesID flag.
|
||||
* @param medianIDI - the median IDI in seconds.
|
||||
* @param meanIDI - the mean IDI in seconds.
|
||||
* @param stdIDI - the standard deviation in IDI.
|
||||
|
||||
*/
|
||||
public IDIClassification(int speciesID, double medianIDI, double meanIDI, double stdIDI) {
|
||||
this.medianIDI = medianIDI;
|
||||
this.meanIDI = meanIDI;
|
||||
this.stdIDI = stdIDI;
|
||||
this.speciesID = speciesID;
|
||||
idiClassifierJSONLogging = new IDIClassifierJSON();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bearing classification from a JSON string.
|
||||
* @param jsonstring - JSON string containing the bearing data.
|
||||
*/
|
||||
public IDIClassification(String jsonstring) {
|
||||
idiClassifierJSONLogging = new IDIClassifierJSON();
|
||||
CTClassification classification = idiClassifierJSONLogging.createClassification(jsonstring);
|
||||
this.speciesID =classification.getSpeciesID();
|
||||
this.medianIDI =((IDIClassification) classification).getMeanIDI();
|
||||
this.meanIDI =((IDIClassification) classification).getMedianIDI();
|
||||
this.stdIDI =((IDIClassification) classification).getStdIDI();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public CTClassifierType getClassifierType() {
|
||||
return CTClassifierType.IDICLASSIFIER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpeciesID() {
|
||||
return speciesID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummaryString() {
|
||||
return String.format("IDI Classifier: Mean IDI %.4f\u00B0/s Median IDI %.4f\u00B0/s Std IDI%.4f\u00B0/s",
|
||||
meanIDI, medianIDI, stdIDI);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassifierJSONLogging getJSONLogging() {
|
||||
return idiClassifierJSONLogging;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the median of bearing delta values in radians per second.
|
||||
* @return the median bearing delta in rad/s.
|
||||
*/
|
||||
public double getMedianIDI() {
|
||||
return this.medianIDI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mean of bearing delta values in radians per second.
|
||||
* @return the mean bearing delta in rad/s
|
||||
*
|
||||
*/
|
||||
public double getMeanIDI() {
|
||||
return this.meanIDI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the standard deviation in bearing delta values in radians per second.
|
||||
* @return the standard deviation in bearing delta in rad/s
|
||||
*/
|
||||
public double getStdIDI() {
|
||||
return this.stdIDI;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package clickTrainDetector.classification.idiClassifier;
|
||||
|
||||
import clickTrainDetector.CTDataUnit;
|
||||
import clickTrainDetector.ClickTrainControl;
|
||||
import clickTrainDetector.IDIInfo;
|
||||
import clickTrainDetector.classification.CTClassification;
|
||||
import clickTrainDetector.classification.CTClassifier;
|
||||
import clickTrainDetector.classification.CTClassifierParams;
|
||||
import clickTrainDetector.layout.classification.CTClassifierGraphics;
|
||||
import clickTrainDetector.layout.classification.idiClassifier.IDIClassifierGraphics;
|
||||
|
||||
/**
|
||||
* An inter-detection interval based classifier for click trains.
|
||||
*
|
||||
* @author Jamie Macaulay
|
||||
*/
|
||||
public class IDIClassifier implements CTClassifier {
|
||||
|
||||
/**
|
||||
* The IDI parameters.
|
||||
*/
|
||||
private IDIClassifierParams idiParams;
|
||||
|
||||
/**
|
||||
* The bearing classifier graphics
|
||||
*/
|
||||
private IDIClassifierGraphics idiClassifierGraphics;
|
||||
|
||||
public IDIClassifier(ClickTrainControl clickTrainControl, int defaultSpeciesID) {
|
||||
idiParams = new IDIClassifierParams();
|
||||
idiParams.speciesFlag=defaultSpeciesID;
|
||||
this.idiClassifierGraphics = new IDIClassifierGraphics(clickTrainControl, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CTClassification classifyClickTrain(CTDataUnit clickTrain) {
|
||||
//check IDI classification is passed
|
||||
boolean passesIDI = checkIDIMeasurements(clickTrain);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "IDI classifier";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpeciesID() {
|
||||
return idiParams.speciesFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CTClassifierGraphics getCTClassifierGraphics() {
|
||||
return idiClassifierGraphics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParams(CTClassifierParams ctClassifierParams) {
|
||||
this.idiParams=(IDIClassifierParams) ctClassifierParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check IDI measurements for a click train
|
||||
* @return true if all measurements are passed.
|
||||
*/
|
||||
private boolean checkIDIMeasurements(CTDataUnit clickTrain) {
|
||||
IDIInfo idiInfo = clickTrain.getIDIInfo();
|
||||
|
||||
if (idiParams.useMedianIDI &&
|
||||
(idiInfo.medianIDI<idiParams.minMedianIDI || idiInfo.medianIDI>idiParams.maxMedianIDI)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (idiParams.useMeanIDI &&
|
||||
(idiInfo.meanIDI<idiParams.minMeanIDI || idiInfo.meanIDI>idiParams.maxMeanIDI)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (idiParams.useStdIDI &&
|
||||
(idiInfo.stdIDI<idiParams.minStdIDI || idiInfo.stdIDI>idiParams.maxStdIDI)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public IDIClassifierParams getParams() {
|
||||
return idiParams;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package clickTrainDetector.classification.idiClassifier;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerationException;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import clickTrainDetector.classification.CTClassification;
|
||||
import clickTrainDetector.classification.SimpleClassifierJSONLogging;
|
||||
|
||||
public class IDIClassifierJSON extends SimpleClassifierJSONLogging {
|
||||
|
||||
public static final String MEDIAN_IDI_STRING = "MED_IDI_DELTA";
|
||||
public static final String MEAN_IDI_STRING = "MEAN_IDI_DELTA";
|
||||
public static final String STD_IDI_STRING = "STD_IDI_DELTA";
|
||||
|
||||
/**
|
||||
* Write JSON data after default TYPE and SPECIESID values have been added.
|
||||
* @param the JSON data generator.
|
||||
* @throws IOException
|
||||
* @throws JsonGenerationException
|
||||
*/
|
||||
public void writeJSONData(JsonGenerator jg, CTClassification ctClassification) {
|
||||
try {
|
||||
jg.writeNumberField(MEDIAN_IDI_STRING, ((IDIClassification) ctClassification).getMedianIDI());
|
||||
jg.writeNumberField(MEAN_IDI_STRING, ((IDIClassification) ctClassification).getMeanIDI());
|
||||
jg.writeNumberField(STD_IDI_STRING, ((IDIClassification) ctClassification).getStdIDI());
|
||||
|
||||
} catch (JsonGenerationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get classifier data after default TYPE and SPECIESID values has been
|
||||
* @param the JSON node which contains data.
|
||||
*/
|
||||
public CTClassification createClassification(JsonNode jTree) {
|
||||
JsonNode na = jTree.findValue("SPECIES");
|
||||
int speciesID;
|
||||
double medianIDIDelta;
|
||||
double meanIDIDelta;
|
||||
double stdIDIDelta;
|
||||
if (na != null ) {
|
||||
speciesID = na.asInt();
|
||||
}
|
||||
else {
|
||||
System.err.println("Cannot load IDI classifier");
|
||||
return null;
|
||||
}
|
||||
|
||||
na = jTree.findValue(MEDIAN_IDI_STRING);
|
||||
if (na != null ) {
|
||||
medianIDIDelta = na.asDouble();
|
||||
}
|
||||
else {
|
||||
System.err.println("Cannot load IDI classifier: no median IDI");
|
||||
return null;
|
||||
}
|
||||
|
||||
na = jTree.findValue(MEAN_IDI_STRING);
|
||||
if (na != null ) {
|
||||
meanIDIDelta = na.asDouble();
|
||||
}
|
||||
else {
|
||||
System.err.println("Cannot load IDI classifier: no mean IDI");
|
||||
return null;
|
||||
}
|
||||
|
||||
na = jTree.findValue(STD_IDI_STRING);
|
||||
if (na != null ) {
|
||||
stdIDIDelta = na.asDouble();
|
||||
}
|
||||
else {
|
||||
System.err.println("Cannot load IDI classifier: no std IDI");
|
||||
return null;
|
||||
}
|
||||
|
||||
IDIClassification idiClassification =
|
||||
new IDIClassification(speciesID, meanIDIDelta, medianIDIDelta, stdIDIDelta);
|
||||
|
||||
return idiClassification;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
package clickTrainDetector.classification.idiClassifier;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import PamModel.parametermanager.ManagedParameters;
|
||||
import clickTrainDetector.classification.CTClassifierParams;
|
||||
|
||||
public class IDIClassifierParams extends CTClassifierParams implements Serializable, Cloneable, ManagedParameters {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Use the median ICI measurements
|
||||
*/
|
||||
public boolean useMedianIDI = true;
|
||||
|
||||
/**
|
||||
* The minimim median ICI.
|
||||
*/
|
||||
public Double minMedianIDI = 0.; // seconds
|
||||
|
||||
/**
|
||||
* The maximum median ICI
|
||||
*/
|
||||
public Double maxMedianIDI = 2.; // seconds
|
||||
|
||||
/**
|
||||
* Use the mean ICI measurements.
|
||||
*/
|
||||
public boolean useMeanIDI = false;
|
||||
|
||||
|
||||
/**
|
||||
* The minimum median ICI.
|
||||
*/
|
||||
public Double minMeanIDI = 0.; // seconds
|
||||
|
||||
/**
|
||||
* The maximum median ICI
|
||||
*/
|
||||
public Double maxMeanIDI = 2.; // seconds
|
||||
|
||||
|
||||
/**
|
||||
* Use the mean ICI measurements
|
||||
*/
|
||||
public boolean useStdIDI = false;
|
||||
|
||||
/**
|
||||
* The minimum standard deviation in ICI.
|
||||
*/
|
||||
public Double minStdIDI = 0.; // seconds
|
||||
|
||||
/**
|
||||
* The maximum standard deviation in ICI
|
||||
*/
|
||||
public Double maxStdIDI = 100.; // seconds
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package clickTrainDetector.classification.standardClassifier;
|
||||
|
||||
import clickTrainDetector.ClickTrainControl;
|
||||
import clickTrainDetector.classification.CTClassification;
|
||||
import clickTrainDetector.classification.CTClassifierType;
|
||||
import clickTrainDetector.classification.ClassifierJSONLogging;
|
||||
import clickTrainDetector.classification.bearingClassifier.BearingClassifierJSON;
|
||||
|
||||
/**
|
||||
* A classification object for a standard classification
|
||||
*
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class StandardClassification implements CTClassification {
|
||||
|
||||
/**
|
||||
* Reference to the click control.
|
||||
*/
|
||||
private ClickTrainControl clickTrainControl;
|
||||
|
||||
|
||||
/**
|
||||
* The current species ID.
|
||||
*/
|
||||
private int speciesID;
|
||||
|
||||
/**
|
||||
* All the classifications.
|
||||
*/
|
||||
private CTClassification[] ctClassifications;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Standard classifier JSON logging.
|
||||
*/
|
||||
private StandardClassificationJSON standardClassifierJSONLogging;
|
||||
|
||||
|
||||
public StandardClassification(ClickTrainControl clickTrainControl, CTClassification[] ctClassifications, int speciesID) {
|
||||
this.clickTrainControl=clickTrainControl;
|
||||
this.ctClassifications=ctClassifications;
|
||||
standardClassifierJSONLogging = new StandardClassificationJSON();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a classification unit from a JSON string.
|
||||
* @param jsonstring
|
||||
*/
|
||||
public StandardClassification(String jsonstring) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CTClassifierType getClassifierType() {
|
||||
return CTClassifierType.STANDARDCLASSIFIER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpeciesID() {
|
||||
return speciesID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSummaryString() {
|
||||
String summaryString ="";
|
||||
for (CTClassification ctClassification : ctClassifications) {
|
||||
summaryString+= ctClassification.getSummaryString() + "\n";
|
||||
}
|
||||
return summaryString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassifierJSONLogging getJSONLogging() {
|
||||
return standardClassifierJSONLogging;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package clickTrainDetector.classification.standardClassifier;
|
||||
|
||||
import clickTrainDetector.classification.SimpleClassifierJSONLogging;
|
||||
|
||||
public class StandardClassificationJSON extends SimpleClassifierJSONLogging {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
package clickTrainDetector.classification.standardClassifier;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import clickTrainDetector.CTDataUnit;
|
||||
import clickTrainDetector.ClickTrainControl;
|
||||
import clickTrainDetector.classification.CTClassification;
|
||||
import clickTrainDetector.classification.CTClassifier;
|
||||
import clickTrainDetector.classification.CTClassifierParams;
|
||||
import clickTrainDetector.classification.bearingClassifier.BearingClassifier;
|
||||
import clickTrainDetector.classification.bearingClassifier.BearingClassifierParams;
|
||||
import clickTrainDetector.classification.idiClassifier.IDIClassification;
|
||||
import clickTrainDetector.classification.idiClassifier.IDIClassifier;
|
||||
import clickTrainDetector.classification.simplechi2classifier.Chi2CTClassification;
|
||||
import clickTrainDetector.classification.simplechi2classifier.Chi2ThresholdClassifier;
|
||||
import clickTrainDetector.classification.templateClassifier.CTTemplateClassifier;
|
||||
import clickTrainDetector.layout.classification.CTClassifierGraphics;
|
||||
import clickTrainDetector.layout.classification.standardClassifier.StandardClassifierGraphics;
|
||||
|
||||
/**
|
||||
* Combines the IDI, CHI2, BEARING and TEMPLATE classifier into one.
|
||||
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class StandardClassifier implements CTClassifier {
|
||||
|
||||
/**
|
||||
* The bearing classifier parameters.
|
||||
*/
|
||||
private StandardClassifierParams standardClssfrParams = new StandardClassifierParams();
|
||||
|
||||
/**
|
||||
* The graphics for changing settings.
|
||||
*/
|
||||
private StandardClassifierGraphics standardClassifierGraphics;
|
||||
|
||||
/**
|
||||
* List of the classifiers used.
|
||||
*/
|
||||
private ArrayList<CTClassifier> classifiers;
|
||||
|
||||
/**
|
||||
* Click train control.
|
||||
*/
|
||||
private ClickTrainControl clickTrainControl;
|
||||
|
||||
public StandardClassifier(ClickTrainControl clickTrainControl, int speciesID) {
|
||||
this.clickTrainControl = clickTrainControl;
|
||||
standardClassifierGraphics = new StandardClassifierGraphics(clickTrainControl, this);
|
||||
standardClssfrParams.speciesFlag=speciesID;
|
||||
|
||||
//load the settings
|
||||
createClassifiers();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the classifier. Each sub classifier (if enabled) must be passed for a positive classification.
|
||||
*/
|
||||
private void createClassifiers() {
|
||||
classifiers = new ArrayList<CTClassifier>();
|
||||
|
||||
classifiers.add(new Chi2ThresholdClassifier(clickTrainControl, standardClssfrParams.speciesFlag));
|
||||
|
||||
classifiers.add(new IDIClassifier(clickTrainControl, standardClssfrParams.speciesFlag));
|
||||
|
||||
classifiers.add(new CTTemplateClassifier(clickTrainControl, standardClssfrParams.speciesFlag));
|
||||
|
||||
classifiers.add(new BearingClassifier(clickTrainControl, standardClssfrParams.speciesFlag));
|
||||
|
||||
setClassifierParams();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parameters for the individual classifiers
|
||||
*/
|
||||
private void setClassifierParams() {
|
||||
|
||||
if (standardClssfrParams.ctClassifierParams ==null || standardClssfrParams.ctClassifierParams.length != classifiers.size()) {
|
||||
standardClssfrParams.ctClassifierParams = new CTClassifierParams[classifiers.size()];
|
||||
standardClssfrParams.enable = new boolean[classifiers.size()];
|
||||
//enable all classifiers by default.
|
||||
for (int i=0; i<classifiers.size(); i++) {
|
||||
standardClssfrParams.enable[i] = true; //default is false
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<classifiers.size(); i++) {
|
||||
if (standardClssfrParams.ctClassifierParams[i]==null) {
|
||||
//set default settings
|
||||
standardClssfrParams.ctClassifierParams[i]= classifiers.get(i).getParams();
|
||||
}
|
||||
else {
|
||||
//the standard classifier should have settings set.
|
||||
classifiers.get(i).setParams(standardClssfrParams.ctClassifierParams[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CTClassification classifyClickTrain(CTDataUnit clickTrain) {
|
||||
|
||||
|
||||
//all classifiers have to pass.
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Standard Classifier";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpeciesID() {
|
||||
return standardClssfrParams.speciesFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CTClassifierGraphics getCTClassifierGraphics() {
|
||||
return standardClassifierGraphics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParams(CTClassifierParams ctClassifierParams) {
|
||||
this.standardClssfrParams=(StandardClassifierParams) ctClassifierParams;
|
||||
setClassifierParams();
|
||||
}
|
||||
|
||||
public StandardClassifierParams getParams() {
|
||||
return standardClssfrParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the classifiers the standard classifier uses. .
|
||||
* @return the classifiers.
|
||||
*/
|
||||
public ArrayList<CTClassifier> getClassifiers() {
|
||||
return classifiers;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package clickTrainDetector.classification.standardClassifier;
|
||||
|
||||
import clickTrainDetector.classification.CTClassifierParams;
|
||||
|
||||
|
||||
/**
|
||||
* Standard classifier parameters.
|
||||
*/
|
||||
public class StandardClassifierParams extends CTClassifierParams {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* List of the classifier parameters used.
|
||||
*/
|
||||
public CTClassifierParams[] ctClassifierParams;
|
||||
|
||||
/**
|
||||
* List of which classifiers are enabled.
|
||||
*/
|
||||
public boolean[] enable;
|
||||
|
||||
//
|
||||
// /**
|
||||
// * Standard classifier parameters.
|
||||
// */
|
||||
// public Chi2ThresholdParams standClassifierParams = new Chi2ThresholdParams();
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * The parameters for bearing classification.
|
||||
// */
|
||||
// public BearingClassifierParams bearingClassifierParams = new BearingClassifierParams();
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * The IDI parameters.
|
||||
// */
|
||||
// public IDIClassifierParams idClassifierParams = new IDIClassifierParams();
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Template classifier parameters.
|
||||
// */
|
||||
// public TemplateClassifierParams templateClassifierParams = new TemplateClassifierParams();
|
||||
|
||||
|
||||
public CTClassifierParams clone() {
|
||||
StandardClassifierParams clonedParams =(StandardClassifierParams) super.clone();
|
||||
|
||||
//make sure to hard clone the settings.
|
||||
for (int i=0; i<clonedParams.ctClassifierParams.length; i++) {
|
||||
clonedParams.ctClassifierParams[i] = clonedParams.ctClassifierParams[i].clone();
|
||||
}
|
||||
|
||||
return clonedParams;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -47,7 +47,7 @@ public class CTTemplateClassifier implements CTClassifier {
|
||||
/**
|
||||
* THe Chi2 threshold classifier.
|
||||
*/
|
||||
public Chi2ThresholdClassifier chi2ThresholdClassifier;
|
||||
//public Chi2ThresholdClassifier chi2ThresholdClassifier;
|
||||
|
||||
/**
|
||||
* The spectrum template which has been interpolated for current sample rate and
|
||||
@ -57,15 +57,15 @@ public class CTTemplateClassifier implements CTClassifier {
|
||||
|
||||
public CTTemplateClassifier(ClickTrainControl clickTrainControl, int defaultSpeciesID) {
|
||||
this.clickTrainControl = clickTrainControl;
|
||||
chi2ThresholdClassifier=new Chi2ThresholdClassifier(clickTrainControl, defaultSpeciesID);
|
||||
//chi2ThresholdClassifier=new Chi2ThresholdClassifier(clickTrainControl, defaultSpeciesID);
|
||||
templateClassifierParams.speciesFlag=defaultSpeciesID;
|
||||
templateClassifierParams.chi2ThresholdParams.speciesFlag=defaultSpeciesID; //must make this the same
|
||||
//templateClassifierParams.chi2ThresholdParams.speciesFlag=defaultSpeciesID; //must make this the same
|
||||
}
|
||||
|
||||
public CTTemplateClassifier(int defaultSpeciesID) {
|
||||
chi2ThresholdClassifier=new Chi2ThresholdClassifier(defaultSpeciesID);
|
||||
//chi2ThresholdClassifier=new Chi2ThresholdClassifier(defaultSpeciesID);
|
||||
templateClassifierParams.speciesFlag=defaultSpeciesID;
|
||||
templateClassifierParams.chi2ThresholdParams.speciesFlag=defaultSpeciesID; //must make this the same
|
||||
//templateClassifierParams.chi2ThresholdParams.speciesFlag=defaultSpeciesID; //must make this the same
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,9 +74,9 @@ public class CTTemplateClassifier implements CTClassifier {
|
||||
//Debug.out.println("Click train: " + clickTrain + " sub count: " + clickTrain.getSubDetectionsCount() + " UID: " + clickTrain.getUID());
|
||||
|
||||
//little HACK here to ensure species falgs are the same.
|
||||
templateClassifierParams.chi2ThresholdParams.speciesFlag=templateClassifierParams.speciesFlag;
|
||||
//templateClassifierParams.chi2ThresholdParams.speciesFlag=templateClassifierParams.speciesFlag;
|
||||
|
||||
chi2ThresholdClassifier.setParams(templateClassifierParams.chi2ThresholdParams);
|
||||
//chi2ThresholdClassifier.setParams(templateClassifierParams.chi2ThresholdParams);
|
||||
|
||||
if (clickTrain.getAverageSpectra()==null) {
|
||||
System.err.println("TemplateClassifier:There is no average waveform for template classification: " + clickTrain.averageWaveform);
|
||||
@ -89,25 +89,17 @@ public class CTTemplateClassifier implements CTClassifier {
|
||||
//need to work out correlation threshold whatever
|
||||
|
||||
//first check the chi2 value.
|
||||
Chi2CTClassification chi2Classification = chi2ThresholdClassifier.classifyClickTrain(clickTrain);
|
||||
//Chi2CTClassification chi2Classification = chi2ThresholdClassifier.classifyClickTrain(clickTrain);
|
||||
|
||||
|
||||
//check chi^2 classification is passed
|
||||
if (chi2Classification.getSpeciesID()!=templateClassifierParams.speciesFlag) {
|
||||
//no classification
|
||||
// Debug.out.println(templateClassifierParams.classifierName + " Classifier: Failed chi2 classifier: " + chi2Classification.getSpeciesID() +
|
||||
// " " +chi2ThresholdClassifier.getParams().speciesFlag + " " + templateClassifierParams.speciesFlag + " min chi2: " + templateClassifierParams.chi2ThresholdParams.chi2Threshold);
|
||||
return new TemplateClassification(CTClassifier.PRECLASSIFIERFLAG, corrValue);
|
||||
}
|
||||
// //check chi^2 classification is passed
|
||||
// if (chi2Classification.getSpeciesID()!=templateClassifierParams.speciesFlag) {
|
||||
// //no classification
|
||||
//// Debug.out.println(templateClassifierParams.classifierName + " Classifier: Failed chi2 classifier: " + chi2Classification.getSpeciesID() +
|
||||
//// " " +chi2ThresholdClassifier.getParams().speciesFlag + " " + templateClassifierParams.speciesFlag + " min chi2: " + templateClassifierParams.chi2ThresholdParams.chi2Threshold);
|
||||
// return new TemplateClassification(CTClassifier.PRECLASSIFIERFLAG, corrValue);
|
||||
// }
|
||||
|
||||
//check IDI classification is passed
|
||||
boolean passesIDI = checkIDIMeasurements(clickTrain);
|
||||
//check chi^2 classification is passed
|
||||
if (!passesIDI) {
|
||||
//no classification
|
||||
// Debug.out.println(templateClassifierParams.classifierName +" Classifier: Failed IDI classifier: ");
|
||||
return new TemplateClassification(CTClassifier.PRECLASSIFIERFLAG, corrValue);
|
||||
}
|
||||
|
||||
// check template correlation.
|
||||
if (Double.isNaN(corrValue) || corrValue<templateClassifierParams.corrThreshold) {
|
||||
@ -219,30 +211,6 @@ public class CTTemplateClassifier implements CTClassifier {
|
||||
return corr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check IDI measurments for a click trian
|
||||
* @return true if all measurments are passed.
|
||||
*/
|
||||
private boolean checkIDIMeasurements(CTDataUnit clickTrain) {
|
||||
IDIInfo idiInfo = clickTrain.getIDIInfo();
|
||||
|
||||
if (templateClassifierParams.useMedianIDI &&
|
||||
(idiInfo.medianIDI<templateClassifierParams.minMedianIDI || idiInfo.medianIDI>templateClassifierParams.maxMedianIDI)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (templateClassifierParams.useMeanIDI &&
|
||||
(idiInfo.meanIDI<templateClassifierParams.minMeanIDI || idiInfo.meanIDI>templateClassifierParams.maxMeanIDI)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (templateClassifierParams.useStdIDI &&
|
||||
(idiInfo.stdIDI<templateClassifierParams.minStdIDI || idiInfo.stdIDI>templateClassifierParams.maxStdIDI)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
@ -270,14 +238,14 @@ public class CTTemplateClassifier implements CTClassifier {
|
||||
this.templateClassifierParams=(TemplateClassifierParams) ctClassifierParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the simple chi^2 classifier which forms one of the classification tests for
|
||||
* the template classifier.
|
||||
* @return the chi2 classifier.
|
||||
*/
|
||||
public Chi2ThresholdClassifier getSimpleCTClassifier() {
|
||||
return this.chi2ThresholdClassifier;
|
||||
}
|
||||
// /**
|
||||
// * Get the simple chi^2 classifier which forms one of the classification tests for
|
||||
// * the template classifier.
|
||||
// * @return the chi2 classifier.
|
||||
// */
|
||||
// public Chi2ThresholdClassifier getSimpleCTClassifier() {
|
||||
// return this.chi2ThresholdClassifier;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int getSpeciesID() {
|
||||
|
@ -4,8 +4,6 @@ import PamModel.parametermanager.ManagedParameters;
|
||||
import PamModel.parametermanager.PamParameterSet;
|
||||
import clickTrainDetector.classification.CTClassifierParams;
|
||||
import clickTrainDetector.classification.CTClassifierType;
|
||||
import clickTrainDetector.classification.bearingClassifier.BearingClassifierParams;
|
||||
import clickTrainDetector.classification.simplechi2classifier.Chi2ThresholdParams;
|
||||
|
||||
import clickTrainDetector.classification.templateClassifier.DefualtSpectrumTemplates.SpectrumTemplateType;
|
||||
import matchedTemplateClassifer.MatchTemplate;
|
||||
@ -34,7 +32,7 @@ public class TemplateClassifierParams extends CTClassifierParams implements Mana
|
||||
/**
|
||||
* Basic chi2 threshold params.
|
||||
*/
|
||||
public Chi2ThresholdParams chi2ThresholdParams = new Chi2ThresholdParams();
|
||||
//public Chi2ThresholdParams chi2ThresholdParams = new Chi2ThresholdParams();
|
||||
|
||||
/**
|
||||
* Bearing parameters
|
||||
@ -45,53 +43,6 @@ public class TemplateClassifierParams extends CTClassifierParams implements Mana
|
||||
* Template correlation paramters.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Use the median ICI measurements
|
||||
*/
|
||||
public boolean useMedianIDI = true;
|
||||
|
||||
/**
|
||||
* The minimim median ICI.
|
||||
*/
|
||||
public Double minMedianIDI = 0.; // seconds
|
||||
|
||||
/**
|
||||
* The maximum median ICI
|
||||
*/
|
||||
public Double maxMedianIDI = 2.; // seconds
|
||||
|
||||
/**
|
||||
* Use the mean ICI measurements.
|
||||
*/
|
||||
public boolean useMeanIDI = false;
|
||||
|
||||
|
||||
/**
|
||||
* The minimum median ICI.
|
||||
*/
|
||||
public Double minMeanIDI = 0.; // seconds
|
||||
|
||||
/**
|
||||
* The maximum median ICI
|
||||
*/
|
||||
public Double maxMeanIDI = 2.; // seconds
|
||||
|
||||
|
||||
/**
|
||||
* Use the mean ICI measurements
|
||||
*/
|
||||
public boolean useStdIDI = false;
|
||||
|
||||
/**
|
||||
* The minimum standard deviation in ICI.
|
||||
*/
|
||||
public Double minStdIDI = 0.; // seconds
|
||||
|
||||
/**
|
||||
* The maximum standard deviation in ICI
|
||||
*/
|
||||
public Double maxStdIDI = 100.; // seconds
|
||||
|
||||
/**
|
||||
* Match FFT template.
|
||||
@ -107,7 +58,7 @@ public class TemplateClassifierParams extends CTClassifierParams implements Mana
|
||||
public TemplateClassifierParams clone() {
|
||||
TemplateClassifierParams clonedParams =(TemplateClassifierParams) super.clone();
|
||||
clonedParams.spectrumTemplate=spectrumTemplate.clone();
|
||||
clonedParams.chi2ThresholdParams=chi2ThresholdParams.clone();
|
||||
//clonedParams.chi2ThresholdParams=chi2ThresholdParams.clone();
|
||||
return clonedParams;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ import clickTrainDetector.layout.classification.CTClassifiersPane;
|
||||
import cpod.CPODClick;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.geometry.Side;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.ComboBox;
|
||||
@ -50,7 +51,7 @@ public class ClickTrainAlgorithmPaneFX extends SettingsPane<ClickTrainParams> {
|
||||
//there is something a little weird about template spectrum classifier which in Swing means
|
||||
//it needs to be 850 in height or the template covers some of the controls and they
|
||||
//cannot be clicked on??
|
||||
private static final double prefHeight = 800;
|
||||
private static final double prefHeight = 750;
|
||||
|
||||
private static final double prefWidth = 450;
|
||||
|
||||
@ -194,12 +195,16 @@ public class ClickTrainAlgorithmPaneFX extends SettingsPane<ClickTrainParams> {
|
||||
Label label = new Label("Click Train Detector Algorithm");
|
||||
// label.setFont(PamGuiManagerFX.titleFontSize2);
|
||||
PamGuiManagerFX.titleFont2style(label);
|
||||
|
||||
|
||||
dataSelectorHolder = new PamBorderPane();
|
||||
|
||||
|
||||
PamVBox ctDetectorHolder = new PamVBox();
|
||||
ctDetectorHolder.setSpacing(5);
|
||||
ctDetectorHolder.getChildren().addAll(label, clickTrainAlgorithmBox, ctSettingsHolder);
|
||||
|
||||
ctDetectorHolder.getChildren().addAll(sourcePane, groupHolder, dataSelectorHolder, label, clickTrainAlgorithmBox, ctSettingsHolder);
|
||||
ctDetectorHolder.setPadding(new Insets(5,5,5,5));
|
||||
|
||||
//the data selector pane.
|
||||
dataSelectorPane = createDataSelectorPane();
|
||||
|
||||
@ -210,6 +215,9 @@ public class ClickTrainAlgorithmPaneFX extends SettingsPane<ClickTrainParams> {
|
||||
ctClassifierHolder= new CTClassifiersPane(clickTrainControl);
|
||||
ctClassifierHolder.setPadding(new Insets(5,0,0,0));
|
||||
|
||||
|
||||
|
||||
|
||||
//the tab pane to hold classifier and the detector pane.
|
||||
tabPane = new TabPane();
|
||||
Tab tab1 = new Tab("Detector", ctDetectorHolder);
|
||||
@ -221,10 +229,11 @@ public class ClickTrainAlgorithmPaneFX extends SettingsPane<ClickTrainParams> {
|
||||
tabPane.getTabs().addAll(tab1, tab3, tab2);
|
||||
tabPane.setPrefHeight(prefHeight);
|
||||
|
||||
dataSelectorHolder = new PamBorderPane();
|
||||
tabPane.setSide(Side.TOP);
|
||||
|
||||
|
||||
holder.getChildren().addAll(sourcePane, groupHolder, dataSelectorHolder, tabPane);
|
||||
holder.setPadding(new Insets(5,5,5,5));
|
||||
holder.getChildren().addAll(tabPane);
|
||||
//holder.setPadding(new Insets(5,5,5,5));
|
||||
|
||||
return holder;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package clickTrainDetector.layout;
|
||||
import clickTrainDetector.ClickTrainControl;
|
||||
import clickTrainDetector.ClickTrainParams;
|
||||
import clickTrainDetector.layout.classification.simplechi2classifier.SimpleCTClassifierPane;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.layout.Pane;
|
||||
import pamViewFX.fxNodes.PamBorderPane;
|
||||
|
||||
@ -27,7 +28,8 @@ public class PreClassifierPane extends PamBorderPane {
|
||||
this.clickTrainControl = clickTrainControl;
|
||||
|
||||
|
||||
this.setCenter(createClassifierPane());
|
||||
this.setCenter(createClassifierPane());
|
||||
this.setPadding(new Insets(5,5,5,5));
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,13 +18,13 @@ public interface CTClassifierGraphics {
|
||||
public Pane getCTClassifierPane();
|
||||
|
||||
/**
|
||||
* Called to save the params from the settings pane.
|
||||
* Called to save the parameters from the settings pane.
|
||||
*/
|
||||
public CTClassifierParams getParams();
|
||||
|
||||
/**
|
||||
* Set the parameters
|
||||
* @param params - the paramters for a classifier
|
||||
* Set the parameters.
|
||||
* @param params - the parameters for a classifier.
|
||||
*/
|
||||
public void setParams(CTClassifierParams params);
|
||||
|
||||
|
@ -5,6 +5,7 @@ import clickTrainDetector.ClickTrainControl;
|
||||
import clickTrainDetector.classification.CTClassifier;
|
||||
import clickTrainDetector.classification.CTClassifierParams;
|
||||
import clickTrainDetector.classification.CTClassifierType;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Label;
|
||||
@ -28,7 +29,7 @@ public class CTClassifierPane extends PamBorderPane {
|
||||
/**
|
||||
* The classifier type combo box.
|
||||
*/
|
||||
private ComboBox<String> classifierListBox;
|
||||
private ComboBox<CTClassifierType> classifierListBox;
|
||||
|
||||
/**
|
||||
* Reference to the click train control.
|
||||
@ -45,10 +46,19 @@ public class CTClassifierPane extends PamBorderPane {
|
||||
*/
|
||||
private CTClassifier currentClassifier;
|
||||
|
||||
/**
|
||||
* A list of the type of classifiers.
|
||||
*/
|
||||
private CTClassifierType[] ctClassifierTypes;
|
||||
|
||||
/**
|
||||
* The name field.
|
||||
*/
|
||||
private TextField nameField;
|
||||
|
||||
/**
|
||||
* Selects the species ID for the classifier.
|
||||
*/
|
||||
private PamSpinner<Integer> speciesIDSpinner;
|
||||
|
||||
/**
|
||||
@ -56,7 +66,6 @@ public class CTClassifierPane extends PamBorderPane {
|
||||
*/
|
||||
private int defaultSpeciesID = 1;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for the classifier pane.
|
||||
* @param i - the default species ID
|
||||
@ -102,12 +111,16 @@ public class CTClassifierPane extends PamBorderPane {
|
||||
|
||||
ctClassifierTypes = CTClassifierType.values();
|
||||
|
||||
classifierListBox = new ComboBox<String>();
|
||||
int nClassifiers = 0;
|
||||
classifierListBox = new ComboBox<CTClassifierType>();
|
||||
for (int i=0; i<ctClassifierTypes.length; i++) {
|
||||
classifierListBox.getItems().add(clickTrainControl.getClassifierManager().getClassifierName(ctClassifierTypes[i]));
|
||||
if (ctClassifierTypes[i].isEnable()) {
|
||||
classifierListBox.getItems().add(ctClassifierTypes[i]);
|
||||
nClassifiers++;
|
||||
}
|
||||
}
|
||||
classifierListBox.setOnAction((action)->{
|
||||
setClassifierPane(classifierListBox.getSelectionModel().getSelectedIndex());
|
||||
setClassifierPane(classifierListBox.getSelectionModel().getSelectedItem());
|
||||
});
|
||||
classifierListBox.getSelectionModel().select(0);
|
||||
|
||||
@ -116,9 +129,15 @@ public class CTClassifierPane extends PamBorderPane {
|
||||
settingsHolder = new PamBorderPane();
|
||||
|
||||
//set the current classifier pane.
|
||||
setClassifierPane(0);
|
||||
setClassifierPane(classifierListBox.getItems().get(0));
|
||||
|
||||
//only add the classifiers type box if there is more than one type of classifier.
|
||||
mainHolder.getChildren().addAll(label1, holder);
|
||||
if (nClassifiers>1) mainHolder.getChildren().addAll(label2, classifierListBox);
|
||||
mainHolder.getChildren().addAll(settingsHolder);
|
||||
|
||||
mainHolder.setPadding(new Insets(5,5,5,5)); //otherwise looks messy against edges of tab pane.
|
||||
|
||||
mainHolder.getChildren().addAll(label1, holder, label2, classifierListBox, settingsHolder);
|
||||
|
||||
return mainHolder;
|
||||
}
|
||||
@ -144,15 +163,15 @@ public class CTClassifierPane extends PamBorderPane {
|
||||
*/
|
||||
public void setParams(CTClassifierParams params) {
|
||||
//probably a more elegent way to do this.
|
||||
int index =-1;
|
||||
for (int i=0; i<ctClassifierTypes.length; i++) {
|
||||
if (ctClassifierTypes[i]==params.type) {
|
||||
index=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
classifierListBox.getSelectionModel().select(index);
|
||||
setClassifierPane(index);
|
||||
// int index =-1;
|
||||
// for (int i=0; i<ctClassifierTypes.length; i++) {
|
||||
// if (ctClassifierTypes[i]==params.type) {
|
||||
// index=i;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
classifierListBox.getSelectionModel().select(params.type);
|
||||
setClassifierPane(params.type);
|
||||
|
||||
//species Id
|
||||
setBasicParams(params);
|
||||
@ -174,10 +193,11 @@ public class CTClassifierPane extends PamBorderPane {
|
||||
|
||||
/**
|
||||
* Set the classifier pane.
|
||||
* @param clssfrIndex - set the index.
|
||||
* @param ctClassifierType - set the index.
|
||||
*/
|
||||
private void setClassifierPane(int clssfrIndex) {
|
||||
currentClassifier = clickTrainControl.getClassifierManager().createClassifier(clssfrIndex);
|
||||
private void setClassifierPane(CTClassifierType ctClassifierType) {
|
||||
if (ctClassifierType==null) return;
|
||||
currentClassifier = clickTrainControl.getClassifierManager().createClassifier(ctClassifierType);
|
||||
//Classifier pane- this also sets parameters for the classifier specific pane
|
||||
if (currentClassifier.getCTClassifierGraphics()!=null) {
|
||||
settingsHolder.setCenter(currentClassifier.getCTClassifierGraphics().getCTClassifierPane());
|
||||
|
@ -32,11 +32,13 @@ public class CTClassifiersPane extends PamBorderPane {
|
||||
*/
|
||||
private CheckBox enableClassifierBox;
|
||||
|
||||
|
||||
/**
|
||||
* Reference to the click train control.
|
||||
*/
|
||||
private ClickTrainControl clickTrainControl;
|
||||
|
||||
|
||||
/**
|
||||
* Tab pane where each tab is a different classifier.
|
||||
*/
|
||||
@ -55,22 +57,18 @@ public class CTClassifiersPane extends PamBorderPane {
|
||||
*/
|
||||
private Pane createClassifierPane() {
|
||||
|
||||
|
||||
// enable the classifier.
|
||||
enableClassifierBox = new CheckBox("Enable Click Train Classification");
|
||||
enableClassifierBox.setOnAction(action ->{
|
||||
enableClassifierPane(enableClassifierBox.isSelected());
|
||||
});
|
||||
|
||||
|
||||
|
||||
// enable the classifier.
|
||||
enableClassifierBox = new CheckBox("Enable Click Train Classification");
|
||||
enableClassifierBox.setOnAction(action ->{
|
||||
enableClassifierPane(enableClassifierBox.isSelected());
|
||||
});
|
||||
|
||||
|
||||
// enable the classifier.
|
||||
enableClassifierBox = new CheckBox("Enable Click Train Classification");
|
||||
enableClassifierBox.setOnAction(action ->{
|
||||
enableClassifierPane(enableClassifierBox.isSelected());
|
||||
});
|
||||
|
||||
//with just one classifier.
|
||||
pamTabPane = new PamTabPane();
|
||||
pamTabPane.setAddTabButton(true);
|
||||
@ -78,10 +76,7 @@ public class CTClassifiersPane extends PamBorderPane {
|
||||
pamTabPane.getAddTabButton().setGraphic(PamGlyphDude.createPamIcon("mdi2p-plus", PamGuiManagerFX.iconSize));
|
||||
pamTabPane.setTabClosingPolicy(TabClosingPolicy.SELECTED_TAB);
|
||||
pamTabPane.getAddTabButton().setTooltip(new Tooltip(
|
||||
"Add a new template. The classifier will check all templates \n"
|
||||
+ "and classify the click train if any template passes it's designated \n"
|
||||
+ "value. All template match, reject and threshold values are \n"
|
||||
+ "stored as annotations in binary files."));
|
||||
"Add a new classifier."));
|
||||
|
||||
pamTabPane.getAddTabButton().setOnAction((action)->{
|
||||
CTClassifierPane clssfrPane = new CTClassifierPane(clickTrainControl);
|
||||
@ -113,9 +108,7 @@ public class CTClassifiersPane extends PamBorderPane {
|
||||
|
||||
enableClassifierPane(enableClassifierBox.isSelected());
|
||||
|
||||
|
||||
enableClassifierPane(enableClassifierBox.isSelected());
|
||||
|
||||
|
||||
return holder;
|
||||
}
|
||||
@ -153,7 +146,7 @@ public class CTClassifiersPane extends PamBorderPane {
|
||||
super("Tab");
|
||||
this.ctClassifierPane = tmpltClassifierPane;
|
||||
this.setContent(tmpltClassifierPane);
|
||||
tmpltClassifierPane.getNameField().setText("Template " + (listPos+1));
|
||||
tmpltClassifierPane.getNameField().setText("Classifer " + (listPos+1));
|
||||
|
||||
this.textProperty().bind(tmpltClassifierPane.getNameField().textProperty());
|
||||
}
|
||||
@ -187,8 +180,6 @@ public class CTClassifiersPane extends PamBorderPane {
|
||||
ctClassifierParams.add(aClassifierParams);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!PamArrayUtils.unique(speciesCodeList) && speciesCodeList.length>1) {
|
||||
System.err.println("CTClassifiersPane: The species codes are not unique");
|
||||
PamArrayUtils.printArray(speciesCodeList);
|
||||
|
@ -45,17 +45,17 @@ public class BearingClassifierPane extends SettingsPane<BearingClassifierParams
|
||||
*/
|
||||
private void createBearingClassifierPane() {
|
||||
|
||||
Label label = new Label("Bearing Limits");
|
||||
// Label label = new Label("Bearing Limits");
|
||||
// label.setFont(PamGuiManagerFX.titleFontSize2);
|
||||
PamGuiManagerFX.titleFont2style(label);
|
||||
// PamGuiManagerFX.titleFont2style(label);
|
||||
|
||||
|
||||
bearingLims = new MinMaxPane<Double>("Bearing", "\u00B0", -180., 180., 2.);
|
||||
bearingLims = new MinMaxPane<Double>("Bearing Limits", "\u00B0", -180., 180., 2.);
|
||||
|
||||
|
||||
Label label2 = new Label("\u0394 Bearing");
|
||||
// Label label2 = new Label("\u0394 Bearing");
|
||||
// label2.setFont(PamGuiManagerFX.titleFontSize2);
|
||||
PamGuiManagerFX.titleFont2style(label2);
|
||||
// PamGuiManagerFX.titleFont2style(label2);
|
||||
|
||||
|
||||
bearingDMean = new MinMaxPane<Double>("\u0394 Bearing Mean ", "\u00B0/s", -180., 180., 0.001);
|
||||
@ -70,7 +70,7 @@ public class BearingClassifierPane extends SettingsPane<BearingClassifierParams
|
||||
this.mainPane = new PamVBox();
|
||||
mainPane.setSpacing(5);
|
||||
|
||||
mainPane.getChildren().addAll(label, bearingLims, label2, bearingDMean, bearingDMedian, bearingDStd);
|
||||
mainPane.getChildren().addAll(bearingLims, bearingDMean, bearingDMedian, bearingDStd);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,59 @@
|
||||
package clickTrainDetector.layout.classification.idiClassifier;
|
||||
|
||||
import clickTrainDetector.ClickTrainControl;
|
||||
import clickTrainDetector.classification.CTClassifierParams;
|
||||
import clickTrainDetector.classification.idiClassifier.IDIClassifier;
|
||||
import clickTrainDetector.classification.idiClassifier.IDIClassifierParams;
|
||||
import clickTrainDetector.layout.classification.CTClassifierGraphics;
|
||||
import javafx.scene.layout.Pane;
|
||||
|
||||
/**
|
||||
* The IDI classifier graphics. Has controls for the IDI classifier.
|
||||
*
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class IDIClassifierGraphics implements CTClassifierGraphics {
|
||||
|
||||
|
||||
private IDIPane idiPane;
|
||||
|
||||
/**
|
||||
* Reference to the IDI classifier
|
||||
*/
|
||||
private IDIClassifier idiClassifier;
|
||||
|
||||
public IDIClassifierGraphics(ClickTrainControl clickTrainControl, IDIClassifier idiClassifier) {
|
||||
this.idiClassifier = idiClassifier;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pane getCTClassifierPane() {
|
||||
if (idiPane == null) {
|
||||
idiPane = new IDIPane();
|
||||
}
|
||||
return idiPane;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CTClassifierParams getParams() {
|
||||
IDIClassifierParams clssfrParams = idiPane.getParams(idiClassifier.getParams());
|
||||
if (clssfrParams==null) {
|
||||
System.err.print("Bearing classifier returned null params");
|
||||
return null;
|
||||
}
|
||||
// else {
|
||||
// simpleChi2Classifier.setParams(clssfrParams);
|
||||
// return clssfrParams;
|
||||
// }
|
||||
return clssfrParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParams(CTClassifierParams params) {
|
||||
idiPane.setParams((IDIClassifierParams) params);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package clickTrainDetector.layout.classification.templateClassifier;
|
||||
package clickTrainDetector.layout.classification.idiClassifier;
|
||||
|
||||
import clickTrainDetector.classification.idiClassifier.IDIClassifierParams;
|
||||
import clickTrainDetector.classification.templateClassifier.TemplateClassifierParams;
|
||||
|
||||
import javafx.scene.layout.Pane;
|
||||
@ -63,45 +64,45 @@ public class IDIPane extends PamBorderPane {
|
||||
|
||||
/**
|
||||
* Set IDI parameters.
|
||||
* @param templateClassifierParams - parameters to set.
|
||||
* @param idiClassifierParams - parameters to set.
|
||||
*/
|
||||
public void setParams(TemplateClassifierParams templateClassifierParams) {
|
||||
public void setParams(IDIClassifierParams idiClassifierParams) {
|
||||
|
||||
medianMinMax.setParams(templateClassifierParams.minMedianIDI, templateClassifierParams.maxMedianIDI, templateClassifierParams.useMedianIDI);
|
||||
medianMinMax.setParams(idiClassifierParams.minMedianIDI, idiClassifierParams.maxMedianIDI, idiClassifierParams.useMedianIDI);
|
||||
|
||||
meanMinMax.setParams(templateClassifierParams.minMeanIDI, templateClassifierParams.maxMeanIDI, templateClassifierParams.useMeanIDI);
|
||||
meanMinMax.setParams(idiClassifierParams.minMeanIDI, idiClassifierParams.maxMeanIDI, idiClassifierParams.useMeanIDI);
|
||||
|
||||
stdMinMax.setParams(templateClassifierParams.minStdIDI, templateClassifierParams.maxStdIDI, templateClassifierParams.useStdIDI);
|
||||
stdMinMax.setParams(idiClassifierParams.minStdIDI, idiClassifierParams.maxStdIDI, idiClassifierParams.useStdIDI);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get IDI parameters.
|
||||
* @param templateClassifierParams - parameter class to add IDI parameters settings to./
|
||||
* @param idiClassifierParams - parameter class to add IDI parameters settings to./
|
||||
* @return altered parameters class.
|
||||
*/
|
||||
public TemplateClassifierParams getParams(TemplateClassifierParams templateClassifierParams) {
|
||||
public IDIClassifierParams getParams(IDIClassifierParams idiClassifierParams) {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
MinMaxParams minMaxParams = medianMinMax.getParams();
|
||||
|
||||
templateClassifierParams.minMedianIDI = (Double) minMaxParams.min;
|
||||
templateClassifierParams.maxMedianIDI = (Double) minMaxParams.max;
|
||||
templateClassifierParams.useMedianIDI = minMaxParams.enabled;
|
||||
idiClassifierParams.minMedianIDI = (Double) minMaxParams.min;
|
||||
idiClassifierParams.maxMedianIDI = (Double) minMaxParams.max;
|
||||
idiClassifierParams.useMedianIDI = minMaxParams.enabled;
|
||||
|
||||
minMaxParams = meanMinMax.getParams();
|
||||
|
||||
templateClassifierParams.minMeanIDI = (Double) minMaxParams.min;
|
||||
templateClassifierParams.maxMeanIDI = (Double) minMaxParams.max;
|
||||
templateClassifierParams.useMeanIDI = minMaxParams.enabled;
|
||||
idiClassifierParams.minMeanIDI = (Double) minMaxParams.min;
|
||||
idiClassifierParams.maxMeanIDI = (Double) minMaxParams.max;
|
||||
idiClassifierParams.useMeanIDI = minMaxParams.enabled;
|
||||
|
||||
minMaxParams = stdMinMax.getParams();
|
||||
|
||||
templateClassifierParams.minStdIDI = (Double) minMaxParams.min;
|
||||
templateClassifierParams.maxStdIDI = (Double) minMaxParams.max;
|
||||
templateClassifierParams.useStdIDI = minMaxParams.enabled;
|
||||
idiClassifierParams.minStdIDI = (Double) minMaxParams.min;
|
||||
idiClassifierParams.maxStdIDI = (Double) minMaxParams.max;
|
||||
idiClassifierParams.useStdIDI = minMaxParams.enabled;
|
||||
|
||||
return templateClassifierParams;
|
||||
return idiClassifierParams;
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,13 @@ import PamController.SettingsPane;
|
||||
import clickTrainDetector.classification.simplechi2classifier.Chi2ThresholdClassifier;
|
||||
import clickTrainDetector.classification.simplechi2classifier.Chi2ThresholdParams;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.Spinner;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.layout.Pane;
|
||||
import pamViewFX.fxNodes.PamHBox;
|
||||
import pamViewFX.fxNodes.PamSpinner;
|
||||
import pamViewFX.fxNodes.PamVBox;
|
||||
import pamViewFX.fxNodes.utilsFX.ControlField;
|
||||
@ -19,10 +24,12 @@ import pamViewFX.fxNodes.utilsFX.ControlField;
|
||||
public class SimpleCTClassifierPane extends SettingsPane<Chi2ThresholdParams> {
|
||||
|
||||
|
||||
private static final double LABEL_WIDTH = 115;
|
||||
|
||||
/**
|
||||
* The main pane.
|
||||
*/
|
||||
private PamVBox mainPane;
|
||||
private Pane mainPane;
|
||||
|
||||
/**
|
||||
* The chi^2 threshold.
|
||||
@ -47,23 +54,42 @@ public class SimpleCTClassifierPane extends SettingsPane<Chi2ThresholdParams> {
|
||||
public SimpleCTClassifierPane(Chi2ThresholdClassifier simpleChi2Classifier) {
|
||||
super(null);
|
||||
this.simpleChi2Classifier=simpleChi2Classifier;
|
||||
mainPane = createSimpleClassifierPane();
|
||||
mainPane = createSimpleClassifierPane(Orientation.VERTICAL);
|
||||
}
|
||||
|
||||
public SimpleCTClassifierPane() {
|
||||
super(null);
|
||||
mainPane = createSimpleClassifierPane();
|
||||
mainPane = createSimpleClassifierPane(Orientation.VERTICAL);
|
||||
}
|
||||
|
||||
public SimpleCTClassifierPane(Chi2ThresholdClassifier simpleChi2Classifier, Orientation orientation) {
|
||||
super(null);
|
||||
this.simpleChi2Classifier=simpleChi2Classifier;
|
||||
mainPane = createSimpleClassifierPane(orientation);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create simple classifier pane.
|
||||
*/
|
||||
private PamVBox createSimpleClassifierPane() {
|
||||
private Pane createSimpleClassifierPane(Orientation orientation) {
|
||||
|
||||
Pane vBox;
|
||||
|
||||
if (orientation == Orientation.VERTICAL) {
|
||||
vBox = new PamVBox();
|
||||
((PamVBox) vBox).setSpacing(5);
|
||||
}
|
||||
else {
|
||||
vBox = new PamHBox();
|
||||
((PamHBox) vBox).setSpacing(5);
|
||||
}
|
||||
|
||||
PamVBox vBox = new PamVBox();
|
||||
vBox.setPadding(new Insets(5,0,0,0));
|
||||
vBox.setSpacing(5);
|
||||
|
||||
PamHBox pamHBox = new PamHBox();
|
||||
pamHBox.setSpacing(5);
|
||||
|
||||
|
||||
// create spinner.
|
||||
chi2Threshold = new ControlField<Double>("X\u00b2 Threshold ", "", 0.0, Double.MAX_VALUE, 25.0);
|
||||
@ -72,17 +98,20 @@ public class SimpleCTClassifierPane extends SettingsPane<Chi2ThresholdParams> {
|
||||
"A click train has a X\u00b2 value which is based on the consistancy of inter detection interval \n"
|
||||
+ "amplitude and other factors. The calculation of X\\\\u00b2 changes depending on the click train \n"
|
||||
+ "detector is used."));
|
||||
chi2Threshold.getLabel1().setPrefWidth(LABEL_WIDTH);
|
||||
|
||||
minClicks = new ControlField<Double>("Minimum Clicks ", "", 0, Integer.MAX_VALUE, 5);
|
||||
minClicks = new ControlField<Double>("Min. Clicks ", "", 0, Integer.MAX_VALUE, 5);
|
||||
minClicks.setTooltip(new Tooltip(
|
||||
"The minimum number of detections."));
|
||||
minClicks.getSpinner().setEditable(true);
|
||||
minClicks.getLabel1().setPrefWidth(LABEL_WIDTH);
|
||||
|
||||
minTime = new ControlField<Double>("Minimum Time ", "s", 0.0, Double.MAX_VALUE, 1.0);
|
||||
minTime = new ControlField<Double>("Min. Time ", "s", 0.0, Double.MAX_VALUE, 1.0);
|
||||
minTime.getSpinner().getValueFactory().setConverter(PamSpinner.createStringConverter(2));
|
||||
minTime.setTooltip(new Tooltip(
|
||||
"The minimum time for a click train."));
|
||||
minTime.getSpinner().setEditable(true);
|
||||
minTime.getLabel1().setPrefWidth(LABEL_WIDTH);
|
||||
|
||||
chi2Threshold.getSpinner().setEditable(true);
|
||||
|
||||
@ -125,7 +154,7 @@ public class SimpleCTClassifierPane extends SettingsPane<Chi2ThresholdParams> {
|
||||
* Get the main pane.
|
||||
* @return the main pane.
|
||||
*/
|
||||
public PamVBox getMainPane() {
|
||||
public Pane getMainPane() {
|
||||
return mainPane;
|
||||
}
|
||||
|
||||
@ -134,6 +163,7 @@ public class SimpleCTClassifierPane extends SettingsPane<Chi2ThresholdParams> {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,70 @@
|
||||
package clickTrainDetector.layout.classification.standardClassifier;
|
||||
|
||||
import clickTrainDetector.ClickTrainControl;
|
||||
import clickTrainDetector.classification.CTClassifierParams;
|
||||
import clickTrainDetector.classification.bearingClassifier.BearingClassifier;
|
||||
import clickTrainDetector.classification.bearingClassifier.BearingClassifierParams;
|
||||
import clickTrainDetector.classification.standardClassifier.StandardClassifier;
|
||||
import clickTrainDetector.classification.standardClassifier.StandardClassifierParams;
|
||||
import clickTrainDetector.layout.classification.CTClassifierGraphics;
|
||||
import javafx.scene.layout.Pane;
|
||||
|
||||
|
||||
/**
|
||||
* Handles the GUI for the standard click train classifier.
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class StandardClassifierGraphics implements CTClassifierGraphics {
|
||||
|
||||
/**
|
||||
* Reference to the pane which hold controls for standard classifier params.
|
||||
*/
|
||||
private StandardClassifierPane standardClassifierPane;
|
||||
|
||||
/**
|
||||
* Reference to the click train control.
|
||||
*/
|
||||
private ClickTrainControl clickTrainControl;
|
||||
|
||||
/**
|
||||
* Reference to the standard classifier
|
||||
*/
|
||||
private StandardClassifier standardClassifier;
|
||||
|
||||
public StandardClassifierGraphics(ClickTrainControl clickTrainControl, StandardClassifier standardClassifier) {
|
||||
this.clickTrainControl=clickTrainControl;
|
||||
this.standardClassifier= standardClassifier;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Pane getCTClassifierPane() {
|
||||
if (standardClassifierPane ==null) {
|
||||
standardClassifierPane = new StandardClassifierPane(standardClassifier);
|
||||
}
|
||||
|
||||
return (Pane) standardClassifierPane.getContentNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CTClassifierParams getParams() {
|
||||
StandardClassifierParams clssfrParams = standardClassifierPane.getParams(standardClassifier.getParams());
|
||||
if (clssfrParams==null) {
|
||||
System.err.print("Bearing classifier returned null params");
|
||||
return null;
|
||||
}
|
||||
// else {
|
||||
// simpleChi2Classifier.setParams(clssfrParams);
|
||||
// return clssfrParams;
|
||||
// }
|
||||
return clssfrParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParams(CTClassifierParams params) {
|
||||
standardClassifierPane.setParams((StandardClassifierParams) params);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package clickTrainDetector.layout.classification.standardClassifier;
|
||||
|
||||
import PamController.SettingsPane;
|
||||
import clickTrainDetector.classification.standardClassifier.StandardClassifier;
|
||||
import clickTrainDetector.classification.standardClassifier.StandardClassifierParams;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.Pane;
|
||||
import pamViewFX.PamGuiManagerFX;
|
||||
import pamViewFX.fxNodes.PamBorderPane;
|
||||
import pamViewFX.fxNodes.PamHBox;
|
||||
import pamViewFX.fxNodes.PamVBox;
|
||||
import pamViewFX.fxNodes.utilityPanes.PamToggleSwitch;
|
||||
|
||||
|
||||
/**
|
||||
* Pane for the standard classifier. Essentially holds all the panes of the other classifiers.
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class StandardClassifierPane extends SettingsPane<StandardClassifierParams> {
|
||||
|
||||
private PamBorderPane mainPane;
|
||||
|
||||
private StandardClassifier standardClassifier;
|
||||
|
||||
private PamToggleSwitch[] enableSwitch;
|
||||
|
||||
public StandardClassifierPane(StandardClassifier standardClassifier) {
|
||||
super(null);
|
||||
this.standardClassifier = standardClassifier;
|
||||
mainPane = new PamBorderPane();
|
||||
mainPane.setCenter(createPane());
|
||||
}
|
||||
|
||||
private Pane createPane() {
|
||||
PamVBox vBox = new PamVBox();
|
||||
vBox.setSpacing(5);
|
||||
|
||||
enableSwitch = new PamToggleSwitch[standardClassifier.getClassifiers().size()];
|
||||
for (int i=0; i<standardClassifier.getClassifiers().size(); i++) {
|
||||
|
||||
enableSwitch[i] = new PamToggleSwitch("");
|
||||
|
||||
Label label = new Label(standardClassifier.getClassifiers().get(i).getName());
|
||||
PamGuiManagerFX.titleFont2style(label);
|
||||
|
||||
final int ii = i;
|
||||
enableSwitch[i].selectedProperty().addListener((obsVal, oldVal, newVal)->{
|
||||
standardClassifier.getClassifiers().get(ii).getCTClassifierGraphics().getCTClassifierPane().setDisable(!enableSwitch[ii].isSelected());
|
||||
label.setDisable(!enableSwitch[ii].isSelected());
|
||||
});
|
||||
|
||||
PamHBox hBox = new PamHBox();
|
||||
hBox.setSpacing(5);
|
||||
|
||||
hBox.getChildren().addAll(enableSwitch[i], label);
|
||||
|
||||
|
||||
|
||||
vBox.getChildren().addAll(hBox, standardClassifier.getClassifiers().get(i).getCTClassifierGraphics().getCTClassifierPane());
|
||||
}
|
||||
|
||||
return vBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardClassifierParams getParams(StandardClassifierParams currParams) {
|
||||
for (int i=0; i<standardClassifier.getClassifiers().size(); i++) {
|
||||
currParams.ctClassifierParams[i] = standardClassifier.getClassifiers().get(i).getCTClassifierGraphics().getParams();
|
||||
currParams.enable[i] = enableSwitch[i].isSelected();
|
||||
}
|
||||
return currParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParams(StandardClassifierParams input) {
|
||||
for (int i=0; i<standardClassifier.getClassifiers().size(); i++) {
|
||||
standardClassifier.getClassifiers().get(i).getCTClassifierGraphics().setParams(input.ctClassifierParams[i]);
|
||||
enableSwitch[i].setSelected(input.enable[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Standard Classifier";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getContentNode() {
|
||||
return mainPane;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paneInitialized() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ import clickTrainDetector.classification.templateClassifier.CTTemplateClassifier
|
||||
import clickTrainDetector.classification.templateClassifier.DefualtSpectrumTemplates;
|
||||
import clickTrainDetector.classification.templateClassifier.DefualtSpectrumTemplates.SpectrumTemplateType;
|
||||
import clickTrainDetector.classification.templateClassifier.TemplateClassifierParams;
|
||||
import clickTrainDetector.layout.classification.idiClassifier.IDIPane;
|
||||
import clickTrainDetector.layout.classification.simplechi2classifier.SimpleCTClassifierPane;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Node;
|
||||
@ -35,7 +36,7 @@ public class TemplateClassifierPane extends SettingsPane<TemplateClassifierParam
|
||||
/**
|
||||
* Simple classifier pane
|
||||
*/
|
||||
private SimpleCTClassifierPane simpleCTClassifierPane;
|
||||
//private SimpleCTClassifierPane simpleCTClassifierPane;
|
||||
|
||||
/**
|
||||
* Reference to the CT classifer.
|
||||
@ -45,7 +46,7 @@ public class TemplateClassifierPane extends SettingsPane<TemplateClassifierParam
|
||||
/**
|
||||
* The inter-detection settings pane.
|
||||
*/
|
||||
private IDIPane idiPane;
|
||||
//private IDIPane idiPane;
|
||||
|
||||
private TemplateSpectrumPane spectrumTemplatePane;
|
||||
|
||||
@ -73,24 +74,24 @@ public class TemplateClassifierPane extends SettingsPane<TemplateClassifierParam
|
||||
|
||||
private Node createTemplatePane() {
|
||||
|
||||
//create the simple classifier pane.
|
||||
Label label1 = new Label("X\u00b2 Threshold");
|
||||
// label1.setFont(PamGuiManagerFX.titleFontSize2);
|
||||
PamGuiManagerFX.titleFont2style(label1);
|
||||
|
||||
simpleCTClassifierPane = new SimpleCTClassifierPane(cTTemplateClassifier.getSimpleCTClassifier());
|
||||
|
||||
//the IDI settings
|
||||
Label label2 = new Label("IDI Settings");
|
||||
// label2.setFont(PamGuiManagerFX.titleFontSize2);
|
||||
PamGuiManagerFX.titleFont2style(label2);
|
||||
|
||||
idiPane = new IDIPane();
|
||||
// //create the simple classifier pane.
|
||||
// Label label1 = new Label("X\u00b2 Threshold");
|
||||
//// label1.setFont(PamGuiManagerFX.titleFontSize2);
|
||||
// PamGuiManagerFX.titleFont2style(label1);
|
||||
//
|
||||
// simpleCTClassifierPane = new SimpleCTClassifierPane(cTTemplateClassifier.getSimpleCTClassifier());
|
||||
//
|
||||
// //the IDI settings
|
||||
// Label label2 = new Label("IDI Settings");
|
||||
//// label2.setFont(PamGuiManagerFX.titleFontSize2);
|
||||
// PamGuiManagerFX.titleFont2style(label2);
|
||||
//
|
||||
// idiPane = new IDIPane();
|
||||
|
||||
//the spectrum template pane.
|
||||
Label label3 = new Label("Spectrum Template");
|
||||
//Label label3 = new Label("Spectrum Template");
|
||||
// label3.setFont(PamGuiManagerFX.titleFontSize2);
|
||||
PamGuiManagerFX.titleFont2style(label3);
|
||||
//PamGuiManagerFX.titleFont2style(label3);
|
||||
|
||||
// create spinner.
|
||||
spectrumthreshold = new ControlField<Double>("Spectrum Correlation Threshold", "", 0.0, Double.MAX_VALUE, 0.2);
|
||||
@ -100,18 +101,21 @@ public class TemplateClassifierPane extends SettingsPane<TemplateClassifierParam
|
||||
|
||||
spectrumTemplatePane = new TemplateSpectrumPane();
|
||||
spectrumTemplatePane.setPadding(new Insets(5,5,5,5));
|
||||
spectrumTemplatePane.setMaxWidth(Double.POSITIVE_INFINITY);
|
||||
spectrumTemplatePane.setMinWidth(50);
|
||||
|
||||
// spectrumTemplatePane.setMouseTransparent(true);
|
||||
|
||||
//make general and spectrum correlation pane.
|
||||
PamVBox generalPane = new PamVBox();
|
||||
generalPane.setSpacing(5);
|
||||
generalPane.getChildren().addAll(label1, simpleCTClassifierPane.getContentNode(), label2,
|
||||
idiPane);
|
||||
// generalPane.getChildren().addAll(label1, simpleCTClassifierPane.getContentNode(), label2,
|
||||
// idiPane);
|
||||
generalPane.setPadding(new Insets(5,5,5,5));
|
||||
|
||||
PamVBox spectrumPane = new PamVBox();
|
||||
spectrumPane.setSpacing(5);
|
||||
spectrumPane.getChildren().addAll(label3, spectrumthreshold, spectrumTemplatePane);
|
||||
spectrumPane.getChildren().addAll(spectrumthreshold, spectrumTemplatePane);
|
||||
spectrumPane.setPadding(new Insets(5,5,5,5));
|
||||
|
||||
|
||||
@ -139,9 +143,9 @@ public class TemplateClassifierPane extends SettingsPane<TemplateClassifierParam
|
||||
@Override
|
||||
public TemplateClassifierParams getParams(TemplateClassifierParams currParams) {
|
||||
|
||||
currParams.chi2ThresholdParams = simpleCTClassifierPane.getParams(currParams.chi2ThresholdParams);
|
||||
|
||||
currParams = idiPane.getParams(currParams);
|
||||
// currParams.chi2ThresholdParams = simpleCTClassifierPane.getParams(currParams.chi2ThresholdParams);
|
||||
//
|
||||
// currParams = idiPane.getParams(currParams);
|
||||
|
||||
currParams.spectrumTemplate = spectrumTemplatePane.getSpectrum();
|
||||
|
||||
@ -153,11 +157,11 @@ public class TemplateClassifierPane extends SettingsPane<TemplateClassifierParam
|
||||
@Override
|
||||
public void setParams(TemplateClassifierParams input) {
|
||||
//TEMP- testing settings classes.
|
||||
if (input.chi2ThresholdParams==null) input.chi2ThresholdParams=new Chi2ThresholdParams();
|
||||
//if (input.chi2ThresholdParams==null) input.chi2ThresholdParams=new Chi2ThresholdParams();
|
||||
if (input.spectrumTemplate==null) input.spectrumTemplate=DefualtSpectrumTemplates.getTemplate(SpectrumTemplateType.DOLPHIN);
|
||||
|
||||
simpleCTClassifierPane.setParams(input.chi2ThresholdParams);
|
||||
idiPane.setParams(input);
|
||||
// simpleCTClassifierPane.setParams(input.chi2ThresholdParams);
|
||||
// idiPane.setParams(input);
|
||||
spectrumTemplatePane.setSpectrum(input.spectrumTemplate);
|
||||
spectrumthreshold.setValue(input.corrThreshold);
|
||||
}
|
||||
|
@ -85,6 +85,7 @@ public class TemplateSpectrumPane extends PamBorderPane {
|
||||
templateDisplay.setDataInfo(templateSpectrumInfo=new TemplateDDDataInfo(templateDisplay, 192000));
|
||||
templateDisplay.setPrefHeight(prefHeight);
|
||||
templateDisplay.setMaxHeight(prefHeight);
|
||||
//templateDisplay.setPrefWidth(500); //TODO - need to make this span the whole display...
|
||||
|
||||
templateDisplay.getDataTypePane().notifyDataChange(); //need this to initialise options pane for different plots.
|
||||
|
||||
@ -111,17 +112,28 @@ public class TemplateSpectrumPane extends PamBorderPane {
|
||||
splitMenuButtonReject.setTranslateX(-20);
|
||||
|
||||
detectionPlot.setMouseTransparent(true);
|
||||
detectionPlot.setMaxWidth(Double.MAX_VALUE);
|
||||
|
||||
StackPane stackPane = new StackPane();
|
||||
stackPane.getChildren().add(detectionPlot);
|
||||
stackPane.getChildren().add(splitMenuButtonReject);
|
||||
stackPane.setPrefHeight(prefHeight);
|
||||
stackPane.setMaxHeight(prefHeight);
|
||||
stackPane.setMaxWidth(Double.MAX_VALUE);
|
||||
stackPane.setPrefWidth(500); //need this for some reason to make the plot resize.
|
||||
|
||||
//stackPane.setStyle("-fx-background-color: red;");
|
||||
|
||||
detectionPlot.prefWidthProperty().bind(stackPane.widthProperty());
|
||||
|
||||
|
||||
PamVBox holder = new PamVBox();
|
||||
holder.setSpacing(5);
|
||||
holder.getChildren().addAll(stackPane);
|
||||
holder.setMaxWidth(Double.MAX_VALUE);
|
||||
|
||||
//holder.setStyle("-fx-background-color: green;");
|
||||
|
||||
|
||||
holder.setPadding(new Insets(10,5,5,5));
|
||||
|
||||
|
@ -5,7 +5,7 @@ import clickTrainDetector.clickTrainAlgorithms.mht.mhtvar.SimpleChi2VarParams;
|
||||
|
||||
/**
|
||||
* The IDI Chi2 Pane.
|
||||
* @author au671271
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class IDIChi2Pane extends SimpleMHTVarPane {
|
||||
|
@ -20,5 +20,11 @@ public class CPODProcess extends PamProcess {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getSampleRate() {
|
||||
return CPODClickDataBlock.CPOD_SR;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class CPODTDSettingsPane implements TDSettingsPane {
|
||||
public CPODTDSettingsPane(CPODPlotInfoFX cpodPlotInfoFX) {
|
||||
this.cpodPlotInfoFX=cpodPlotInfoFX;
|
||||
mainPane = createMainPane();
|
||||
mainPane.setPrefWidth(300);
|
||||
mainPane.setPrefWidth(330);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,6 +63,10 @@ public class OverlayGroupDisplay extends PamBorderPane {
|
||||
*/
|
||||
private boolean hasSuper = false;
|
||||
|
||||
private DisplayTab detectionsTab;
|
||||
|
||||
private DisplayTab suprDetTab;
|
||||
|
||||
/**
|
||||
* Constructor for the group detection display.
|
||||
*/
|
||||
@ -74,6 +78,15 @@ public class OverlayGroupDisplay extends PamBorderPane {
|
||||
superDetectionsDisplay = new DetectionGroupDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current number of detection plots that are available to dsiplay the currently set
|
||||
* data units.
|
||||
* @return the number of deteciton plots. Will be zero if the data cannot be displayed.
|
||||
*/
|
||||
public int getDetectionPlotCount() {
|
||||
if (detectionsPane.getDetectionDisplay().getCurrentDataInfo()==null) return 0;
|
||||
return detectionsPane.getDetectionDisplay().getCurrentDataInfo().getDetectionPlotCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Layout the pane.
|
||||
@ -83,6 +96,8 @@ public class OverlayGroupDisplay extends PamBorderPane {
|
||||
this.setCenter(null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (hasSuperDetectionDisplay()) {
|
||||
hasSuper=true;
|
||||
//need to redo this to prevent duplicate children issues...
|
||||
@ -100,11 +115,10 @@ public class OverlayGroupDisplay extends PamBorderPane {
|
||||
tabPane.addEventHandler(EventType.ROOT, event -> this.fireEvent(event));
|
||||
// tabPane.setPickOnBounds(false);
|
||||
|
||||
Tab tab;
|
||||
tabPane.getTabs().add(tab = new DisplayTab("Data Units", detectionsPane));
|
||||
tab.setClosable(false);
|
||||
tabPane.getTabs().add(tab = new DisplayTab("Super Detection", superDetectionsDisplay));
|
||||
tab.setClosable(false);
|
||||
tabPane.getTabs().add(detectionsTab = new DisplayTab("Data Units", detectionsPane));
|
||||
detectionsTab.setClosable(false);
|
||||
tabPane.getTabs().add(suprDetTab = new DisplayTab("Super Detection", superDetectionsDisplay));
|
||||
suprDetTab.setClosable(false);
|
||||
|
||||
tabPane.getSelectionModel().selectedItemProperty().addListener((obs, oldTab, newTab)->{
|
||||
DetectionGroupDisplay display = ((DisplayTab) newTab).getDetGroupDisplay();
|
||||
@ -112,11 +126,22 @@ public class OverlayGroupDisplay extends PamBorderPane {
|
||||
});
|
||||
|
||||
this.setCenter(tabPane);
|
||||
|
||||
//might have detections which cannot be individually shown but summaries are shown in super display.
|
||||
if (getDetectionPlotCount()<1) {
|
||||
detectionsTab.setDisable(true);
|
||||
tabPane.getSelectionModel().select(1);
|
||||
}
|
||||
else {
|
||||
detectionsTab.setDisable(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
hasSuper=false;
|
||||
this.setCenter(detectionsPane);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,7 +173,7 @@ public class OverlayGroupDisplay extends PamBorderPane {
|
||||
* can be displayed on a graph.
|
||||
* @return true if super detection graph exists.
|
||||
*/
|
||||
private boolean hasSuperDetectionDisplay() {
|
||||
public boolean hasSuperDetectionDisplay() {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
HashSet<SuperDetection> dataUnitSet = getUniqueSuperDetections();
|
||||
@ -226,10 +251,12 @@ public class OverlayGroupDisplay extends PamBorderPane {
|
||||
// Debug.out.println("Super list size: " + superDets);
|
||||
|
||||
this.detectionsPane.setDetectionGroup(dataList);
|
||||
|
||||
|
||||
|
||||
if (superDets!=null) {
|
||||
this.superDetectionsDisplay.setDetectionGroup(new ArrayList<PamDataUnit>(superDets));
|
||||
}
|
||||
|
||||
this.prepareDisplay();
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,8 @@ import javafx.geometry.Side;
|
||||
import javafx.scene.control.Control;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Labeled;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.ScrollPane.ScrollBarPolicy;
|
||||
import javafx.scene.control.Separator;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.control.Tooltip;
|
||||
@ -371,6 +373,9 @@ public class TDMenuPane extends PamBorderPane {
|
||||
PamVBox menuPane= new PamVBox();
|
||||
Control menuButton;
|
||||
|
||||
//menu pane with options form other modules e.g. click event marking
|
||||
PamVBox externalMenuPane= new PamVBox();
|
||||
|
||||
for (int i=0; i<menuNodes.size(); i++){
|
||||
if (menuNodes.get(i).getFlag()==OverlayMenuItem.NO_GROUP){
|
||||
// int row=(int) Math.floor(i/3);
|
||||
@ -379,10 +384,18 @@ public class TDMenuPane extends PamBorderPane {
|
||||
menuButton=overlayItme.menuAction(detectionGroup, detectionGroup==null ? 0 : detectionGroup.getDataList().indexOf(currentDataUnit),
|
||||
overlayMarker==null ? null:overlayMarker.getCurrentMark());
|
||||
//just add the node
|
||||
menuPane.getChildren().add(menuButton);
|
||||
externalMenuPane.getChildren().add(menuButton);
|
||||
styleButton(menuButton, OverlayMenuItem.buttonWidthStandard);
|
||||
}
|
||||
}
|
||||
|
||||
ScrollPane scrollPane = new ScrollPane(externalMenuPane);
|
||||
scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER);
|
||||
scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
|
||||
scrollPane.setPrefHeight(200);
|
||||
|
||||
menuPane.getChildren().add(scrollPane);
|
||||
|
||||
|
||||
//add data info specific stuff.
|
||||
menuPane.getChildren().add(createDataInfoSpecificGroup(detectionGroup, menuNodes));
|
||||
@ -547,13 +560,16 @@ public class TDMenuPane extends PamBorderPane {
|
||||
Debug.out.println("TDMenuPane: Detection Group NO raw wav data");
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if (this.groupDetectionDisplay.getDetectionPlotCount()<1 && !groupDetectionDisplay.hasSuperDetectionDisplay()) {
|
||||
//Debug.out.println("TDMenuPane: Detection Group Summary is NULL");
|
||||
//if there is raw data then we can show that!
|
||||
//this.toggle.setDisable(true);
|
||||
//showDetDisplay=false;
|
||||
this.toggle.setDisable(true);
|
||||
showDetDisplay=false;
|
||||
}
|
||||
|
||||
else {
|
||||
//nothing to do here as everything is fine.
|
||||
}
|
||||
|
||||
prepareDisplay();
|
||||
layoutPane(showDetDisplay);
|
||||
}
|
||||
|
@ -191,14 +191,26 @@ public class TDAcousticScroller extends AcousticScrollerFX implements PamSetting
|
||||
* only the visible range. However in real time mode we want it to set the visible time and
|
||||
* the data keep time.
|
||||
*/
|
||||
if (newVal<=this.getRangeMillis() || !isViewer) {
|
||||
// Debug.out.println("TDAcousticScroller: TimeRangeSpinner: " + newVal);
|
||||
if (newVal<=this.getRangeMillis()) {
|
||||
//System.out.println("TDAcousticScroller: TimeRangeSpinner: " + newVal);
|
||||
//Debug.out.println("TDAcousticScroller: TimeRangeSpinner: " + newVal);
|
||||
Platform.runLater(()->{ //why? But seems necessary
|
||||
super.setVisibleMillis(newVal);
|
||||
super.setRangeMillis(0, newVal, false);
|
||||
});
|
||||
}
|
||||
else spinner.getValueFactory().decrement(1); //need to use decrement here instead of set time because otherwise arrow buttons
|
||||
else {
|
||||
//in real time mode set the range of the display too -otherwise the spinner will max
|
||||
//max out and the user will not be able to make the visible time larger,
|
||||
if (!isViewer) {
|
||||
Platform.runLater(()->{
|
||||
super.setRangeMillis(0, newVal, false); //in real time mode just make the display larger.
|
||||
super.setVisibleMillis(newVal);
|
||||
});
|
||||
}
|
||||
else {
|
||||
spinner.getValueFactory().decrement(1); //need to use decrement here instead of set time becuase spinners with custom numbers are weird
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import PamUtils.PamUtils;
|
||||
import PamUtils.complex.ComplexArray;
|
||||
import PamguardMVC.DataUnit2D;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import PamguardMVC.RawDataHolder;
|
||||
import PamguardMVC.debug.Debug;
|
||||
import clickDetector.ClickDetection;
|
||||
import detectionPlotFX.layout.DetectionPlotDisplay;
|
||||
@ -211,16 +212,40 @@ public class WaterfallSpecPlot<D extends DetectionGroupDataUnit> extends RawFFTP
|
||||
*/
|
||||
public DataUnit2D getFFTdata(PamDataUnit dataUnit, int fftLen, int channel) {
|
||||
//data units will be clicks
|
||||
if (dataUnit instanceof ClickDetection) {
|
||||
ComplexArray fftData = ((ClickDetection) dataUnit).getComplexSpectrum(channel, fftLen);
|
||||
|
||||
SimpleFFTDataUnit fftDataUnit = new SimpleFFTDataUnit(dataUnit.getTimeMilliseconds(),
|
||||
PamUtils.makeChannelMap(channel), dataUnit.getStartSample(),
|
||||
fftLen, fftData, 0, dataUnit.getParentDataBlock().getSampleRate());
|
||||
|
||||
return fftDataUnit;
|
||||
ComplexArray fftData;
|
||||
if (dataUnit instanceof RawDataHolder) {
|
||||
fftData = ((RawDataHolder) dataUnit).getDataTransforms().getComplexSpectrum(channel, fftLen);
|
||||
}
|
||||
return null;
|
||||
else {
|
||||
//used for example, in CPOD data.
|
||||
double[] realData = new double[fftLen/2];
|
||||
double[] imagData = new double[fftLen/2]; //no phase info for this - just keep it all zeros.
|
||||
|
||||
//if there is no FFT data then just use the frequency limits.
|
||||
|
||||
double amplitudebin = dataUnit.getAmplitudeDB()/(dataUnit.getFrequency()[1]-dataUnit.getFrequency()[0]);
|
||||
|
||||
double minFreqBin;
|
||||
double maxFreqBin;
|
||||
for (int i= 0; i <realData.length; i++) {
|
||||
minFreqBin = (i/(double) realData.length)*(dataUnit.getParentDataBlock().getSampleRate()/2);
|
||||
maxFreqBin = (i/(double) realData.length)*(dataUnit.getParentDataBlock().getSampleRate()/2);
|
||||
|
||||
if (minFreqBin > dataUnit.getFrequency()[0] && maxFreqBin<=dataUnit.getFrequency()[1]) {
|
||||
realData[i]+=amplitudebin;
|
||||
|
||||
//System.out.println("real data amplitude bin: " + realData[i]);
|
||||
}
|
||||
}
|
||||
|
||||
fftData = new ComplexArray(realData, imagData);
|
||||
|
||||
}
|
||||
|
||||
SimpleFFTDataUnit fftDataUnit = new SimpleFFTDataUnit(dataUnit.getTimeMilliseconds(),
|
||||
PamUtils.makeChannelMap(channel), dataUnit.getStartSample(),
|
||||
fftLen, fftData, 0, dataUnit.getParentDataBlock().getSampleRate());
|
||||
return fftDataUnit;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -131,7 +131,7 @@ public abstract class DDDataInfo<T extends PamDataUnit> {
|
||||
|
||||
|
||||
/**
|
||||
* Get the sample rate. This is aquired form the datablock if one exists. Otherwise a hard
|
||||
* Get the sample rate. This is acquired form the datablock if one exists. Otherwise a hard
|
||||
* wired sample rate is used.
|
||||
* @return the sample rate.
|
||||
*/
|
||||
@ -283,7 +283,6 @@ public abstract class DDDataInfo<T extends PamDataUnit> {
|
||||
|
||||
|
||||
public void setupAxis( DetectionPlotProjector projector, T pamDataUnit){
|
||||
|
||||
getCurrentDetectionPlot().setupAxis((PamDataUnit) pamDataUnit, this.getHardSampleRate(), projector);
|
||||
}
|
||||
|
||||
|
@ -387,26 +387,33 @@ public abstract class RawFFTPlot<D extends PamDataUnit> extends FFTPlot<D> {
|
||||
int iChannel = this.getParentDataBlock().getARealChannel(PamUtils.getSingleChannel(getChannelBitmap()));
|
||||
|
||||
// get the acquisition process.
|
||||
try {
|
||||
//TODO- need to pick correct data block
|
||||
// try {
|
||||
// //TODO- need to pick correct data block
|
||||
if (PamController.getInstance().getRawDataBlock(0)!=null) {
|
||||
daqProcess = (AcquisitionProcess) PamController.getInstance().getRawDataBlock(0).getSourceProcess();
|
||||
daqProcess.prepareFastAmplitudeCalculation(iChannel);
|
||||
// }
|
||||
// catch (ClassCastException e) {
|
||||
// e.printStackTrace();
|
||||
// return magSqData;
|
||||
// }
|
||||
|
||||
magSqData = fftData.magsq();
|
||||
|
||||
// System.out.println("Magnitude squared length is: " + magSqData.length + " "+ magSqData[0]);
|
||||
|
||||
for (int i = 0; i < magSqData.length; i++) {
|
||||
magSqData[i] = daqProcess.fftAmplitude2dB(magSqData[i], iChannel,
|
||||
sR, magSqData.length*2, true, false);
|
||||
}
|
||||
|
||||
// System.out.println("Magnitude squared length is: " + magSqData.length + " "+ magSqData[0]);
|
||||
|
||||
} else {
|
||||
for (int i = 0; i < magSqData.length; i++) {
|
||||
magSqData[i] = 20*Math.log10(magSqData[i]) + 175; //Guess
|
||||
}
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
e.printStackTrace();
|
||||
return magSqData;
|
||||
}
|
||||
|
||||
magSqData = fftData.magsq();
|
||||
|
||||
// System.out.println("Magnitude squared length is: " + magSqData.length + " "+ magSqData[0]);
|
||||
|
||||
for (int i = 0; i < magSqData.length; i++) {
|
||||
magSqData[i] = daqProcess.fftAmplitude2dB(magSqData[i], iChannel,
|
||||
sR, magSqData.length*2, true, false);
|
||||
}
|
||||
|
||||
// System.out.println("Magnitude squared length is: " + magSqData.length + " "+ magSqData[0]);
|
||||
|
||||
//normalise data (used in subclasses for weird spectrograms)
|
||||
//Debug.out.println("Max amplitude squared is: " + PamArrayUtils.max(magSqData));
|
||||
|
@ -35,7 +35,6 @@ import matchedTemplateClassifer.ImportTemplateMAT;
|
||||
import matchedTemplateClassifer.MTClassifier;
|
||||
import matchedTemplateClassifer.MTClassifierControl;
|
||||
import matchedTemplateClassifer.MatchTemplate;
|
||||
import matchedTemplateClassifer.MatchedTemplateParams;
|
||||
import matchedTemplateClassifer.TemplateImport;
|
||||
import pamViewFX.PamGuiManagerFX;
|
||||
import pamViewFX.fxGlyphs.PamGlyphDude;
|
||||
|
@ -154,7 +154,8 @@ public class ColorComboBox extends ComboBox<String>{
|
||||
* @param freqColourArray - the colour array vlaue to set the combo box to.
|
||||
*/
|
||||
public void setValue(ColourArrayType freqColourArray) {
|
||||
this.setValue(ColourArray.getName(freqColourArray));
|
||||
this.getSelectionModel().select(ColourArray.getName(freqColourArray));
|
||||
//this.setValue(ColourArray.getName(freqColourArray));
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@ import pamViewFX.fxNodes.PamSpinner;
|
||||
import pamViewFX.fxNodes.PamVBox;
|
||||
import pamViewFX.fxNodes.comboBox.ColorComboBox;
|
||||
import pamViewFX.fxNodes.utilsFX.ColourArray;
|
||||
import pamViewFX.fxNodes.utilsFX.ColourArray.ColourArrayType;
|
||||
|
||||
/**
|
||||
* Option pane for the PeakFreqSymbolChooser. Allows users to change the max and min frequency and
|
||||
@ -129,12 +130,16 @@ public class PeakFreqOptionsPane extends StandardSymbolModifierPane {
|
||||
// PeakFreqSymbolOptions symbolOptions = (PeakFreqSymbolOptions) standardSymbolOptions.getModifierParams(this.getSymbolModifier().getName());
|
||||
|
||||
PeakFreqSymbolOptions symbolOptions = (PeakFreqSymbolOptions) this.getSymbolModifier().getSymbolModifierParams();
|
||||
if (initialised) {
|
||||
if (initialised && !setParams) {
|
||||
//must make sure we do not call get parameters during a set parameters - the listeners on the controls call getParams so all goes
|
||||
//haywire if the setParams is not set properly.
|
||||
//System.out.println("GETPARAMS: " + ColourArray.getColorArrayType(this.colourBox.getSelectionModel().getSelectedItem()) + " " + setParams);
|
||||
symbolOptions.freqLimts=new double[] {minFreq.getValue(), maxFreq.getValue()};
|
||||
symbolOptions.freqColourArray = ColourArray.getColorArrayType(this.colourBox.getSelectionModel().getSelectedItem());
|
||||
|
||||
}
|
||||
|
||||
((PeakFreqModifier) this.getSymbolModifier()).checkColourArray();
|
||||
|
||||
//System.out.println("StandardSymbolModifierPane : getParams(): new mod: " +mod);
|
||||
|
||||
return standardSymbolOptions;
|
||||
@ -145,23 +150,24 @@ public class PeakFreqOptionsPane extends StandardSymbolModifierPane {
|
||||
public void setParams() {
|
||||
|
||||
if (initialised) {
|
||||
setParams = true;
|
||||
|
||||
super.setParams();
|
||||
|
||||
//important to have here because the super.setParams set this bak to false.
|
||||
setParams = true;
|
||||
|
||||
// StandardSymbolOptions standardSymbolOptions = (StandardSymbolOptions) getSymbolModifier().getSymbolChooser().getSymbolOptions();
|
||||
// PeakFreqSymbolOptions symbolOptions = (PeakFreqSymbolOptions) standardSymbolOptions.getModifierParams(this.getSymbolModifier().getName());
|
||||
PeakFreqSymbolOptions symbolOptions = (PeakFreqSymbolOptions) this.getSymbolModifier().getSymbolModifierParams();
|
||||
|
||||
//now set frequency params;
|
||||
//now set frequency parameters;
|
||||
checkFreqLimits( symbolOptions ) ;
|
||||
minFreq.getValueFactory().setValue(symbolOptions.freqLimts[0]);
|
||||
maxFreq.getValueFactory().setValue(symbolOptions.freqLimts[1]);
|
||||
|
||||
colourBox.setValue(symbolOptions.freqColourArray);
|
||||
|
||||
|
||||
setParams = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user