mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 08:32:32 +00:00
Updates and bug fixes to click train detector and CPOD importer
This commit is contained in:
parent
fa52548746
commit
941737a7ab
@ -158,7 +158,7 @@ public class CTClassifierManager {
|
||||
//first check the pre-classifier
|
||||
Chi2CTClassification classification = this.preClassifier.classifyClickTrain(ctDataUnit);
|
||||
|
||||
Debug.out.println("Pre classifier: " + PamCalendar.formatDateTime(ctDataUnit.getTimeMilliseconds()) + " N. " + ctDataUnit.getSubDetectionsCount() + "UID first: " + ctDataUnit.getSubDetection(0).getUID() );
|
||||
System.out.println("Pre classifier: " + PamCalendar.formatDateTime(ctDataUnit.getTimeMilliseconds()) + " N. " + ctDataUnit.getSubDetectionsCount() + "UID first: " + ctDataUnit.getSubDetection(0).getUID() );
|
||||
|
||||
if (classification.getSpeciesID()==CTClassifier.NOSPECIES) {
|
||||
System.out.println("No SPECIES: chi^2" + ctDataUnit.getCTChi2());
|
||||
@ -189,12 +189,18 @@ public class CTClassifierManager {
|
||||
ctDataUnit.clearClassifiers();
|
||||
ctDataUnit.setClassificationIndex(-1);
|
||||
|
||||
System.out.println("Classify species: Num classifier " + this.cTClassifiers.size());
|
||||
|
||||
for (int i=0; i<clickTrainControl.getCurrentClassifiers().size(); i++) {
|
||||
for (int i=0; i<this.cTClassifiers.size(); i++) {
|
||||
|
||||
|
||||
System.out.println("Classifier: " + i);
|
||||
|
||||
//the first classifier
|
||||
ctclassification = clickTrainControl.getCurrentClassifiers().get(i).classifyClickTrain(ctDataUnit);
|
||||
ctclassification = this.cTClassifiers.get(i).classifyClickTrain(ctDataUnit);
|
||||
|
||||
System.out.println("Classifier complete: SPECIES: " + ctclassification.getSpeciesID());
|
||||
|
||||
|
||||
// Debug.out.println(i + " ClassifierManager: Classify a click train data unit: " + ctDataUnit + " parent data block: " +
|
||||
// " " + ctDataUnit.getnSubDetections());
|
||||
@ -202,6 +208,7 @@ public class CTClassifierManager {
|
||||
|
||||
//set the species flag but only if this is the first time the ct data unit has been classified.
|
||||
if (ctclassification.getSpeciesID()>CTClassifier.NOSPECIES && !hasBeenClssfd) {
|
||||
System.out.println("Set classiifcation index: " + i);
|
||||
ctDataUnit.setClassificationIndex(i); //set the classification index.
|
||||
hasBeenClssfd = true;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class CTClassifierParams implements Cloneable, Serializable, ManagedParam
|
||||
public int speciesFlag = 1;
|
||||
|
||||
/**
|
||||
* Easy way to know which classifier the parameter class belong to rather than big instancof statement
|
||||
* Easy way to know which classifier the parameter class belong to rather than big instance of statement
|
||||
*/
|
||||
public CTClassifierType type;
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class IDIClassification implements CTClassification {
|
||||
|
||||
@Override
|
||||
public String getSummaryString() {
|
||||
return String.format("IDI Classifier: Mean IDI %.4f\u00B0/s Median IDI %.4f\u00B0/s Std IDI%.4f\u00B0/s",
|
||||
return String.format("IDI Classifier: Mean IDI %.5fs Median IDI %.5fs Std IDI%.5fs",
|
||||
meanIDI, medianIDI, stdIDI);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,13 @@ public class IDIClassifier implements CTClassifier {
|
||||
//check IDI classification is passed
|
||||
boolean passesIDI = checkIDIMeasurements(clickTrain);
|
||||
|
||||
return null;
|
||||
int speciesID = CTClassifier.NOSPECIES;
|
||||
if (passesIDI) {
|
||||
speciesID = idiParams.speciesFlag;
|
||||
}
|
||||
|
||||
return new IDIClassification( speciesID, clickTrain.getIDIInfo().medianIDI, clickTrain.getIDIInfo().meanIDI, clickTrain.getIDIInfo().stdIDI);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,7 +50,7 @@ public class Chi2CTClassification implements CTClassification {
|
||||
|
||||
@Override
|
||||
public String getSummaryString() {
|
||||
return "Simple X\u00b2 Clssfr: Species ID: " + this.getSpeciesID();
|
||||
return "X\u00b2 Clssfr: Species ID: " + this.getSpeciesID();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,10 +1,8 @@
|
||||
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
|
||||
@ -14,12 +12,6 @@ import clickTrainDetector.classification.bearingClassifier.BearingClassifierJSON
|
||||
*/
|
||||
public class StandardClassification implements CTClassification {
|
||||
|
||||
/**
|
||||
* Reference to the click control.
|
||||
*/
|
||||
private ClickTrainControl clickTrainControl;
|
||||
|
||||
|
||||
/**
|
||||
* The current species ID.
|
||||
*/
|
||||
@ -31,17 +23,16 @@ public class StandardClassification implements CTClassification {
|
||||
private CTClassification[] ctClassifications;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Standard classifier JSON logging.
|
||||
*/
|
||||
private StandardClassificationJSON standardClassifierJSONLogging;
|
||||
|
||||
|
||||
public StandardClassification(ClickTrainControl clickTrainControl, CTClassification[] ctClassifications, int speciesID) {
|
||||
this.clickTrainControl=clickTrainControl;
|
||||
public StandardClassification(CTClassification[] ctClassifications, int speciesID) {
|
||||
this.ctClassifications=ctClassifications;
|
||||
standardClassifierJSONLogging = new StandardClassificationJSON();
|
||||
standardClassifierJSONLogging = new StandardClassificationJSON(ctClassifications);
|
||||
this.speciesID=speciesID;
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,63 @@
|
||||
package clickTrainDetector.classification.standardClassifier;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import clickTrainDetector.classification.CTClassification;
|
||||
import clickTrainDetector.classification.SimpleClassifierJSONLogging;
|
||||
|
||||
|
||||
/**
|
||||
* Standard classification JSON logging
|
||||
*
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class StandardClassificationJSON extends SimpleClassifierJSONLogging {
|
||||
|
||||
private CTClassification[] standardClassifier;
|
||||
|
||||
/**
|
||||
* Create the JSON logging for standard classifier.
|
||||
* @param ctClassifications - the standard classifier.
|
||||
*/
|
||||
public StandardClassificationJSON(CTClassification[] ctClassifications) {
|
||||
this.standardClassifier=ctClassifications;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeJSONData(JsonGenerator jg, CTClassification ctClassification) {
|
||||
for (int i=0; i<standardClassifier.length; i++) {
|
||||
((SimpleClassifierJSONLogging) standardClassifier[i].getJSONLogging()).writeJSONData(jg, standardClassifier[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CTClassification createClassification(JsonNode jTree) {
|
||||
|
||||
JsonNode na = jTree.findValue("SPECIES");
|
||||
int speciesID;
|
||||
if (na != null ) {
|
||||
speciesID = na.asInt();
|
||||
}
|
||||
else {
|
||||
System.err.println("Cannot load template classifier");
|
||||
return null;
|
||||
}
|
||||
|
||||
CTClassification[] ctClassification = new CTClassification[standardClassifier.length];
|
||||
for (int i=0; i<standardClassifier.length; i++) {
|
||||
ctClassification[i] = ((SimpleClassifierJSONLogging) standardClassifier[i].getJSONLogging()).createClassification(jTree);
|
||||
}
|
||||
|
||||
StandardClassification stClassification =
|
||||
new StandardClassification(ctClassification, speciesID);
|
||||
|
||||
return stClassification;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -25,6 +25,12 @@ import clickTrainDetector.layout.classification.standardClassifier.StandardClass
|
||||
*/
|
||||
public class StandardClassifier implements CTClassifier {
|
||||
|
||||
/**
|
||||
* It's quite complicated to keep track of the species ID for all sub classifier but just set them
|
||||
* to 1 to check whether the classifier has passed or not,
|
||||
*/
|
||||
public int SUB_CLASSIFIER_SPECIESID = 1;
|
||||
|
||||
/**
|
||||
* The bearing classifier parameters.
|
||||
*/
|
||||
@ -52,7 +58,6 @@ public class StandardClassifier implements CTClassifier {
|
||||
|
||||
//load the settings
|
||||
createClassifiers();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,13 +66,13 @@ public class StandardClassifier implements CTClassifier {
|
||||
private void createClassifiers() {
|
||||
classifiers = new ArrayList<CTClassifier>();
|
||||
|
||||
classifiers.add(new Chi2ThresholdClassifier(clickTrainControl, standardClssfrParams.speciesFlag));
|
||||
classifiers.add(new Chi2ThresholdClassifier(clickTrainControl, SUB_CLASSIFIER_SPECIESID));
|
||||
|
||||
classifiers.add(new IDIClassifier(clickTrainControl, standardClssfrParams.speciesFlag));
|
||||
classifiers.add(new IDIClassifier(clickTrainControl,SUB_CLASSIFIER_SPECIESID));
|
||||
|
||||
classifiers.add(new CTTemplateClassifier(clickTrainControl, standardClssfrParams.speciesFlag));
|
||||
classifiers.add(new CTTemplateClassifier(clickTrainControl, SUB_CLASSIFIER_SPECIESID));
|
||||
|
||||
classifiers.add(new BearingClassifier(clickTrainControl, standardClssfrParams.speciesFlag));
|
||||
classifiers.add(new BearingClassifier(clickTrainControl, SUB_CLASSIFIER_SPECIESID));
|
||||
|
||||
setClassifierParams();
|
||||
}
|
||||
@ -101,11 +106,32 @@ public class StandardClassifier implements CTClassifier {
|
||||
@Override
|
||||
public CTClassification classifyClickTrain(CTDataUnit clickTrain) {
|
||||
|
||||
int speciesID = standardClssfrParams.speciesFlag;
|
||||
|
||||
//all classifiers have to pass.
|
||||
|
||||
System.out.println("Standard Classificiation: " );
|
||||
|
||||
return null;
|
||||
//all classifiers have to pass.
|
||||
CTClassification[] ctClassification = new CTClassification[classifiers.size()];
|
||||
for (int i=0; i<classifiers.size(); i++) {
|
||||
|
||||
ctClassification[i] = classifiers.get(i).classifyClickTrain(clickTrain);
|
||||
|
||||
System.out.println("Standard Classificiation: " + i + " speciesID: " + ctClassification[i].getSpeciesID()
|
||||
+ " sub species: "+ classifiers.get(i).getParams().speciesFlag + " standard species: " +speciesID + " use? : " + standardClssfrParams.enable[i]);
|
||||
|
||||
if (standardClssfrParams.enable[i]) {
|
||||
if (ctClassification[i].getSpeciesID() != SUB_CLASSIFIER_SPECIESID){
|
||||
speciesID = CTClassifier.NOSPECIES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("SPECIES ID: " + speciesID);
|
||||
|
||||
//create the classification.
|
||||
StandardClassification classification = new StandardClassification(ctClassification, speciesID);
|
||||
|
||||
return classification;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,7 @@
|
||||
package clickTrainDetector.classification.standardClassifier;
|
||||
|
||||
import clickTrainDetector.classification.CTClassifierParams;
|
||||
import clickTrainDetector.classification.CTClassifierType;
|
||||
|
||||
|
||||
/**
|
||||
@ -24,6 +25,14 @@ public class StandardClassifierParams extends CTClassifierParams {
|
||||
*/
|
||||
public boolean[] enable;
|
||||
|
||||
|
||||
public StandardClassifierParams(){
|
||||
///very important to set this or else the clasifier manager does not
|
||||
//know which classifier to create.
|
||||
type = CTClassifierType.STANDARDCLASSIFIER;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// /**
|
||||
// * Standard classifier parameters.
|
||||
|
@ -66,10 +66,9 @@ public class MHTClassifierMAT {
|
||||
classification = cTClassifiers.get(i).classifyClickTrain(dataUnit);
|
||||
dataUnit.addCtClassification(classification);
|
||||
|
||||
// System.out.println("Classification " + classification.getSpeciesID() + " speciesID " + cTClassifiers.get(i).getSpeciesID());
|
||||
System.out.println("Classification " + classification.getSpeciesID() + " speciesID " + cTClassifiers.get(i).getSpeciesID());
|
||||
|
||||
if (classification.getSpeciesID()>CTClassifier.NOSPECIES && !hasBeenClssfd) {
|
||||
// System.out.println("Set classiifcation index: " + i);
|
||||
dataUnit.setClassificationIndex(i); //set the classification index.
|
||||
hasBeenClssfd = true;
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ public class StandardClassifierPane extends SettingsPane<StandardClassifierPara
|
||||
|
||||
private PamToggleSwitch[] enableSwitch;
|
||||
|
||||
private Label[] labels;
|
||||
|
||||
public StandardClassifierPane(StandardClassifier standardClassifier) {
|
||||
super(null);
|
||||
this.standardClassifier = standardClassifier;
|
||||
@ -37,32 +39,36 @@ public class StandardClassifierPane extends SettingsPane<StandardClassifierPara
|
||||
PamVBox vBox = new PamVBox();
|
||||
vBox.setSpacing(5);
|
||||
|
||||
labels = new Label[standardClassifier.getClassifiers().size()];
|
||||
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);
|
||||
labels[i] = new Label(standardClassifier.getClassifiers().get(i).getName());
|
||||
PamGuiManagerFX.titleFont2style(labels[i]);
|
||||
|
||||
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());
|
||||
labels[ii].setDisable(!enableSwitch[ii].isSelected());
|
||||
});
|
||||
|
||||
PamHBox hBox = new PamHBox();
|
||||
hBox.setSpacing(5);
|
||||
|
||||
hBox.getChildren().addAll(enableSwitch[i], label);
|
||||
hBox.getChildren().addAll(enableSwitch[i], labels[i]);
|
||||
|
||||
|
||||
|
||||
vBox.getChildren().addAll(hBox, standardClassifier.getClassifiers().get(i).getCTClassifierGraphics().getCTClassifierPane());
|
||||
}
|
||||
|
||||
return vBox;
|
||||
}
|
||||
|
||||
private void disableClassifierPane(int ii) {
|
||||
standardClassifier.getClassifiers().get(ii).getCTClassifierGraphics().getCTClassifierPane().setDisable(!enableSwitch[ii].isSelected());
|
||||
labels[ii].setDisable(!enableSwitch[ii].isSelected());
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardClassifierParams getParams(StandardClassifierParams currParams) {
|
||||
@ -78,6 +84,7 @@ public class StandardClassifierPane extends SettingsPane<StandardClassifierPara
|
||||
for (int i=0; i<standardClassifier.getClassifiers().size(); i++) {
|
||||
standardClassifier.getClassifiers().get(i).getCTClassifierGraphics().setParams(input.ctClassifierParams[i]);
|
||||
enableSwitch[i].setSelected(input.enable[i]);
|
||||
disableClassifierPane(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,10 +402,15 @@ public class CPODSettingsPane extends SettingsPane<CPODParams> {
|
||||
|
||||
//have a look through the files and check that there are some files to import.
|
||||
for (int i=0; i<CPODFileType.values().length; i++) {
|
||||
try {
|
||||
List<File> cp1 = (List<File>) FileUtils.listFiles(folder,
|
||||
new String[]{CPODFileType.values()[i].getText()}, this.subFolder.isSelected());
|
||||
System.out.println("Files out: " + cp1);
|
||||
files.addAll(cp1);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.err.println("Current directory does not exist: " + folder );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,11 @@
|
||||
package dataPlotsFX.overlaymark.menuOptions.MLExport;
|
||||
|
||||
import com.jmatio.types.MLDouble;
|
||||
import com.jmatio.types.MLInt32;
|
||||
import com.jmatio.types.MLInt64;
|
||||
import com.jmatio.types.MLInt8;
|
||||
import com.jmatio.types.MLStructure;
|
||||
|
||||
import PamUtils.PamUtils;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import clickDetector.ClickDetection;
|
||||
import whistlesAndMoans.ConnectedRegionDataUnit;
|
||||
|
||||
/**
|
||||
* Export a click to a MATLAB structure.
|
||||
|
@ -49,7 +49,7 @@ import pamViewFX.fxStyles.PamStylesManagerFX;
|
||||
*/
|
||||
public class TDMenuPane extends PamBorderPane {
|
||||
|
||||
public static final int menuWidth=200;
|
||||
public static final int MENU_WIDTH=200;
|
||||
|
||||
/**
|
||||
* The current data units.
|
||||
@ -333,10 +333,10 @@ public class TDMenuPane extends PamBorderPane {
|
||||
|
||||
flipPane.getFront().getChildren().add(menuPane);
|
||||
flipPane.getBack().getChildren().add(infoPane);
|
||||
flipPane.setPrefWidth(menuWidth);
|
||||
flipPane.setPrefWidth(MENU_WIDTH);
|
||||
|
||||
PamBorderPane holder = new PamBorderPane(flipPane);
|
||||
holder.setPrefWidth(menuWidth);
|
||||
holder.setPrefWidth(MENU_WIDTH);
|
||||
|
||||
|
||||
return holder;
|
||||
|
Loading…
Reference in New Issue
Block a user