src.visualise package

Submodules

src.visualise.all_metrics_graphs module

Code for generating plots that combine all performance success metrics

src.visualise.all_metrics_graphs.generate_all_metrics_plots(mds: list[src.analyse.phase_correction_models.PhaseCorrectionModel], output_dir: str) None

Generates all plots in this file, with required arguments and inputs

src.visualise.asynchrony_graphs module

Code for generating plots using the ensemble asynchrony success metric

src.visualise.asynchrony_graphs.generate_asynchrony_plots(mds: list, output_dir: str, corpus_dir: str) None

Generates all plots in this file, with required arguments and inputs

src.visualise.ioi_variability_graphs module

Code for generating plots using the timing irregularity success metric

src.visualise.ioi_variability_graphs.generate_tempo_stability_plots(mds: list, output_dir: str)

Generates all plots in this file, with required arguments and inputs

src.visualise.jitter_measurement_graphs module

Code for generating plots from recordings of network latency and jitter

class src.visualise.jitter_measurement_graphs.JitterMeasurementAnalysis(directory: str, **kwargs)

Bases: object

Measures inter-beat latency for recordings in Librosa

_extract_iois(onset_times: ndarray) array

Extracts inter-onset intervals between real and delayed metronome clicks

_extract_onsets(y: ndarray) array

Extracts onsets from audio file in Librosa

_get_files() list[str]

Returns strings of valid filepaths

static _get_minimum(list_of_arrays: list[numpy.array]) float

Gets the minimum shape of multiple input arrays, used when subsetting

_load_audio() list[numpy.array]

Loads audio into librosa

_match_latency_onset_and_ioi() list[pandas.core.frame.DataFrame]

Matches each inter-onset interval together with the initial onset time

class src.visualise.jitter_measurement_graphs.LinePlotJitterMeasurement(arrays, **kwargs)

Bases: BasePlot

Creates lineplots (with marginal histrograms) for multiple recordings

_create_plot() None

Creates the line plot and histogram for each array

_format_array(arrs: list[numpy.array]) Generator

Formats array returned from each recording

_format_ax() None

Formats all axis

_format_fig() None

Formats figure-level attributes

_format_main_ax() None

Formats the main line plots

_format_marginal_ax() None

Formats the marginal histograms

create_plot() tuple[matplotlib.figure.Figure, str]

Called from outside the class and generates the plot, then saves in decorator

src.visualise.jitter_measurement_graphs.generate_latency_measurement_plots(input_dir: str, output_dir: str, **kwargs) None

Generates all plots in this file, with required arguments and inputs

src.visualise.misc_graphs module

Code for generating plots that don’t fit anywhere else

src.visualise.misc_graphs.generate_misc_plots(mds: list, output_dir: str) None

Generates all plots in this file, with required arguments and inputs

src.visualise.phase_correction_graphs module

Code for generating plots from the phase correction models

src.visualise.phase_correction_graphs.generate_phase_correction_plots(mds: list[src.analyse.phase_correction_models.PhaseCorrectionModel], output_dir: str) None

Generates all plots in this file, with required arguments and inputs

src.visualise.run_visualisations module

Central file for running all visualisation functions, called by run.cmd

src.visualise.simulations_graphs module

Code for generating plots from the simulation objects

src.visualise.simulations_graphs.generate_plots_for_individual_performance_simulations(sims: list[src.analyse.simulations.Simulation], output_dir: str) None

Deprecated(?)

src.visualise.simulations_graphs.generate_plots_for_simulations_with_coupling_parameters(sims_params: list[src.analyse.simulations.Simulation], output_dir: str) None

Generates all plots in this file, with required arguments and inputs

src.visualise.success_graphs module

Code for generating plots using the self-reported success metric

src.visualise.success_graphs.generate_questionnaire_plots(mds: list, output_dir: str) None

Generates all plots in this file, with required arguments and inputs

src.visualise.tempo_slope_graphs module

Code for generating plots using the tempo slope success metric

src.visualise.tempo_slope_graphs.generate_tempo_slope_plots(mds: list, output_dir: str, corpus_dir: str)

Generates all plots in this file, with required arguments and inputs

src.visualise.visualise_utils module

Utility functions, classes, and constants for creating figures and tables

class src.visualise.visualise_utils.BasePlot(**kwargs)

Bases: object

Base plotting class from which others inherit

src.visualise.visualise_utils.alpha_func(pal) ListedColormap

Shade a color map by given alpha value (can be used in color bars etc)

src.visualise.visualise_utils.append_count_in_rows_to_df(df_avg_slopes: DataFrame, time_col: str = 'elapsed') DataFrame

Appends empty rows to a dataframe corresponding with every second of the count-in where no notes were played. Input dataframe should be in the format returned by average_bpms (i.e. average BPM across performers per second) Used when creating videos of tempo slopes.

src.visualise.visualise_utils.bootstrap_mean_difference(a1: Series, a2: Series, quantile: float = 0.025, n_boot: int = 10000)

Helper function to bootstrap the mean difference between two arrays (a1, a2). Number of bootstraps is given by the N_BOOT constant if not provided. Quantile is set to 2.5, for 95% confidence intervals.

src.visualise.visualise_utils.break_axis(ax1: Axes, ax2: Axes, d: float = 0.015) None

Add a vertical breaks into two axis to show change in scale

src.visualise.visualise_utils.create_normalised_cmap(slopes: list) TwoSlopeNorm

Create a normalised cmap between a minimum, median, and maximum value.

src.visualise.visualise_utils.create_output_folder(out)

Create a folder to store the plots, with optional subdirectory. Out should be a full system path.

src.visualise.visualise_utils.create_scalar_cbar(norm: TwoSlopeNorm) ScalarMappable

Creates a scalar colourbar object to be placed on a figure

src.visualise.visualise_utils.get_gridspec_array(fig: Optional[Figure] = None, ncols: int = 2) array

Create an array of axes with unequal numbers of plots per row/column Returns an array that can be indexed in the same way as the array normally returned by plt.subplots()

src.visualise.visualise_utils.get_significance_asterisks(p: float) str

Converts a raw p-value into asterisks, showing significance boundaries.

src.visualise.visualise_utils.interpolate_df_rows(df: DataFrame) DataFrame

Adds additional rows to a tempo slope dataframe, used when upscaling video FPS.

src.visualise.visualise_utils.load_from_disc(output_dir: str, filename: str = 'phase_correction_mds.p') list

Try and load models from disc

src.visualise.visualise_utils.plot_decorator(plotter: callable)

Decorator applied to any plotting function. Used to create a folder, save plot into this, then close it cleanly and exit.

src.visualise.visualise_utils.resample(perf: DataFrame, col: str = 'my_onset', resample_window: str = '1s') DataFrame

Resamples an individual performance dataframe to get mean of every second.

Module contents

Scripts to create exploratory and results oriented visualisations