Overview#

This notebook gives a general overview of the features included in the dataset.

Hide imports
%load_ext autoreload
%autoreload 2
import os

import dimcat as dc
import pandas as pd
import plotly.express as px
from dimcat import filters, plotting
from IPython.display import display

import utils
RESULTS_PATH = os.path.abspath(os.path.join(utils.OUTPUT_FOLDER, "overview"))
os.makedirs(RESULTS_PATH, exist_ok=True)


def make_output_path(
    filename: str,
    extension=None,
    path=RESULTS_PATH,
) -> str:
    return utils.make_output_path(filename=filename, extension=extension, path=path)


def save_figure_as(
    fig, filename, formats=("png", "pdf"), directory=RESULTS_PATH, **kwargs
):
    if formats is not None:
        for fmt in formats:
            plotting.write_image(fig, filename, directory, format=fmt, **kwargs)
    else:
        plotting.write_image(fig, filename, directory, **kwargs)

Loading data

D = utils.get_dataset("mendelssohn_quartets", corpus_release="v2.4")
package = D.inputs.get_package()
package_info = package._package.custom
git_tag = package_info.get("git_tag")
utils.print_heading("Data and software versions")
print("Felix Mendelssohn – String Quartets version v2.4")
print(f"Datapackage '{package.package_name}' @ {git_tag}")
print(f"dimcat version {dc.__version__}\n")
D
Data and software versions
--------------------------

Felix Mendelssohn – String Quartets version v2.4
Datapackage 'mendelssohn_quartets' @ v2.4
dimcat version 3.4.0
Dataset
=======
{'inputs': {'basepath': None,
            'packages': {'mendelssohn_quartets': ["'mendelssohn_quartets.measures' "
                                                  '(MuseScoreFacetName.MuseScoreMeasures)',
                                                  "'mendelssohn_quartets.notes' (MuseScoreFacetName.MuseScoreNotes)",
                                                  "'mendelssohn_quartets.expanded' "
                                                  '(MuseScoreFacetName.MuseScoreHarmonies)',
                                                  "'mendelssohn_quartets.chords' (MuseScoreFacetName.MuseScoreChords)",
                                                  "'mendelssohn_quartets.metadata' (FeatureName.Metadata)"]}},
 'outputs': {'basepath': None, 'packages': {}},
 'pipeline': []}
