-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue300 fix debug spectrograms #301
Conversation
Change default window function from Hamming to Hanning. Also add documentation to some of the class properties.
Issue #300 Write one unit test for overlay of sonogram with matrix of score/hits. Remove duplicated method RecognizerBase.WriteSpectrumIndicesFiles() Rewrite method for drawing of event rectangles.
Issue #300 Unit tests for drawing events on sonograms Make unit test for drawing a matrix of scores over a spectrogram. Shift unit test EventStatisticsCalculateTests to a new namespace of tests for acoustic events. Create new class of tests for acoustic events.
Issue #300 The main difficulty here is confusing terminology of temporal fileds and properties. Changed some of these to be more explicit. There appears to remain one more bug - the number of acoustic events in the ae.csv file does not match number that appears in the spectrogram images??
Issue #300 remove DIY test method.
Issue #300 Final debug of merge events. It now works correctly.
Issue #300 Removed unneccesary methods and added documentation. Grouped methods according to functionality.
"hit matrix overlap" should read "hit matrix overlay" |
/// <summary> | ||
/// Sets both the Segment start and the Event start wrt to recording. | ||
/// </summary> | ||
protected void SetSegmentAndEventStartsWrtRecording(TimeSpan segmentStartWrtRecording, double eventStartWrtSegment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrt
is an unacceptable abbreviation. Remove, please. Use the old names - they are consistently used in the project
If you need to document the purpose of these parameters then add documentation.
@@ -30,7 +30,7 @@ public class WhistleParameters : CommonParameters | |||
double decibelThreshold, | |||
double minDuration, | |||
double maxDuration, | |||
TimeSpan segmentStartOffset) | |||
TimeSpan segmentStartWrtRecording) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TimeSpan segmentStartWrtRecording) | |
TimeSpan segmentStartOffset) |
@@ -96,7 +93,7 @@ public class WhistleParameters : CommonParameters | |||
decibelThreshold, | |||
minDuration, | |||
maxDuration, | |||
segmentStartOffset); | |||
segmentStartWrtRecording); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
segmentStartWrtRecording); | |
segmentStartOffset); |
@@ -110,33 +107,9 @@ public class WhistleParameters : CommonParameters | |||
} //end for all freq bins | |||
|
|||
// combine adjacent acoustic events | |||
events = AcousticEvent.CombineOverlappingEvents(events); | |||
events = AcousticEvent.CombineOverlappingEvents(events, segmentStartWrtRecording); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix name
// double I1MeandB; //mean intensity of pixels in the event prior to noise subtraction | ||
// double I1Var; //, | ||
// double I2MeandB; // mean intensity of pixels in the event after Wiener filter, prior to noise subtraction | ||
// double I2Var; //, | ||
// private double i3Mean; // mean intensity of pixels in the event AFTER noise reduciton - USED FOR CLUSTERING | ||
// private double i3Var; // variance of intensity of pixels in the event. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These look to be inserted - why are they? Where from? Why not remove them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see, it was removed from further down. I'd suggest removing this completely and instead checking if equivalent statistics can be found in the EventStatistics
class
var segmentStartOffset = TimeSpan.Zero; | ||
double maxPossibleScore = 10.0; | ||
var startTime1 = 1.0; | ||
var duration1 = 5.0; | ||
var minHz1 = 1000; | ||
var maxHz1 = 8000; | ||
var event1 = new AcousticEvent(segmentStartOffset, startTime1, duration1, minHz1, maxHz1) | ||
{ | ||
Name = "Event1", | ||
Score = 1.0, | ||
ScoreNormalised = 1.0 / maxPossibleScore, | ||
}; | ||
|
||
events.Add(event1); | ||
|
||
var startTime2 = 4.5; | ||
var duration2 = 2.0; | ||
var minHz2 = 1500; | ||
var maxHz2 = 6000; | ||
var event2 = new AcousticEvent(segmentStartOffset, startTime2, duration2, minHz2, maxHz2) | ||
{ | ||
Name = "Event2", | ||
Score = 5.0, | ||
ScoreNormalised = 5.0 / maxPossibleScore, | ||
}; | ||
events.Add(event2); | ||
|
||
var startTime3 = 7.0; | ||
var duration3 = 2.0; | ||
var minHz3 = 1000; | ||
var maxHz3 = 8000; | ||
var event3 = new AcousticEvent(segmentStartOffset, startTime3, duration3, minHz3, maxHz3) | ||
{ | ||
Name = "Event3", | ||
Score = 9.0, | ||
ScoreNormalised = 9.0 / maxPossibleScore, | ||
}; | ||
events.Add(event3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a good test (well done) but there's a lot of ceremony here. Inline all the variable declarations that are used to create the acoustic events.
If you want to keep the names as a form of documentation you can use C# named parameters
} | ||
|
||
//substituteSonogram.Save("C:\\temp\\image.png"); | ||
var redPixel1 = new Argb32(110, 10, 30); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you creating pixels with an alpha component here?
} | ||
|
||
[TestMethod] | ||
public void TestSonogramWithEventsOverlay() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this test, I'd suggest using the GeneratedImageTest
base class I've set up.
Also, the previous comment about ceremony applies here
ev.DrawEvent(substituteSonogram, framesPerSecond, freqBinWidth, height); | ||
} | ||
|
||
//substituteSonogram.Save("C:\\temp\\image.png"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bad example to leave in. Remove or fix path. See GeneratedImageTests
for example output save directory
@@ -219,5 +221,47 @@ public void TestAnnotatedSonogramWithPlots() | |||
Assert.AreEqual(1621, image.Width); | |||
Assert.AreEqual(656, image.Height); | |||
} | |||
|
|||
[TestMethod] | |||
public void TestSonogramHitsOverlay() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the generated image test class
Issue #300 Most of the changes are to terminology of temporal variables. Also to signatures of test methods.
Concerning requested changes: |
@towsey - thanks. RE 4.: Set up a call. |
@atruskie I will fix the Anti Aliasing issue and then suggest a call concerning point 4. |
I have not been able to find a solution to the anti-aliasing problem. |
Issue #300 Fix anti-aliasing problem and then fix unit tests for the drawing of events.
Issue #300 Fixed test of drawing events on spectrograms. Test now uses the new image comparison facility. Set the event name to empty string in order to prevent test failing due to writing of poorly anti-aliased text. Returned font type to the original. Included new expected events image in Fixtures.
Adressing comments from #301. @towsey was unwilling to address all comments from code review. This commit actually addresses the feedback. Removes abbreviation `wrt` wherever used in recent changes and instead adds better documentation for parameters. Corrects mistaken comments and assumptions about TimeStart and TimeEnd on AcousticEvent and marks them as obsolete to prevent further misunderstanding. Move EventStatisticsCalculateTests.cs back to its correct folder and namespace. Also renames EventTests.cs to AcousticEventTests.cs (as per our convention) and moves the file to correct namespace and folder.
c303f56
to
7804814
Compare
Adressing comments from #301. @towsey was unwilling to address all comments from code review. This commit actually addresses the feedback. Removes abbreviation `wrt` wherever used in recent changes and instead adds better documentation for parameters. Corrects mistaken comments and assumptions about TimeStart and TimeEnd on AcousticEvent and marks them as obsolete to prevent further misunderstanding. Move EventStatisticsCalculateTests.cs back to its correct folder and namespace. Also renames EventTests.cs to AcousticEventTests.cs (as per our convention) and moves the file to correct namespace and folder.
Original intention was to fix drawing of spectrograms. This included the drawing of acoustic events and the hit matrix overlap. Therefore did some tidying up of the AcousticEvent class. Also set FFT window to HANNING which was originally set as Issue #291.
Wrote unit tests for the drawing of Acoustic events and the merging of overlapping acoustic events.
Work for #300.