-
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
711e06c
Update SpectrogramSettings.cs
towsey 02947b7
Write one unit test for overlay of hit scores
towsey b3cf451
Unit tests for drawing events on sonograms
towsey 3d1b263
Fixing bugs in merging of acoustic events
towsey 072742f
Remove a call to one of my do-it-yourself test methods.
towsey fa15eef
Update AcousticEvent.cs
towsey ecf3ad0
Update AcousticEvent.cs
towsey bca4013
Changes as requested by Anthony
towsey 1d4e524
Fix anti-aliasing when drawing event
towsey 04f9b04
Fixed test of drawing events
towsey e8d593d
Cleaned up event test
atruskie 7804814
Cleaned up unconventional code
atruskie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -30,7 +30,7 @@ public static (List<AcousticEvent>, double[]) GetWhistles( | |||||
double decibelThreshold, | ||||||
double minDuration, | ||||||
double maxDuration, | ||||||
TimeSpan segmentStartOffset) | ||||||
TimeSpan segmentStartWrtRecording) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
{ | ||||||
var sonogramData = sonogram.Data; | ||||||
int frameCount = sonogramData.GetLength(0); | ||||||
|
@@ -39,10 +39,6 @@ public static (List<AcousticEvent>, double[]) GetWhistles( | |||||
double binWidth = nyquist / (double)binCount; | ||||||
int minBin = (int)Math.Round(minHz / binWidth); | ||||||
int maxBin = (int)Math.Round(maxHz / binWidth); | ||||||
//int binCountInBand = maxBin - minBin + 1; | ||||||
|
||||||
// buffer zone around whistle is four bins wide. | ||||||
int N = 4; | ||||||
|
||||||
// list of accumulated acoustic events | ||||||
var events = new List<AcousticEvent>(); | ||||||
|
@@ -54,7 +50,8 @@ public static (List<AcousticEvent>, double[]) GetWhistles( | |||||
// set up an intensity array for the frequency bin. | ||||||
double[] intensity = new double[frameCount]; | ||||||
|
||||||
if (minBin < N) | ||||||
// buffer zone around whistle is four bins wide. | ||||||
if (minBin < 4) | ||||||
{ | ||||||
// for all time frames in this frequency bin | ||||||
for (int t = 0; t < frameCount; t++) | ||||||
|
@@ -96,7 +93,7 @@ public static (List<AcousticEvent>, double[]) GetWhistles( | |||||
decibelThreshold, | ||||||
minDuration, | ||||||
maxDuration, | ||||||
segmentStartOffset); | ||||||
segmentStartWrtRecording); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
// add to conbined intensity array | ||||||
for (int t = 0; t < frameCount; t++) | ||||||
|
@@ -110,33 +107,9 @@ public static (List<AcousticEvent>, double[]) GetWhistles( | |||||
} //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 commentThe reason will be displayed to describe this comment to others. Learn more. Fix name |
||||||
|
||||||
return (events, combinedIntensityArray); | ||||||
} | ||||||
|
||||||
/* | ||||||
/// <summary> | ||||||
/// Calculates the average intensity in a freq band having min and max freq, | ||||||
/// AND then subtracts average intensity in the side/buffer bands, below and above. | ||||||
/// THis method adds dB log values incorrectly but it is faster than doing many log conversions. | ||||||
/// This method is used to find acoustic events and is accurate enough for the purpose. | ||||||
/// </summary> | ||||||
public static double[] CalculateFreqBandAvIntensityMinusBufferIntensity(double[,] sonogramData, int minHz, int maxHz, int nyquist) | ||||||
{ | ||||||
var bandIntensity = SNR.CalculateFreqBandAvIntensity(sonogramData, minHz, maxHz, nyquist); | ||||||
var bottomSideBandIntensity = SNR.CalculateFreqBandAvIntensity(sonogramData, minHz - bottomHzBuffer, minHz, nyquist); | ||||||
var topSideBandIntensity = SNR.CalculateFreqBandAvIntensity(sonogramData, maxHz, maxHz + topHzBuffer, nyquist); | ||||||
|
||||||
int frameCount = sonogramData.GetLength(0); | ||||||
double[] netIntensity = new double[frameCount]; | ||||||
for (int i = 0; i < frameCount; i++) | ||||||
{ | ||||||
netIntensity[i] = bandIntensity[i] - bottomSideBandIntensity[i] - topSideBandIntensity[i]; | ||||||
} | ||||||
|
||||||
return netIntensity; | ||||||
} | ||||||
*/ | ||||||
} | ||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 projectIf you need to document the purpose of these parameters then add documentation.