sigsep / sigsep-mus-2018-analysis

Analysis and Visualization for SiSEC 2018
9 stars 2 forks source link

Example segmentation of results based on previews #3

Closed deeuu closed 6 years ago

deeuu commented 6 years ago

Hey,

Here's a function I'm using to segment the main SiSEC 2018 results generated by this repo, based on the track sample times (csv file) generated by sigsep-mus-previews:

def segment_sisec18_given_previews(sisec18, previews, sample_rate=44100):

    def _filter(track):

        preview = previews[previews.iloc[:, 0].isin(track.track)]

        start_time = preview.iloc[0, 1] // sample_rate
        end_time = preview.iloc[0, 2] // sample_rate
        loc = ((track['time'] >= start_time) & (track['time'] <= end_time))

        return track[loc]

    sisec18 = sisec18[sisec18.track.isin(previews.iloc[:, 0])]

    track_group = sisec18.groupby('track')
    sisec18 = track_group.apply(_filter)

    return sisec18

Just thought you might find it helpful.

If it would be useful here, let me know where you would like it adding and I'll set up a pull request.

faroit commented 6 years ago

I actually somehow oversaw this. I guess it can be closes as we have https://github.com/sigsep/sigsep-mus-preview-generator