From 38671987dbfbb85958794801fc91189d1001ae78 Mon Sep 17 00:00:00 2001 From: Jamie Mac Date: Mon, 26 Aug 2024 17:15:43 +0100 Subject: [PATCH] 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. --- .gitignore | 2 + src/PamUtils/PamArrayUtils.java | 2 +- src/PamView/symbol/StandardSymbolChooser.java | 11 ++++ .../symbol/modifier/PeakFreqModifier.java | 4 +- .../data/generic/GenericDataPlotInfo.java | 22 +++++++ .../data/generic/GenericLinePlotInfo.java | 2 + .../data/generic/GenericSettingsPane.java | 14 ++++- .../rawClipDataPlot/RawClipDataInfo.java | 14 ++++- .../rawClipDataPlot/RawClipSettingsPane.java | 10 +++ .../layout/DetectionPlotDisplay.java | 2 +- src/detectionPlotFX/plots/WaveformPlot.java | 16 ++--- .../rawDDPlot/RawWaveformPlot.java | 3 +- src/export/exporter_help.md | 4 +- src/export/wavExport/WavDetExport.java | 4 +- src/pamViewFX/symbol/PamColorPicker.java | 62 +++++++++++++++++++ .../symbol/StandardSymbolModifierPane.java | 45 +++++++++++++- .../symbol/StandardSymbolOptionsPane.java | 6 ++ .../dataPlotFX/DLSymbolModifier.java | 9 ++- .../dataSelector/DLPredictonPane.java | 1 + .../segmenter/SegmenterProcess.java | 2 +- 20 files changed, 209 insertions(+), 26 deletions(-) create mode 100644 src/pamViewFX/symbol/PamColorPicker.java diff --git a/.gitignore b/.gitignore index 76213268..3d9716ea 100644 --- a/.gitignore +++ b/.gitignore @@ -114,3 +114,5 @@ settings.xml .classpath .settings/org.eclipse.jdt.core.prefs .classpath +.settings/org.eclipse.jdt.core.prefs +.classpath diff --git a/src/PamUtils/PamArrayUtils.java b/src/PamUtils/PamArrayUtils.java index ce4318a9..a2ac1b5a 100644 --- a/src/PamUtils/PamArrayUtils.java +++ b/src/PamUtils/PamArrayUtils.java @@ -600,7 +600,7 @@ public class PamArrayUtils { // int count = 0; float cur; for(int i=0; imax) { index[0]=i; diff --git a/src/PamView/symbol/StandardSymbolChooser.java b/src/PamView/symbol/StandardSymbolChooser.java index 5748a358..1d4b9a2b 100644 --- a/src/PamView/symbol/StandardSymbolChooser.java +++ b/src/PamView/symbol/StandardSymbolChooser.java @@ -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; } diff --git a/src/PamView/symbol/modifier/PeakFreqModifier.java b/src/PamView/symbol/modifier/PeakFreqModifier.java index 29a17765..b499ec35 100644 --- a/src/PamView/symbol/modifier/PeakFreqModifier.java +++ b/src/PamView/symbol/modifier/PeakFreqModifier.java @@ -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()); diff --git a/src/dataPlotsFX/data/generic/GenericDataPlotInfo.java b/src/dataPlotsFX/data/generic/GenericDataPlotInfo.java index a530ec89..74fdb4cb 100644 --- a/src/dataPlotsFX/data/generic/GenericDataPlotInfo.java +++ b/src/dataPlotsFX/data/generic/GenericDataPlotInfo.java @@ -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); + } + } + } diff --git a/src/dataPlotsFX/data/generic/GenericLinePlotInfo.java b/src/dataPlotsFX/data/generic/GenericLinePlotInfo.java index 98b39929..57c359f4 100644 --- a/src/dataPlotsFX/data/generic/GenericLinePlotInfo.java +++ b/src/dataPlotsFX/data/generic/GenericLinePlotInfo.java @@ -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); } diff --git a/src/dataPlotsFX/data/generic/GenericSettingsPane.java b/src/dataPlotsFX/data/generic/GenericSettingsPane.java index 4947d7d9..eac55841 100644 --- a/src/dataPlotsFX/data/generic/GenericSettingsPane.java +++ b/src/dataPlotsFX/data/generic/GenericSettingsPane.java @@ -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); + } + } + } diff --git a/src/dataPlotsFX/rawClipDataPlot/RawClipDataInfo.java b/src/dataPlotsFX/rawClipDataPlot/RawClipDataInfo.java index f6daeabc..5027a15d 100644 --- a/src/dataPlotsFX/rawClipDataPlot/RawClipDataInfo.java +++ b/src/dataPlotsFX/rawClipDataPlot/RawClipDataInfo.java @@ -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); + } + } diff --git a/src/dataPlotsFX/rawClipDataPlot/RawClipSettingsPane.java b/src/dataPlotsFX/rawClipDataPlot/RawClipSettingsPane.java index 6f81b639..6a21a465 100644 --- a/src/dataPlotsFX/rawClipDataPlot/RawClipSettingsPane.java +++ b/src/dataPlotsFX/rawClipDataPlot/RawClipSettingsPane.java @@ -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); + } + } } diff --git a/src/detectionPlotFX/layout/DetectionPlotDisplay.java b/src/detectionPlotFX/layout/DetectionPlotDisplay.java index 3630bc4e..e4a48bfc 100644 --- a/src/detectionPlotFX/layout/DetectionPlotDisplay.java +++ b/src/detectionPlotFX/layout/DetectionPlotDisplay.java @@ -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. diff --git a/src/detectionPlotFX/plots/WaveformPlot.java b/src/detectionPlotFX/plots/WaveformPlot.java index 581d40ae..76fbd4c0 100644 --- a/src/detectionPlotFX/plots/WaveformPlot.java +++ b/src/detectionPlotFX/plots/WaveformPlot.java @@ -93,7 +93,7 @@ public abstract class WaveformPlot 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 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 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 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 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; diff --git a/src/detectionPlotFX/rawDDPlot/RawWaveformPlot.java b/src/detectionPlotFX/rawDDPlot/RawWaveformPlot.java index 8e00f9a8..722f7a2f 100644 --- a/src/detectionPlotFX/rawDDPlot/RawWaveformPlot.java +++ b/src/detectionPlotFX/rawDDPlot/RawWaveformPlot.java @@ -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{ @Override public String getName() { - return "Click Waveform"; + return "Waveform"; } @Override diff --git a/src/export/exporter_help.md b/src/export/exporter_help.md index df85fc41..6339772b 100644 --- a/src/export/exporter_help.md +++ b/src/export/exporter_help.md @@ -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.

- +

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
@@ -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. \ No newline at end of file +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. diff --git a/src/export/wavExport/WavDetExport.java b/src/export/wavExport/WavDetExport.java index b9b33951..953f8254 100644 --- a/src/export/wavExport/WavDetExport.java +++ b/src/export/wavExport/WavDetExport.java @@ -330,7 +330,7 @@ public class WavDetExport { for (int i=0; iMAX_ZEROPAD_SIZE_MEGABYTES) { wavWrite.close(); diff --git a/src/pamViewFX/symbol/PamColorPicker.java b/src/pamViewFX/symbol/PamColorPicker.java new file mode 100644 index 00000000..e6e297b0 --- /dev/null +++ b/src/pamViewFX/symbol/PamColorPicker.java @@ -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; + } + + +} diff --git a/src/pamViewFX/symbol/StandardSymbolModifierPane.java b/src/pamViewFX/symbol/StandardSymbolModifierPane.java index 0dd079ab..4e44b753 100644 --- a/src/pamViewFX/symbol/StandardSymbolModifierPane.java +++ b/src/pamViewFX/symbol/StandardSymbolModifierPane.java @@ -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