Bug fixes for deep leanring module (#155)

* Update exporter_help.md

Updated help for exporter

* Update .gitignore

* Bug fixes for deep learning classifier.

Updated the symbol options to make sure opacity is passed through the symbol chooser.
This commit is contained in:
Jamie Mac 2024-08-26 17:15:43 +01:00 committed by GitHub
parent cfd42779a1
commit 38671987db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 209 additions and 26 deletions

2
.gitignore vendored
View File

@ -114,3 +114,5 @@ settings.xml
.classpath
.settings/org.eclipse.jdt.core.prefs
.classpath
.settings/org.eclipse.jdt.core.prefs
.classpath

View File

@ -600,7 +600,7 @@ public class PamArrayUtils {
// int count = 0;
float cur;
for(int i=0; i<arr.length; i++) {
for(int j=0; j<arr.length; j++) {
for(int j=0; j<arr[i].length; j++) {
cur = arr[i][j];
if (cur>max) {
index[0]=i;

View File

@ -1,5 +1,6 @@
package PamView.symbol;
import java.awt.Color;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -70,6 +71,11 @@ public class StandardSymbolChooser extends PamSymbolChooser {
if (modifiers == null || modifiers.size() == 0) {
return symbolData;
}
Integer alpha = null;
if (symbolData != null) {
alpha = symbolData.getFillColor().getAlpha();
}
boolean isCloned = false;
@ -97,6 +103,11 @@ public class StandardSymbolChooser extends PamSymbolChooser {
}
symbolData = modifiers.get(ind).modifySymbol(symbolData, projector, dataUnit);
}
if (alpha != null && alpha < 255) {
Color currCol = symbolData.getFillColor();
currCol = new Color(currCol.getRed(), currCol.getGreen(), currCol.getBlue(), alpha);
symbolData.setFillColor(currCol);
}
return symbolData;
}

View File

@ -111,9 +111,11 @@ public class PeakFreqModifier extends SymbolModifier {
}
frequency=(frequency - peakFreqSymbolOptions.freqLimts[0])/(peakFreqSymbolOptions.freqLimts[1]-peakFreqSymbolOptions.freqLimts[0]);
checkColourArray();
Color freqCol = PamUtilsFX.fxToAWTColor(this.colourArray.getColour(frequency));
// System.out.println("Freq colour: " + freqCol.getRed() + " " + freqCol.getGreen() + " " + freqCol.getBlue());

View File

@ -42,6 +42,8 @@ import pamViewFX.fxNodes.PamSymbolFX;
*/
public class GenericDataPlotInfo extends TDDataInfoFX {
public static final double DEFAULT_FILL_OPACITY = 0.3;
/**
* Scale infos to show what axis clicks can be plotted on.
*/
@ -351,5 +353,25 @@ public class GenericDataPlotInfo extends TDDataInfoFX {
}
/**
* Called when the user selects a specific data line
* @param dataLine
*/
@Override
public boolean setCurrentAxisName(ParameterType dataType, ParameterUnits dataUnits) {
setDefaultOpacity(dataType);
return super.setCurrentAxisName(dataType, dataUnits);
}
protected void setDefaultOpacity(ParameterType dataType) {
if (dataType.equals(ParameterType.FREQUENCY)) {
this.genericSettingsPane.setDefaultFillOpacity(DEFAULT_FILL_OPACITY);
}
else {
this.genericSettingsPane.setDefaultFillOpacity(1.0);
}
}
}

View File

@ -170,6 +170,8 @@ public abstract class GenericLinePlotInfo extends TDDataInfoFX {
}
GeneralProjector p = this.getTDGraph().getGraphProjector();
PamSymbolChooser sc = symbolManager.getSymbolChooser(getTDGraph().getUniqueName(), p);
return new TDManagedSymbolChooserFX(this, sc, TDSymbolChooserFX.DRAW_SYMBOLS);
}

View File

@ -16,9 +16,7 @@ import pamViewFX.symbol.StandardSymbolOptionsPane;
/**
* Settings pane which holds the symbol options from the data block of the plot info.
* @author Jamie Macaulay
*
* Settings pane which holds the symbol options from the data block of the plot info. *
*
* @author Jamie Macaulay
*
@ -161,5 +159,15 @@ public class GenericSettingsPane extends PamBorderPane implements TDSettingsPane
return this;
}
/**
* Set the default fill opacity.
* @param opacity - the default fill opacity.
*/
public void setDefaultFillOpacity(double opacity) {
if (symbolOptionsPane instanceof StandardSymbolOptionsPane) {
((StandardSymbolOptionsPane) symbolOptionsPane).getDefaultSymbolPane().setDefaultFillOpacity(opacity);
}
}
}

View File

@ -69,8 +69,7 @@ public class RawClipDataInfo extends GenericDataPlotInfo {
rawWavePlotManager = new RawClipWavePlotManager(this);
clipSettingsPane = new RawClipSettingsPane(this);
clipSettingsPane.setParams();
//create the symbol chooser.
rawSymbolChoosr = new RawClipSymbolChooser(this, pamDataBlock.getPamSymbolManager().getSymbolChooser(tdGraph.getUniqueName(), tdGraph.getGraphProjector()), TDSymbolChooserFX.DRAW_SYMBOLS);
@ -278,6 +277,7 @@ public class RawClipDataInfo extends GenericDataPlotInfo {
return false;
}
/**
* Called whenever settings are updated.
*/
@ -285,6 +285,16 @@ public class RawClipDataInfo extends GenericDataPlotInfo {
// TODO Auto-generated method stub
}
@Override
protected void setDefaultOpacity(ParameterType dataType) {
if (dataType.equals(ParameterType.FREQUENCY)) {
this.clipSettingsPane.setDefaultFillOpacity(DEFAULT_FILL_OPACITY);
}
else {
this.clipSettingsPane.setDefaultFillOpacity(1.0);
}
}

View File

@ -324,5 +324,15 @@ public class RawClipSettingsPane extends PamBorderPane implements TDSettingsPane
public Pane getPane() {
return this;
}
/**
* Set the default fill opacity.
* @param opacity - the default fill opacity.
*/
public void setDefaultFillOpacity(double opacity) {
if (symbolOptionsPane instanceof StandardSymbolOptionsPane) {
((StandardSymbolOptionsPane) symbolOptionsPane).getDefaultSymbolPane().setDefaultFillOpacity(opacity);
}
}
}

View File

@ -355,7 +355,7 @@ public class DetectionPlotDisplay extends PamBorderPane {
* the current data unit.
*/
public void setupScrollBar(PamDataUnit newDataUnit){
System.out.println("SETUP SCROLL BAR:");
// System.out.println("SETUP SCROLL BAR:");
if (currentDataInfo!=null) {
//important we put this here as it allows the plot to set up the scroll bar pane.

View File

@ -93,7 +93,7 @@ public abstract class WaveformPlot<D extends PamDataUnit> implements DetectionPl
*/
@Override
public void setupAxis(D pamDetection, double sR, DetectionPlotProjector plotProjector){
System.out.println("WaveformPlot.setupAxis plotting the waveform: " + getWaveform(pamDetection)[0].length);
//System.out.println("WaveformPlot.setupAxis plotting the waveform: " + getWaveform(pamDetection)[0].length);
//all axis are used in the waveform plot except the right axis.
double[][] waveform=getWaveform(pamDetection);
@ -121,8 +121,8 @@ public abstract class WaveformPlot<D extends PamDataUnit> implements DetectionPl
plotProjector.setAxisMinMax((plotProjector.getAxis(Side.BOTTOM).getMinVal()/1000.)*sR,
(plotProjector.getAxis(Side.BOTTOM).getMaxVal()/1000)*sR, Side.TOP);
System.out.println("WaveformPlot.setupAxis: min " + (plotProjector.getAxis(Side.BOTTOM).getMinVal()/1000.)*sR +
" max: " + (plotProjector.getAxis(Side.BOTTOM).getMaxVal()/1000)*sR);
// System.out.println("WaveformPlot.setupAxis: min " + (plotProjector.getAxis(Side.BOTTOM).getMinVal()/1000.)*sR +
// " max: " + (plotProjector.getAxis(Side.BOTTOM).getMaxVal()/1000)*sR);
// plotProjector.setAxisMinMax(0, (binLength*1000.)/sR, Side.BOTTOM);
@ -185,7 +185,7 @@ public abstract class WaveformPlot<D extends PamDataUnit> implements DetectionPl
* @param projector - the projector
*/
private void forcePaintPlot(D pamDetection, GraphicsContext gc, Rectangle rectangle, DetectionPlotProjector projector){
System.out.println("WaveformPlot.forcePaintPlot:");
// System.out.println("WaveformPlot.forcePaintPlot:");
currentWaveform=getWaveform(pamDetection);
if (currentWaveform==null) return;
@ -260,8 +260,10 @@ public abstract class WaveformPlot<D extends PamDataUnit> implements DetectionPl
if (currentDetection == null || waveform==null || waveform.length==0 || waveform[0]==null)
return;
paintWaveform(waveform, currentDetection.getSequenceBitmap(), g, clipRect, (int) projector.getAxis(Side.TOP).getMinVal(), (int) projector.getAxis(Side.TOP).getMaxVal(),
log2Amplitude, color, !waveformPlotParams.showSperateWaveform || waveform.length==1, waveformPlotParams.invert);
paintWaveform(waveform, currentDetection.getSequenceBitmap(), g, clipRect,
(int) projector.getAxis(Side.TOP).getMinVal(), (int) projector.getAxis(Side.TOP).getMaxVal(),
log2Amplitude, color, !waveformPlotParams.showSperateWaveform || waveform.length == 1,
waveformPlotParams.invert);
}
}
@ -279,7 +281,7 @@ public abstract class WaveformPlot<D extends PamDataUnit> implements DetectionPl
*/
public static void paintWaveform(double[][] waveform, int channelBitMap, GraphicsContext g, Rectangle clipRect,
int minbin, int maxbin, double yScaleInfo, Color color, boolean singlePlot, boolean invert) {
System.out.println("Paint the waveform: " + waveform[0].length);
// System.out.println("Paint the waveform: " + waveform[0].length);
g.setLineWidth(1);
// boolean singlePlot=!waveformPlotParams.showSperateWaveform;

View File

@ -8,6 +8,7 @@ import detectionPlotFX.plots.WaveformPlot;
/**
* Plot for any RawDataHolder to show a waveform.
*
* @author Jamie Macaulay
*
*/
@ -38,7 +39,7 @@ public class RawWaveformPlot extends WaveformPlot<PamDataUnit>{
@Override
public String getName() {
return "Click Waveform";
return "Waveform";
}
@Override

View File

@ -7,7 +7,7 @@ The PAMGuard exporter allows users to export PAMGuard data, such as detections,
The PAMGuard exporter can be accessed from *File->Export*. This brings up the Export dialog. The export dialog allows users to select which data to export, where to export it and the file format to export as. Each data block also has a settings icon which opens the data block's unique data selector. So for example, users can export only specific types of clicks or whistles between certain frequencies.
<p align="center">
<img width="920" height="450" src = "resources/PAMGuard_exporter_dialog_annotated.png">
<img width="920" height="475" src = "resources/PAMGuard_exporter_dialog_annotated.png">
</p>
<center><em> Diagram of the exporter dialog. The dialog allows users to select which part of the dataset to export, how to export it and which type of data to export </em></center>
@ -91,4 +91,4 @@ Any detection which contains raw sound data, for example a click, clip or deep l
- *Individual* : Each detection is saved in it's own time stamped individual sound file.
## After export
Once data are exported, the exported files are not part of PAMGuard's data management system i.e. PAMGuard has no record they exist and they are not shown in the data model etc. If you export the same data again to the same location, then previous exported files may be overwritten without warning.
Once data are exported, the exported files are not part of PAMGuard's data management system i.e. PAMGuard has no record they exist and they are not shown in the data model etc. If you export the same data again to the same location, then previous exported files may be overwritten without warning.

View File

@ -330,7 +330,7 @@ public class WavDetExport {
for (int i=0; i<wavDataUnitExports.size(); i++) {
if (wavDataUnitExports.get(i).getUnitClass().isAssignableFrom(fnDataUnit.getClass())) {
System.out.println("Append wav. data unit: " + n + " samples: " + wavDataUnitExports.get(i).getWavClip(fnDataUnit)[0].length + " zeroPad: " + zeroPad);
//System.out.println("Append wav. data unit: " + n + " samples: " + wavDataUnitExports.get(i).getWavClip(fnDataUnit)[0].length + " zeroPad: " + zeroPad);
if (zeroPad && lastfnDataUnit!=null) {
//we need to append zero samples between the detections.
@ -352,7 +352,7 @@ public class WavDetExport {
//now safety check - is this more than one GB of data. Each sample is 16bits but the input double array is 64 bits each.
double size = samplesPad*16*audioFormat.getChannels()/1024/1024;
System.out.println("Append wav. zero pad" + samplesPad);
//System.out.println("Append wav. zero pad" + samplesPad);
//
if (size>MAX_ZEROPAD_SIZE_MEGABYTES) {
wavWrite.close();

View File

@ -0,0 +1,62 @@
package pamViewFX.symbol;
import javafx.scene.control.ColorPicker;
import javafx.scene.paint.Color;
/**
* Color picket which allows users to set a default opacity for the default colours selected by a user.
*
* @author Jamie Macaulay
*
*/
public class PamColorPicker extends ColorPicker {
private double defaultOpacity = 1.;
private boolean lastColDefault = true;
public PamColorPicker() {
//A bit of a HACK - if a user selects a new colour then the opacity is set to defaultOpacity rather than 1.
//If the new colour already has the opacity set by the user then nothing happens.
this.valueProperty().addListener((obsVal, oldVal, newVal)->{
// System.out.println("New colour default opacity: " + defaultOpacity + " " +newVal.getOpacity() + " " + (Math.abs(newVal.getOpacity()-defaultOpacity)));
// if (oldVal.getRed()!=newVal.getRed() || oldVal.getGreen()!=newVal.getGreen() || oldVal.getBlue()!=newVal.getBlue()) {
//we have a new colour - let's set the opacity
if (newVal.getOpacity()==1.) {
//change the opacity to default. Other values of opacity indicate the user has changed
PamColorPicker.this.setValue(Color.color(newVal.getRed(), newVal.getGreen(), newVal.getBlue(), defaultOpacity));
lastColDefault=true;
}
else if (Math.abs(newVal.getOpacity()-defaultOpacity)>(0.5/255)) {
lastColDefault=false;
}
// }
});
}
/**
* Set the default opacity of a colour when selected.
*/
public void setDefaultOpacity(double opacity) {
// System.out.println("Set default opacity: " + opacity + " currently default:? " + lastColDefault + " " + this.getValue().getOpacity());
this.defaultOpacity=opacity;
//when it is set, then change the current colour if it the default opacity only - otherwise keep user specific settings.
if (lastColDefault) {
PamColorPicker.this.setValue(Color.color(this.getValue().getRed(), this.getValue().getGreen(), this.getValue().getBlue(), defaultOpacity));
}
}
public double getDefaultOpacity() {
return defaultOpacity;
}
}

View File

@ -477,13 +477,13 @@ public class StandardSymbolModifierPane extends SymbolModifierPane {
public class ColorChooserPane extends SymbolChooserControls {
private ColorPicker symbolFillColourPicker;
private PamColorPicker symbolFillColourPicker;
public ColorChooserPane(int modFlag, String name) {
super(modFlag, name);
symbolFillColourPicker= new ColorPicker();
symbolFillColourPicker= new PamColorPicker();
symbolFillColourPicker.setStyle("-fx-color-label-visible: false ;");
// symbolFillColourPicker.valueProperty().addListener((obsVal, oldVal, newVal)->{
// //send a notification to the pane that a colour has changed
@ -492,12 +492,33 @@ public class StandardSymbolModifierPane extends SymbolModifierPane {
this.setSettingsPane(symbolFillColourPicker);
}
/**
* Set the default opacity for the colour picker. When a new colour is selected,
* then the opacity will default to the set value.
*
* @param opacity - the default opacity to set. Default is 1.
*/
public void setDefaultOpacity(double opacity) {
symbolFillColourPicker.setDefaultOpacity(opacity);
}
/**
* Get the default opacity for the colour picker. When a new colour is selected,
* then the opacity will default to the set value.
*
* @return opacity - the default opacity of the colour picker.
*/
public double getDefaultOpacity() {
return symbolFillColourPicker.getDefaultOpacity();
}
public ColorPicker getSymbolColourPicker() {
return symbolFillColourPicker;
}
public void setSymbolColourPicker(ColorPicker symbolFillColourPicker) {
public void setSymbolColourPicker(PamColorPicker symbolFillColourPicker) {
this.symbolFillColourPicker = symbolFillColourPicker;
}
@ -625,5 +646,23 @@ public class StandardSymbolModifierPane extends SymbolModifierPane {
public PamVBox getSymbolBox() {
return symbolBox;
}
/**
* Set the default opacity for selected colours from the colour picker. The
* default opacity is the the opacity when a user selects a new colour. The user
* can alter this with advanced colour controls.
*
* @param opacity - the default opacity for fill colours.
*/
public void setDefaultFillOpacity(double opacity) {
//set the opacity ofr all fill colour controls
for (int i=0; i<symbolChooserControls.size(); i++) {
if ((symbolChooserControls.get(i).getModFlag() & SymbolModType.FILLCOLOUR) != 0){
((ColorChooserPane) symbolChooserControls.get(i)).setDefaultOpacity(opacity);
}
}
}
}

View File

@ -502,5 +502,11 @@ public class StandardSymbolOptionsPane extends FXSymbolOptionsPane<StandardSymbo
public BorderPane getMainPane() {
return mainPane;
}
public StandardSymbolModifierPane getDefaultSymbolPane() {
return defaultSymbolPane;
}
}

View File

@ -3,6 +3,8 @@ package rawDeepLearningClassifier.dataPlotFX;
import java.awt.Color;
import java.awt.event.ActionEvent;
import org.jamdev.jpamutils.JamArr;
import PamController.PamController;
import PamUtils.PamArrayUtils;
import PamView.GeneralProjector;
@ -38,7 +40,7 @@ public class DLSymbolModifier extends SymbolModifier {
/**
* The default symbol data for data annotated with a deep elanring classifier.
*/
private SymbolData symbolData = new SymbolData(PamSymbolType.SYMBOL_CIRCLE, 5, 5, true, Color.BLACK, Color.BLACK);
private SymbolData symbolData = new SymbolData(PamSymbolType.SYMBOL_CIRCLE, 10, 10, true, Color.BLACK, Color.BLACK);
/**
@ -142,10 +144,13 @@ public class DLSymbolModifier extends SymbolModifier {
int[] indexBest = PamArrayUtils.maxPos(results);
// System.out.println( " Index best: " + indexBest[0] + " " + indexBest[1]);
//
// JamArr.printArray(results[0]);
if (passed || !dlSymbolOptions.showOnlyBinary) {
//work out the class colour...
javafx.scene.paint.Color color = PamUtilsFX.intToColor(dlSymbolOptions.classColors[indexBest[1]]);
Color colorAWT = PamUtilsFX.fxToAWTColor(color);

View File

@ -140,6 +140,7 @@ public class DLPredictonPane extends DynamicSettingsPane<DLPredictionFilterParam
@Override
public DLPredictionFilterParams getParams(DLPredictionFilterParams currParams) {
if (classPanes==null) return currParams;
for (int i=0; i<classPanes.length ; i++) {
currParams.classSelect[i] = classPanes[i].enable.isSelected();

View File

@ -736,7 +736,7 @@ public class SegmenterProcess extends PamProcess {
//add some extra metadata to the chunks
packageSegmenterDataUnit(currentRawChunks[i]);
System.out.println("Segmenter process: Save current segments to datablock: " + currentRawChunks[i].getParentDataUnit().getUID() + " " + i + currentRawChunks[i].getRawData()[0][0]);
//System.out.println("Segmenter process: Save current segments to datablock: " + currentRawChunks[i].getParentDataUnit().getUID() + " " + i + currentRawChunks[i].getRawData()[0][0]);
//send the raw data unit off to be classified!