IQM_Vis.utils package

Submodules

IQM_Vis.utils.gui_utils module

Utils for PyQt6 image, text and graph widgets

class IQM_Vis.utils.gui_utils.MplCanvas(size=(3.5, 3.5), dpi=100, polar=False)[source]

Bases: matplotlib.backends.backend_qtagg.FigureCanvasQTAgg

IQM_Vis.utils.gui_utils.change_im(widget, im, resize=False, rgb_brightness=250, display_brightness=250, border=False)[source]

given a numpy image, changes the given widget Frame

IQM_Vis.utils.gui_utils.get_image_pair_name(data_store)[source]
IQM_Vis.utils.gui_utils.get_metric_image_name(metric, data_store)[source]
IQM_Vis.utils.gui_utils.get_resolutions(data_store)[source]
IQM_Vis.utils.gui_utils.get_trans_dict_from_str(trans_str, return_dict=False)[source]
IQM_Vis.utils.gui_utils.get_transformed_image_name(data_store)[source]
IQM_Vis.utils.gui_utils.str_to_len(string, length=5, append_char='0', plus=False)[source]

IQM_Vis.utils.image_utils module

image helper functions

IQM_Vis.utils.image_utils.calibrate_brightness(im, rgb_brightness, display_brightness, ubyte=True)[source]
IQM_Vis.utils.image_utils.crop_centre(image, scale_factor=2, keep_size=True)[source]
crop to the centre of the image, note this will return a small image size

so it best used as post processing

Parameters
  • image (np.array) – image to be cropped

  • scale_factor (float) – the percentage to zoom in by (for square crop only). 0.5 = 2x zoom out 1 = normal size 2 = 2x zoom in (Defaults to 2 - half the size)

  • keep_size (bool) – resize image to the original size after cropping (Defaults to True)

Returns

cropeed image

Return type

image (np.array)

IQM_Vis.utils.image_utils.get_transform_image(data_store, transform_functions, transform_params)[source]

transform image with image post processing

Parameters
  • data_store – IQM_Vis data_api

  • transform_functions – dict holding transforms (each key is the name of transform, items have key ‘function’)

  • transform_params – dict holding the parameters for transforms (corresponding to keys in transform_functions)

Returns

processed numpy image

Return type

image

IQM_Vis.utils.image_utils.load_image(image_path)[source]

load image as RGB float

IQM_Vis.utils.image_utils.resize_image(img, size=128)[source]

resize image to square or specified size

IQM_Vis.utils.image_utils.resize_to_longest_side(im, side=128)[source]

resize image to longest side

IQM_Vis.utils.image_utils.save_image(img, path)[source]

save image as ubyte

IQM_Vis.utils.plot_utils module

matplotlib plotting helpers TODO: write dev_resources/docs how to use these (currently just have to look at the UI code)

class IQM_Vis.utils.plot_utils.bar_plotter(bar_names, var_names, ax, lim)[source]

Bases: object

plot(bar_name, var_values)[source]
set_plot_lims()[source]
set_style()[source]
show()[source]
IQM_Vis.utils.plot_utils.click_scatter(_plot, change_trans_value_signal, event)[source]

send signal of which data point was clicked

IQM_Vis.utils.plot_utils.compute_metric_for_human_correlation(data_store, transforms, metric_params, trans_str_values, metric)[source]
IQM_Vis.utils.plot_utils.compute_metrics_over_range(data_store, transforms, transform_values, metric_params, metrics_to_use, pbar_signal=None, stop_flag=None, num_steps=11)[source]

compute metrics over a range of trans (when using non initial values for other transforms) currently this method is not being used and instead using the simpler compute_metrics_over_range_single_trans

Parameters
  • data_store – object containing metrics and image

  • transforms (dict) – containing trans functions and min/max/initial values

  • transform_values (dict) – containing the fixed current transform parameter values

Returns

results of IQM values at each transform value across its

whole paramter rance for the reference image

Return type

results (dict)

IQM_Vis.utils.plot_utils.compute_metrics_over_range_single_trans(data_store, transforms, metric_params, metrics_to_use, pbar_signal=None, stop_flag=None, num_steps=11)[source]

compute metrics over a range of trans

Parameters
  • data_store – object containing metrics and image

  • transforms (dict) – containing trans functions and min/max/initial values

Returns