filtered_D = filters.HasHarmonyLabelsFilter(keep_values=[True]).process(D)
all_metadata = filtered_D.get_metadata()
assert len(all_metadata) > 0, "No pieces selected for analysis."
all_metadata
TimeSig KeySig last_mc last_mn length_qb last_mc_unfolded last_mn_unfolded length_qb_unfolded volta_mcs all_notes_qb ... viaf wikidata staff_1_ambitus staff_1_instrument staff_2_ambitus staff_2_instrument staff_3_ambitus staff_3_instrument staff_4_ambitus staff_4_instrument
corpus piece
mendelssohn_quartets 01op12a {1: '4/4'} {1: -3} 294 292 1168.0 294 292 1168.0 () 4329.00 ... <NA> https://www.wikidata.org/wiki/Q3413716 55-91 (G3-G6) Violin 55-84 (G3-C6) Violin 48-77 (C3-F5) Viola 36-71 (C2-B4) Violoncello
01op12b {1: '2/4'} {1: -2, 33: 1, 92: -2} 135 128 261.5 214 206 412.0 (80, 81, 82], [83, 84) 974.00 ... <NA> https://www.wikidata.org/wiki/Q3413716 55-91 (G3-G6) Violin 55-84 (G3-C6) Violin 48-74 (C3-D5) Viola 36-62 (C2-D4) Violoncello
01op12c {1: '3/4'} {1: -2} 65 65 195.0 65 65 195.0 () 705.00 ... <NA> https://www.wikidata.org/wiki/Q3413716 55-91 (G3-G6) Violin 55-79 (G3-G5) Violin 48-75 (C3-Eb5) Viola 36-63 (C2-Eb4) Violoncello
01op12d {1: '12/8', 106: '4/4', 120: '12/8', 229: '4/4'} {1: -3} 313 313 1680.0 313 313 1680.0 () 6135.00 ... <NA> https://www.wikidata.org/wiki/Q3413716 55-91 (G3-G6) Violin 55-84 (G3-C6) Violin 48-79 (C3-G5) Viola 36-72 (C2-C5) Violoncello
02op13a {1: '3/4', 20: '4/4'} {1: 3, 20: 0} 252 251 986.5 252 251 986.5 () 3742.25 ... <NA> https://www.wikidata.org/wiki/Q3413722 55-95 (G3-B6) Violin 55-88 (G3-E6) Violin 48-76 (C3-E5) Viola 36-74 (C2-D5) Violoncello
02op13b {1: '3/4', 46: '4/4', 53: '3/4', 89: '4/4', 93... {1: -1} 125 125 386.0 125 125 386.0 () 1366.12 ... <NA> https://www.wikidata.org/wiki/Q3413722 55-93 (G3-A6) Violin 55-86 (G3-D6) Violin 48-77 (C3-F5) Viola 36-70 (C2-Bb4) Violoncello
02op13c {1: '2/4'} {1: 0, 27: 3, 117: 0} 164 163 328.0 271 271 542.0 (108], [109) 950.25 ... <NA> https://www.wikidata.org/wiki/Q3413722 57-93 (A3-A6) Violin 55-88 (G3-E6) Violin 48-76 (C3-E5) Viola 36-69 (C2-A4) Violoncello
02op13d {1: '2/2', 365: '3/4', 368: '4/4', 373: '3/4'} {1: 0, 365: -1, 368: 0, 373: 3} 398 397 1560.0 398 397 1560.0 () 5958.50 ... <NA> https://www.wikidata.org/wiki/Q3413722 55-93 (G3-A6) Violin 55-88 (G3-E6) Violin 48-76 (C3-E5) Viola 36-72 (C2-C5) Violoncello
03op44,1a {1: '4/4'} {1: 2} 375 374 1500.0 493 493 1972.0 (120], [121) 5473.50 ... <NA> https://www.wikidata.org/wiki/Q6502965 57-93 (A3-A6) Violin 55-86 (G3-D6) Violin 48-78 (B#2-F#5) Viola 36-69 (C2-A4) Violoncello
03op44,1b {1: '3/4'} {1: 2} 230 225 681.0 309 304 913.0 (65], [66]], [[82], [83) 2615.50 ... <NA> https://www.wikidata.org/wiki/Q6502965 57-93 (A3-A6) Violin 55-81 (G3-A5) Violin 49-78 (C#3-F#5) Viola 36-69 (C2-A4) Violoncello
03op44,1c {1: '2/4'} {1: 2} 155 155 310.0 155 155 310.0 () 980.75 ... <NA> https://www.wikidata.org/wiki/Q6502965 59-91 (B3-G6) Violin 58-79 (A#3-G5) Violin 50-76 (D3-E5) Viola 38-69 (D2-A4) Violoncello
03op44,1d {1: '12/8'} {1: 2} 316 316 1896.0 316 316 1896.0 () 6375.50 ... <NA> https://www.wikidata.org/wiki/Q6502965 55-93 (G3-A6) Violin 55-84 (G3-C6) Violin 48-78 (C3-F#5) Viola 36-71 (C2-B4) Violoncello
04op44,2a {1: '4/4'} {1: 1} 282 277 1128.0 376 376 1504.0 (97, 98, 99, 100, 101], [102) 4113.75 ... <NA> https://www.wikidata.org/wiki/Q7623940 55-91 (G3-G6) Violin 55-86 (G3-D6) Violin 48-76 (C3-E5) Viola 36-71 (C2-B4) Violoncello
04op44,2b {1: '3/4'} {1: 4} 244 244 732.0 244 244 732.0 () 2576.00 ... <NA> https://www.wikidata.org/wiki/Q7623940 56-92 (G#3-G#6) Violin 56-88 (G#3-E6) Violin 48-78 (B#2-F#5) Viola 37-69 (C#2-A4) Violoncello
04op44,2c {1: '4/4'} {1: 1} 83 83 332.0 83 83 332.0 () 1293.00 ... <NA> https://www.wikidata.org/wiki/Q7623940 55-93 (G3-A6) Violin 55-81 (G3-A5) Violin 48-76 (C3-E5) Viola 36-74 (C2-D5) Violoncello
04op44,2d {1: '3/4'} {1: 1, 329: 4, 425: 1} 515 515 1545.0 515 515 1545.0 () 5187.50 ... <NA> https://www.wikidata.org/wiki/Q7623940 55-94 (G3-Bb6) Violin 55-88 (G3-E6) Violin 48-76 (C3-E5) Viola 36-67 (C2-G4) Violoncello
05op44,3a {1: '4/4'} {1: -3} 371 369 1477.0 483 480 1921.0 () 5397.50 ... 174395023.0 https://www.wikidata.org/wiki/Q3413866 55-94 (G3-Bb6) Violin 55-87 (G3-Eb6) Violin 48-77 (C3-F5) Viola 36-73 (C2-Db5) Violoncello
05op44,3b {1: '6/8'} {1: -3} 303 301 903.0 320 317 951.0 () 3008.00 ... 174395023.0 https://www.wikidata.org/wiki/Q3413866 55-91 (G3-G6) Violin 55-82 (G3-Bb5) Violin 48-79 (C3-G5) Viola 36-69 (C2-A4) Violoncello
05op44,3c {1: '3/4'} {1: -4} 131 131 393.0 131 131 393.0 () 1435.50 ... 174395023.0 https://www.wikidata.org/wiki/Q3413866 55-92 (G3-Ab6) Violin 55-80 (G3-Ab5) Violin 48-73 (C3-Db5) Viola 36-63 (C2-Eb4) Violoncello
05op44,3d {1: '4/4'} {1: -3} 324 323 1293.0 324 323 1293.0 () 4859.00 ... 174395023.0 https://www.wikidata.org/wiki/Q3413866 55-94 (G3-Bb6) Violin 55-87 (G3-Eb6) Violin 48-78 (C3-Gb5) Viola 36-68 (C2-Ab4) Violoncello
06op80a {1: '2/2'} {1: -4, 213: -1, 259: -4} 324 324 1296.0 324 324 1296.0 () 4909.00 ... 191502272.0 https://www.wikidata.org/wiki/Q3413720 55-94 (G3-Bb6) Violin 55-84 (G3-C6) Violin 48-79 (C3-G5) Viola 36-68 (C2-Ab4) Violoncello
06op80b {1: '3/4'} {1: -4} 304 301 910.0 388 387 1162.0 (17], [18]], [[88], [89) 3154.00 ... 191502272.0 https://www.wikidata.org/wiki/Q3413720 58-87 (Bb3-Eb6) Violin 55-77 (G3-F5) Violin 48-72 (C3-C5) Viola 36-59 (C2-B3) Violoncello
06op80c {1: '2/4'} {1: -4, 72: 0, 80: -4} 121 120 240.5 121 120 240.5 () 885.62 ... 191502272.0 https://www.wikidata.org/wiki/Q3413720 55-89 (G3-F6) Violin 55-77 (G3-F5) Violin 48-70 (C3-Bb4) Viola 36-63 (C2-Eb4) Violoncello
06op80d {1: '2/4'} {1: -4} 461 461 922.0 461 461 922.0 () 3642.25 ... 191502272.0 https://www.wikidata.org/wiki/Q3413720 56-96 (Ab3-C7) Violin 55-83 (G3-B5) Violin 48-77 (C3-F5) Viola 36-67 (C2-G4) Violoncello

24 rows × 61 columns

mean_composition_years = utils.corpus_mean_composition_years(all_metadata)
chronological_order = mean_composition_years.index.to_list()
corpus_colors = dict(zip(chronological_order, utils.CORPUS_COLOR_SCALE))
corpus_names = {
    corp: utils.get_corpus_display_name(corp) for corp in chronological_order
}
chronological_corpus_names = list(corpus_names.values())
corpus_name_colors = {
    corpus_names[corp]: color for corp, color in corpus_colors.items()
}
mean_composition_years
corpus
mendelssohn_quartets    1835.916667
Name: mean_composition_year, dtype: float64

Composition dates#

This section relies on the dataset’s metadata.

valid_composed_start = pd.to_numeric(all_metadata.composed_start, errors="coerce")
valid_composed_end = pd.to_numeric(all_metadata.composed_end, errors="coerce")
print(
    f"Composition dates range from {int(valid_composed_start.min())} {valid_composed_start.idxmin()} "
    f"to {int(valid_composed_end.max())} {valid_composed_end.idxmax()}."
)
Composition dates range from 1827 ('mendelssohn_quartets', '02op13a') to 1847 ('mendelssohn_quartets', '06op80a').

Mean composition years per corpus#

def make_summary(metadata_df):
    piece_is_annotated = metadata_df.label_count > 0
    return metadata_df[piece_is_annotated].copy()
Hide source
summary = make_summary(all_metadata)
bar_data = pd.concat(
    [
        mean_composition_years.rename("year"),
        summary.groupby(level="corpus").size().rename("pieces"),
    ],
    axis=1,
).reset_index()

N = len(summary)
fig = px.bar(
    bar_data,
    x="year",
    y="pieces",
    color="corpus",
    color_discrete_map=corpus_colors,
    title=f"Temporal coverage of the {N} annotated pieces in the Distant Listening Corpus",
)
fig.update_traces(width=5)
fig.update_layout(**utils.STD_LAYOUT)
fig.update_traces(width=5)
save_figure_as(fig, "pieces_timeline_bars")
fig.show()
summary
TimeSig KeySig last_mc last_mn length_qb last_mc_unfolded last_mn_unfolded length_qb_unfolded volta_mcs all_notes_qb ... viaf wikidata staff_1_ambitus staff_1_instrument staff_2_ambitus staff_2_instrument staff_3_ambitus staff_3_instrument staff_4_ambitus staff_4_instrument
corpus piece
mendelssohn_quartets 01op12a {1: '4/4'} {1: -3} 294 292 1168.0 294 292 1168.0 () 4329.00 ... <NA> https://www.wikidata.org/wiki/Q3413716 55-91 (G3-G6) Violin 55-84 (G3-C6) Violin 48-77 (C3-F5) Viola 36-71 (C2-B4) Violoncello
01op12b {1: '2/4'} {1: -2, 33: 1, 92: -2} 135 128 261.5 214 206 412.0 (80, 81, 82], [83, 84) 974.00 ... <NA> https://www.wikidata.org/wiki/Q3413716 55-91 (G3-G6) Violin 55-84 (G3-C6) Violin 48-74 (C3-D5) Viola 36-62 (C2-D4) Violoncello
01op12c {1: '3/4'} {1: -2} 65 65 195.0 65 65 195.0 () 705.00 ... <NA> https://www.wikidata.org/wiki/Q3413716 55-91 (G3-G6) Violin 55-79 (G3-G5) Violin 48-75 (C3-Eb5) Viola 36-63 (C2-Eb4) Violoncello
01op12d {1: '12/8', 106: '4/4', 120: '12/8', 229: '4/4'} {1: -3} 313 313 1680.0 313 313 1680.0 () 6135.00 ... <NA> https://www.wikidata.org/wiki/Q3413716 55-91 (G3-G6) Violin 55-84 (G3-C6) Violin 48-79 (C3-G5) Viola 36-72 (C2-C5) Violoncello
02op13a {1: '3/4', 20: '4/4'} {1: 3, 20: 0} 252 251 986.5 252 251 986.5 () 3742.25 ... <NA> https://www.wikidata.org/wiki/Q3413722 55-95 (G3-B6) Violin 55-88 (G3-E6) Violin 48-76 (C3-E5) Viola 36-74 (C2-D5) Violoncello
02op13b {1: '3/4', 46: '4/4', 53: '3/4', 89: '4/4', 93... {1: -1} 125 125 386.0 125 125 386.0 () 1366.12 ... <NA> https://www.wikidata.org/wiki/Q3413722 55-93 (G3-A6) Violin 55-86 (G3-D6) Violin 48-77 (C3-F5) Viola 36-70 (C2-Bb4) Violoncello
02op13c {1: '2/4'} {1: 0, 27: 3, 117: 0} 164 163 328.0 271 271 542.0 (108], [109) 950.25 ... <NA> https://www.wikidata.org/wiki/Q3413722 57-93 (A3-A6) Violin 55-88 (G3-E6) Violin 48-76 (C3-E5) Viola 36-69 (C2-A4) Violoncello
02op13d {1: '2/2', 365: '3/4', 368: '4/4', 373: '3/4'} {1: 0, 365: -1, 368: 0, 373: 3} 398 397 1560.0 398 397 1560.0 () 5958.50 ... <NA> https://www.wikidata.org/wiki/Q3413722 55-93 (G3-A6) Violin 55-88 (G3-E6) Violin 48-76 (C3-E5) Viola 36-72 (C2-C5) Violoncello
03op44,1a {1: '4/4'} {1: 2} 375 374 1500.0 493 493 1972.0 (120], [121) 5473.50 ... <NA> https://www.wikidata.org/wiki/Q6502965 57-93 (A3-A6) Violin 55-86 (G3-D6) Violin 48-78 (B#2-F#5) Viola 36-69 (C2-A4) Violoncello
03op44,1b {1: '3/4'} {1: 2} 230 225 681.0 309 304 913.0 (65], [66]], [[82], [83) 2615.50 ... <NA> https://www.wikidata.org/wiki/Q6502965 57-93 (A3-A6) Violin 55-81 (G3-A5) Violin 49-78 (C#3-F#5) Viola 36-69 (C2-A4) Violoncello
03op44,1c {1: '2/4'} {1: 2} 155 155 310.0 155 155 310.0 () 980.75 ... <NA> https://www.wikidata.org/wiki/Q6502965 59-91 (B3-G6) Violin 58-79 (A#3-G5) Violin 50-76 (D3-E5) Viola 38-69 (D2-A4) Violoncello
03op44,1d {1: '12/8'} {1: 2} 316 316 1896.0 316 316 1896.0 () 6375.50 ... <NA> https://www.wikidata.org/wiki/Q6502965 55-93 (G3-A6) Violin 55-84 (G3-C6) Violin 48-78 (C3-F#5) Viola 36-71 (C2-B4) Violoncello
04op44,2a {1: '4/4'} {1: 1} 282 277 1128.0 376 376 1504.0 (97, 98, 99, 100, 101], [102) 4113.75 ... <NA> https://www.wikidata.org/wiki/Q7623940 55-91 (G3-G6) Violin 55-86 (G3-D6) Violin 48-76 (C3-E5) Viola 36-71 (C2-B4) Violoncello
04op44,2b {1: '3/4'} {1: 4} 244 244 732.0 244 244 732.0 () 2576.00 ... <NA> https://www.wikidata.org/wiki/Q7623940 56-92 (G#3-G#6) Violin 56-88 (G#3-E6) Violin 48-78 (B#2-F#5) Viola 37-69 (C#2-A4) Violoncello
04op44,2c {1: '4/4'} {1: 1} 83 83 332.0 83 83 332.0 () 1293.00 ... <NA> https://www.wikidata.org/wiki/Q7623940 55-93 (G3-A6) Violin 55-81 (G3-A5) Violin 48-76 (C3-E5) Viola 36-74 (C2-D5) Violoncello
04op44,2d {1: '3/4'} {1: 1, 329: 4, 425: 1} 515 515 1545.0 515 515 1545.0 () 5187.50 ... <NA> https://www.wikidata.org/wiki/Q7623940 55-94 (G3-Bb6) Violin 55-88 (G3-E6) Violin 48-76 (C3-E5) Viola 36-67 (C2-G4) Violoncello
05op44,3a {1: '4/4'} {1: -3} 371 369 1477.0 483 480 1921.0 () 5397.50 ... 174395023.0 https://www.wikidata.org/wiki/Q3413866 55-94 (G3-Bb6) Violin 55-87 (G3-Eb6) Violin 48-77 (C3-F5) Viola 36-73 (C2-Db5) Violoncello
05op44,3b {1: '6/8'} {1: -3} 303 301 903.0 320 317 951.0 () 3008.00 ... 174395023.0 https://www.wikidata.org/wiki/Q3413866 55-91 (G3-G6) Violin 55-82 (G3-Bb5) Violin 48-79 (C3-G5) Viola 36-69 (C2-A4) Violoncello
05op44,3c {1: '3/4'} {1: -4} 131 131 393.0 131 131 393.0 () 1435.50 ... 174395023.0 https://www.wikidata.org/wiki/Q3413866 55-92 (G3-Ab6) Violin 55-80 (G3-Ab5) Violin 48-73 (C3-Db5) Viola 36-63 (C2-Eb4) Violoncello
05op44,3d {1: '4/4'} {1: -3} 324 323 1293.0 324 323 1293.0 () 4859.00 ... 174395023.0 https://www.wikidata.org/wiki/Q3413866 55-94 (G3-Bb6) Violin 55-87 (G3-Eb6) Violin 48-78 (C3-Gb5) Viola 36-68 (C2-Ab4) Violoncello
06op80a {1: '2/2'} {1: -4, 213: -1, 259: -4} 324 324 1296.0 324 324 1296.0 () 4909.00 ... 191502272.0 https://www.wikidata.org/wiki/Q3413720 55-94 (G3-Bb6) Violin 55-84 (G3-C6) Violin 48-79 (C3-G5) Viola 36-68 (C2-Ab4) Violoncello
06op80b {1: '3/4'} {1: -4} 304 301 910.0 388 387 1162.0 (17], [18]], [[88], [89) 3154.00 ... 191502272.0 https://www.wikidata.org/wiki/Q3413720 58-87 (Bb3-Eb6) Violin 55-77 (G3-F5) Violin 48-72 (C3-C5) Viola 36-59 (C2-B3) Violoncello
06op80c {1: '2/4'} {1: -4, 72: 0, 80: -4} 121 120 240.5 121 120 240.5 () 885.62 ... 191502272.0 https://www.wikidata.org/wiki/Q3413720 55-89 (G3-F6) Violin 55-77 (G3-F5) Violin 48-70 (C3-Bb4) Viola 36-63 (C2-Eb4) Violoncello
06op80d {1: '2/4'} {1: -4} 461 461 922.0 461 461 922.0 () 3642.25 ... 191502272.0 https://www.wikidata.org/wiki/Q3413720 56-96 (Ab3-C7) Violin 55-83 (G3-B5) Violin 48-77 (C3-F5) Viola 36-67 (C2-G4) Violoncello

24 rows × 61 columns

Composition years histogram#

Hide source
hist_data = summary.reset_index()
hist_data.corpus = hist_data.corpus.map(corpus_names)
fig = px.histogram(
    hist_data,
    x="composed_end",
    color="corpus",
    labels=dict(
        composed_end="decade",
        count="pieces",
    ),
    color_discrete_map=corpus_name_colors,
    title=f"Temporal coverage of the {N} annotated pieces in the Distant Listening Corpus",
)
fig.update_traces(xbins=dict(size=10))
fig.update_layout(**utils.STD_LAYOUT)
fig.update_legends(font=dict(size=16))
save_figure_as(fig, "pieces_timeline_histogram", height=1250)
fig.show()

Dimensions#

Overview#

def make_overview_table(groupby, group_name="pieces"):
    n_groups = groupby.size().rename(group_name)
    absolute_numbers = dict(
        measures=groupby.last_mn.sum(),
        length=groupby.length_qb.sum(),
        notes=groupby.n_onsets.sum(),
        labels=groupby.label_count.sum(),
    )
    absolute = pd.DataFrame.from_dict(absolute_numbers)
    absolute = pd.concat([n_groups, absolute], axis=1)
    sum_row = pd.DataFrame(absolute.sum(), columns=["sum"]).T
    absolute = pd.concat([absolute, sum_row])
    return absolute


absolute = make_overview_table(summary.groupby("workTitle"))
# print(absolute.astype(int).to_markdown())
absolute.astype(int)
pieces measures length notes labels
String Quartet No. 1 in E-flat Major 4 798 3304 12713 2005
String Quartet No. 2 in A Minor 4 936 3260 15099 2557
String Quartet No. 3 in D Major 4 1070 4387 15969 2397
String Quartet No. 4 in E Minor 4 1119 3737 17450 2787
String Quartet No. 5 in E-flat Major 4 1124 4066 21610 3064
String Quartet No. 6 in F Minor 4 1206 3368 13230 1948
sum 24 6253 22123 96071 14758
def summarize_dataset(D):
    all_metadata = D.get_metadata()
    summary = make_summary(all_metadata)
    return make_overview_table(summary.groupby(level=0))


corpus_summary = summarize_dataset(D)
print(corpus_summary.astype(int).to_markdown())
|                      |   pieces |   measures |   length |   notes |   labels |
|:---------------------|---------:|-----------:|---------:|--------:|---------:|
| mendelssohn_quartets |       24 |       6253 |    22123 |   96071 |    14758 |
| sum                  |       24 |       6253 |    22123 |   96071 |    14758 |

Measures#

all_measures = D.get_feature("measures")
print(
    f"{len(all_measures.index)} measures over {len(all_measures.groupby(level=[0,1]))} files."
)
all_measures.head()
6271 measures over 24 files.
mc mn quarterbeats duration_qb keysig timesig act_dur mc_offset numbering_offset dont_count barline breaks repeats next volta
corpus piece i
mendelssohn_quartets 01op12a 0 1 1 0 4.0 -3 4/4 1 0 <NA> <NA> <NA> <NA> firstMeasure (2,) <NA>
1 2 2 4 4.0 -3 4/4 1 0 <NA> <NA> <NA> <NA> <NA> (3,) <NA>
2 3 3 8 4.0 -3 4/4 1 0 <NA> <NA> <NA> <NA> <NA> (4,) <NA>
3 4 4 12 4.0 -3 4/4 1 0 <NA> <NA> <NA> <NA> <NA> (5,) <NA>
4 5 5 16 4.0 -3 4/4 1 0 <NA> <NA> <NA> <NA> <NA> (6,) <NA>
all_measures.get_default_analysis().plot_grouped()

Harmony labels#

All symbols, independent of the local key (the mode of which changes their semantics).

try:
    all_annotations = D.get_feature("harmonylabels").df
except Exception:
    all_annotations = pd.DataFrame()
n_annotations = len(all_annotations.index)
includes_annotations = n_annotations > 0
if includes_annotations:
    display(all_annotations.head())
    print(f"Concatenated annotation tables contains {all_annotations.shape[0]} rows.")
    no_chord = all_annotations.root.isna()
    if no_chord.sum() > 0:
        print(
            f"{no_chord.sum()} of them are not chords. Their values are:"
            f" {all_annotations.label[no_chord].value_counts(dropna=False).to_dict()}"
        )
    all_chords = all_annotations[~no_chord].copy()
    print(
        f"Dataset contains {all_chords.shape[0]} tokens and {len(all_chords.chord.unique())} types over "
        f"{len(all_chords.groupby(level=[0,1]))} documents."
    )
    all_annotations["corpus_name"] = all_annotations.index.get_level_values(0).map(
        utils.get_corpus_display_name
    )
    all_chords["corpus_name"] = all_chords.index.get_level_values(0).map(
        utils.get_corpus_display_name
    )
else:
    print("Dataset contains no annotations.")
mc mn quarterbeats duration_qb mc_onset mn_onset timesig staff voice volta ... numeral_or_applied_to_numeral intervals_over_bass intervals_over_root scale_degrees scale_degrees_and_mode scale_degrees_major scale_degrees_minor globalkey localkey chord
corpus piece i
mendelssohn_quartets 01op12a 0 1 1 0 2.0 0 0 4/4 4 1 <NA> ... I (M3, P5) (M3, P5) (1, 3, 5) (1, 3, 5), major (1, 3, 5) (1, #3, 5) Eb I I
1 1 1 2 2.0 1/2 1/2 4/4 4 1 <NA> ... IV (M3, P5, m7) (M3, P5, m7) (1, 3, 5, b7) (1, 3, 5, b7), major (1, 3, 5, b7) (1, #3, 5, 7) Eb I V7/IV
2 2 2 4 4.5 0 0 4/4 4 1 <NA> ... IV (M3, P5) (M3, P5) (4, 6, 1) (4, 6, 1), major (4, 6, 1) (4, #6, 1) Eb I IV
3 3 3 17/2 0.5 1/8 1/8 4/4 4 1 <NA> ... V (M2, a4, M6) (M3, P5, m7) (4, 5, 7, 2) (4, 5, 7, 2), major (4, 5, 7, 2) (4, 5, #7, 2) Eb I V2
4 3 3 9 0.5 1/4 1/4 4/4 4 1 <NA> ... I (m3, m6) (M3, P5) (3, 5, 1) (3, 5, 1), major (3, 5, 1) (#3, 5, 1) Eb I I6

5 rows × 52 columns

Concatenated annotation tables contains 14754 rows.
1 of them are not chords. Their values are: {'@none': 1}
Dataset contains 14753 tokens and 1093 types over 24 documents.