@staticmethod
def add_epochs(recording, nwbfile):
    """
        Auxiliary static method for nwbextractor.
        Adds epochs from recording object to nwbfile object.
        """
    for name, ep in recording._epochs.items():
        if nwbfile.epochs is None:
            nwbfile.add_epoch(start_time=recording.frame_to_time(ep[
                'start_frame']), stop_time=recording.frame_to_time(ep[
                'end_frame']), tags=name)
        elif [name] in nwbfile.epochs['tags'][:]:
            ind = nwbfile.epochs['tags'][:].index([name])
            nwbfile.epochs['start_time'].data[ind] = recording.frame_to_time(ep
                ['start_frame'])
            nwbfile.epochs['stop_time'].data[ind] = recording.frame_to_time(ep
                ['end_frame'])
        else:
            nwbfile.add_epoch(start_time=recording.frame_to_time(ep[
                'start_frame']), stop_time=recording.frame_to_time(ep[
                'end_frame']), tags=name)
    return nwbfile