results of IQM values at each transform value across its

whole paramter rance for the reference image

Return type

results (dict)

IQM_Vis.utils.plot_utils.get_all_single_transform_params(transforms, num_steps=11)[source]

get a list of all the individual transforms with a single parameter value useful when doing experiments to make a dataset

IQM_Vis.utils.plot_utils.get_all_slider_values(transforms, num_steps=11)[source]
IQM_Vis.utils.plot_utils.get_correlation_plot(human_scores, metric_scores, axes, metric, change_trans_value_signal)[source]

scatter plot for correlations

IQM_Vis.utils.plot_utils.get_radar_plots_avg_plots(results, metrics_names, transformation_names, axes, lim=1)[source]

plot results on a polar axes -> radar/spider plot

IQM_Vis.utils.plot_utils.get_transform_range_plots(results, transform, axes, lim=1)[source]

plot a single transform range graph of all metrics

IQM_Vis.utils.plot_utils.hover_scatter(_plot, annot, event)[source]
class IQM_Vis.utils.plot_utils.line_plotter(ax, x_label='', y_label='', lim=1)[source]

Bases: object

plot(x, y, label)[source]
set_plot_lims()[source]
set_style()[source]
show()[source]
class IQM_Vis.utils.plot_utils.radar_plotter(radar_names, var_names, ax, lim=1)[source]

Bases: object

plot(radar_name, var_values)[source]
set_plot_lims()[source]
set_style()[source]
show()[source]
class IQM_Vis.utils.plot_utils.scatter_plotter(ax, x_label='', y_label='', lim=1)[source]

Bases: object

plot(x, y, annotations=None, error=None)[source]
set_plot_lims()[source]
set_style()[source]
show()[source]
IQM_Vis.utils.plot_utils.update_annot(ind, _plot, annot)[source]

IQM_Vis.utils.save_utils module

utils for saving experiments, images and figures

IQM_Vis.utils.save_utils.DEFAULT_SAVE_DIR = '/home/matt/IQM-Vis'

getters for experiment files from save dir

IQM_Vis.utils.save_utils.get_IQM_file(dir)[source]
IQM_Vis.utils.save_utils.get_JND_image_names(dir)[source]

load the image names from a JND experiment

IQM_Vis.utils.save_utils.get_JND_ref_image_dir(dir)[source]
IQM_Vis.utils.save_utils.get_JND_ref_image_unprocessed_dir(dir)[source]
IQM_Vis.utils.save_utils.get_JND_user_ID(dir)[source]
IQM_Vis.utils.save_utils.get_human_scores_file(dir)[source]
IQM_Vis.utils.save_utils.get_human_times_file(dir)[source]
IQM_Vis.utils.save_utils.get_image_name_from_human_scores(dir)[source]
IQM_Vis.utils.save_utils.get_image_processing_file(dir)[source]
IQM_Vis.utils.save_utils.get_original_image_file(dir)[source]
IQM_Vis.utils.save_utils.get_original_unprocessed_image_file(dir)[source]
IQM_Vis.utils.save_utils.get_transform_functions_file(dir)[source]
IQM_Vis.utils.save_utils.get_transform_params_file(dir)[source]
IQM_Vis.utils.save_utils.load_json_dict(path)[source]
IQM_Vis.utils.save_utils.load_obj(pickle_path)[source]

load trans dict from pkl file

IQM_Vis.utils.save_utils.make_name_for_trans(trans)[source]
IQM_Vis.utils.save_utils.save_2AFC_experiment_results(trans_names, results_order, save_dir, times_taken=None, IQM_scores_df=None)[source]

save all the experiment reults as csvs

IQM_Vis.utils.save_utils.save_JND_experiment_results(experiment_results, save_dir, IQM_scores_df=None)[source]
IQM_Vis.utils.save_utils.save_and_merge_df_as_csv(df, file)[source]

df need to be indexed

IQM_Vis.utils.save_utils.save_and_merge_rm_duplicates_df_as_csv(df, file)[source]

save only new IQM rows

IQM_Vis.utils.save_utils.save_df_as_csv(df, file, index=False)[source]
IQM_Vis.utils.save_utils.save_json_dict(path, dict_)[source]
IQM_Vis.utils.save_utils.save_obj(pickle_path, trans)[source]

save transforms as pickle file

Module contents