PyHa icon indicating copy to clipboard operation
PyHa copied to clipboard

Visualize multiple categories

Open marco-bazzani opened this issue 3 years ago • 6 comments

Closes #135

These changes allow the visualize_spectrogram function to graph multiple different categories, assigning each category a different label and color. All actual changes are done in the spectrogram_graph function, since visualize_spectrogram just calls that to draw the final graph. If there are more than six categories, colors will start being re-used.

Tested using a modified version of the Screaming Piha test dataset provided on here. Here are some results from different calls of the function, to make sure my changes matched the intended results:

spectrogram_visualization(clip_path, premade_annotations_df = manual_df[manual_df["IN FILE"] == "ScreamingPiha2.wav"],premade_annotations_label = "Piha Human Labels") image

spectrogram_visualization(clip_path,automated_df = True, isolation_parameters = isolation_parameters) image

spectrogram_visualization(clip_path,automated_df = True,isolation_parameters=isolation_parameters,premade_annotations_df = manual_df[manual_df["IN FILE"] == "ScreamingPiha2.wav"]) image

marco-bazzani avatar Dec 15 '22 13:12 marco-bazzani

Great work so far! I have a couple changes I'd like to see:

  1. Contrast - Given that the spectrogram is blue, it'll be hard to see colors like blue and cyan (green to an extent) overlaid on it. Can we limit the range of colors to those that are easier to see (e.g warm colors)?
  2. Limited classes - If we want to display more than 6 classes, what happens? It would be nice to have set colors (for consistency), then further colors are autogenerated in case someone is working with large amounts of classes.
  3. Customization - Along with consistency, can we have the option to specify colors? I'm thinking of a use case where you want to generate multiple spectrograms, but the color ends up different for the same class across multiple (e.g. Screaming Piha is red on one spectrogram, orange on another). There are multiple ways to go about this, but think from a user's perspective how you would want this to be standardized.

sprestrelski avatar Dec 15 '22 18:12 sprestrelski

Currently, the colors can still change between each function call/different data sets. Is this the desired behavior, or should I make label colors persistent consistent throughout the entire program?

marco-bazzani avatar Dec 16 '22 11:12 marco-bazzani

It'd be great if they were consistent throughout the whole program.

sprestrelski avatar Dec 16 '22 12:12 sprestrelski

Commit https://github.com/UCSD-E4E/PyHa/pull/146/commits/468cb4bd201aedec13811a44cf67e74c8bde5bad is misnamed, that one is a large refactoring that changes spectrogram visualization to take a dataframe as input.

marco-bazzani avatar Dec 22 '22 14:12 marco-bazzani

Once these changes are approved, I'll modify the tutorial notebook to properly call the new functions

marco-bazzani avatar Dec 22 '22 14:12 marco-bazzani

Here are some examples of test outputs from this code: The automated labels are always one color because they only have one label, but they are drawn with the same function as the manual labels, so once the models support multiple labels, the graphs will be able to show it.

2022-12-22_09-29 2022-12-22_09-28 2022-12-22_09-27

marco-bazzani avatar Dec 23 '22 06:12 marco-bazzani