This module takes two XML files and displays the number of measures that differ between the two before and after running the combined correction models
Returns a tuple of the total number of NON-flagged measures and the total number of those measures that have a rhythmic match.
Essentially it’s the ratio of amount of rhythmic similarity within a piece, which gives an upper bound on what the omr.corrector.prior measure should be able to achieve for the flagged measures. If a piece has low rhythmic similarity in general, then there’s no way for a correct match to be found within the unflagged measures in the piece.
takes in a stream.Score.
>>> c = converter.parse(omr.correctors.K525omrShortPath) # first 21 measures
>>> totalUnflagged, totalUnflaggedWithMatches = omr.evaluators.autoCorrelationBestMeasure(c)
>>> (totalUnflagged, totalUnflaggedWithMatches)
(71, 64)
>>> print( float(totalUnflaggedWithMatches) / totalUnflagged )
0.901...
Schoenberg has low autoCorrelation.
>>> c = corpus.parse('schoenberg/opus19/movement6')
>>> totalUnflagged, totalUnflaggedWithMatches = omr.evaluators.autoCorrelationBestMeasure(c)
>>> (totalUnflagged, totalUnflaggedWithMatches)
(18, 6)
>>> print( float(totalUnflaggedWithMatches) / totalUnflagged )
0.333...
Get a dictionary showing the efficacy of the omr.correctors.ScoreCorrector on an OMR Score by comparing it to the GroundTruth.
Set debug to True to see a lot of intermediary steps.
>>> omrFilePath = omr.correctors.K525omrShortPath
>>> groundTruthFilePath = omr.correctors.K525groundTruthShortPath
>>> returnDict = omr.evaluators.evaluateCorrectingModel(omrFilePath, groundTruthFilePath)
>>> for name in sorted(list(returnDict.keys())):
... (name, returnDict[name])
('newEditDistance', 20)
('numberOfFlaggedMeasures', 13)
('originalEditDistance', 32)
('totalNumberOfMeasures', 84)
Object for making comparisons between an OMR score and the GroundTruth
Takes in a path to the OMR and a path to the groundTruth (or a pair of music21.stream.Score objects).
See below for examples.
OmrGroundTruthPair read/write properties
OmrGroundTruthPair methods
define the delete cost for x and y (1)
Returns the total edit distance as an Int between the two scores
This function is based on the James H. Martin’s minimum edit distance, http://www.cs.colorado.edu/~martin/csci5832/edit-dist-blurb.html
>>> omrPath = omr.correctors.K525omrShortPath
>>> ground = omr.correctors.K525groundTruthShortPath
>>> omrGTP = omr.evaluators.OmrGroundTruthPair(omr=omrPath, ground=ground)
>>> differences = omrGTP.getDifferences()
>>> differences
32
Returns the number of differences (int) between two scores with aligned indices
Returns a ScoreCorrector object of the Ground truth score
>>> omrPath = omr.correctors.K525omrShortPath
>>> ground = omr.correctors.K525groundTruthShortPath
>>> omrGTP = omr.evaluators.OmrGroundTruthPair(omr=omrPath, ground=ground)
>>> ssGT = omrGTP.getGroundScore()
>>> ssGT
<music21.omr.correctors.ScoreCorrector object at 0x...>
Returns a ScoreCorrector object of the OMR score. does NOT store it anywhere...
>>> omrPath = omr.correctors.K525omrShortPath
>>> ground = omr.correctors.K525groundTruthShortPath
>>> omrGTP = omr.evaluators.OmrGroundTruthPair(omr=omrPath, ground=ground)
>>> ssOMR = omrGTP.getOmrScore()
>>> ssOMR
<music21.omr.correctors.ScoreCorrector object at 0x...>
store the Hashes for both scores.
define the insert cost for x and y (1)
Computes the min edit distance from target to source. Figure 3.25
Parse both scores.
define the substitution cost for x and y (2)