def plot_rates_boxplot(spike_trains, population=None, node_groups=None, times=None, title=None, show=True, save_as=None):
    'Creates a box plot of the firing rates taken from a SpikeTrains object or SONATA Spike-Trains file. If start\n    and stop times are not specified from the "times" parameter, will try to parse values from the timestamps data.\n\n    By default will plot all nodes together. To only display a subset of the nodes and/or create groups of nodes use\n    the node_groups options::\n\n        plot_rates_boxplot(\n            \'/path/to/my/spike.h5\',\n            node_groups=[{\'node_ids\': range(0, 70), \'label\': \'pyr\'},\n                         {\'node_ids\': range(70, 100), \'label\': \'inh\'}]\n        )\n\n    :param spike_trains: SpikeTrains object or path to a (SONATA) spikes file.\n    :param population: string. If a spikes-file contains more than one population of nodes, use this to determine which\n        nodes to actually plot. If only one population exists and population=None then the function will find it by\n        default.\n    :param node_groups: None or list of dicts. Used to group sets of nodes by labels and color. Each grouping should\n        be a dictionary with a \'node_ids\' key with a list of the ids. You can also add \'label\' and \'c\' keys for\n        label and color. If None all nodes will be labeled and colored the same.\n    :param title: str, Use to add a title. Default no tile\n    :param show:  bool to display or not display plot. default True.\n    :param save_as: None or str: file-name/path to save the plot as a png/jpeg/etc. If None or empty string will not\n        save plot.\n    :return: matplotlib figure.Figure object\n    '
    spike_trains = __get_spike_trains(spike_trains=spike_trains)
    pop = __get_population(spike_trains=spike_trains, population=population)
    (node_groups, selected_ids) = __get_node_groups(spike_trains=spike_trains, node_groups=node_groups, population=pop)
    spikes_df = spike_trains.to_dataframe(population=pop, with_population_col=False)
    spikes_df = spikes_df[spikes_df['node_ids'].isin(selected_ids)]
    if (times is not None):
        recording_interval = (times[1] - times[0])
        spikes_df = spikes_df[((spikes_df['timestamps'] >= times[0]) & (spikes_df['timestamps'] <= times[1]))]
    else:
        recording_interval = (np.max(spikes_df['timestamps']) - np.min(spikes_df['timestamps']))
    (fig, axes) = plt.subplots()
    rates_data = []
    rates_labels = []
    if ((len(node_groups) == 1) and ('label' not in node_groups[0])):
        node_groups[0]['label'] = 'All Nodes'
    for (i, node_grp) in enumerate(node_groups):
        rates_labels.append(node_grp.get('label', 'Node Group {}'.format(i)))
        grp_ids = node_grp.pop('node_ids')
        grp_spikes = spikes_df[spikes_df['node_ids'].isin(grp_ids)]
        spike_rates = (grp_spikes.groupby('node_ids').size() / (recording_interval / 1000.0))
        rates_data.append(spike_rates)
    axes.boxplot(rates_data)
    axes.set_ylabel('Firing Rates (Hz)')
    axes.set_xticklabels(rates_labels)
    if title:
        axes.set_title(title)
    if save_as:
        plt.savefig(save_as)
    if show:
        plt.show()
    return fig
Creates a box plot of the firing rates taken from a SpikeTrains object or SONATA Spike-Trains file. If start
and stop times are not specified from the "times" parameter, will try to parse values from the timestamps data.

By default will plot all nodes together. To only display a subset of the nodes and/or create groups of nodes use
the node_groups options::

    plot_rates_boxplot(
        '/path/to/my/spike.h5',
        node_groups=[{'node_ids': range(0, 70), 'label': 'pyr'},
                     {'node_ids': range(70, 100), 'label': 'inh'}]
    )

:param spike_trains: SpikeTrains object or path to a (SONATA) spikes file.
:param population: string. If a spikes-file contains more than one population of nodes, use this to determine which
    nodes to actually plot. If only one population exists and population=None then the function will find it by
    default.
:param node_groups: None or list of dicts. Used to group sets of nodes by labels and color. Each grouping should
    be a dictionary with a 'node_ids' key with a list of the ids. You can also add 'label' and 'c' keys for
    label and color. If None all nodes will be labeled and colored the same.
:param title: str, Use to add a title. Default no tile
:param show:  bool to display or not display plot. default True.
:param save_as: None or str: file-name/path to save the plot as a png/jpeg/etc. If None or empty string will not
    save plot.
:return: matplotlib figure.Figure object
def plot_rates_boxplot(spike_trains, population=None, node_groups=None, times=None, title=None, show=True, save_as=None):
    'Creates a box plot of the firing rates taken from a SpikeTrains object or SONATA Spike-Trains file. If start\n    and stop times are not specified from the "times" parameter, will try to parse values from the timestamps data.\n\n    By default will plot all nodes together. To only display a subset of the nodes and/or create groups of nodes use\n    the node_groups options::\n\n        plot_rates_boxplot(\n            \'/path/to/my/spike.h5\',\n            node_groups=[{\'node_ids\': range(0, 70), \'label\': \'pyr\'},\n                         {\'node_ids\': range(70, 100), \'label\': \'inh\'}]\n        )\n\n    :param spike_trains: SpikeTrains object or path to a (SONATA) spikes file.\n    :param population: string. If a spikes-file contains more than one population of nodes, use this to determine which\n        nodes to actually plot. If only one population exists and population=None then the function will find it by\n        default.\n    :param node_groups: None or list of dicts. Used to group sets of nodes by labels and color. Each grouping should\n        be a dictionary with a \'node_ids\' key with a list of the ids. You can also add \'label\' and \'c\' keys for\n        label and color. If None all nodes will be labeled and colored the same.\n    :param title: str, Use to add a title. Default no tile\n    :param show:  bool to display or not display plot. default True.\n    :param save_as: None or str: file-name/path to save the plot as a png/jpeg/etc. If None or empty string will not\n        save plot.\n    :return: matplotlib figure.Figure object\n    '
    spike_trains = __get_spike_trains(spike_trains=spike_trains)
    pop = __get_population(spike_trains=spike_trains, population=population)
    (node_groups, selected_ids) = __get_node_groups(spike_trains=spike_trains, node_groups=node_groups, population=pop)
    spikes_df = spike_trains.to_dataframe(population=pop, with_population_col=False)
    spikes_df = spikes_df[spikes_df['node_ids'].isin(selected_ids)]
    if (times is not None):
        recording_interval = (times[1] - times[0])
        spikes_df = spikes_df[((spikes_df['timestamps'] >= times[0]) & (spikes_df['timestamps'] <= times[1]))]
    else:
        recording_interval = (np.max(spikes_df['timestamps']) - np.min(spikes_df['timestamps']))
    (fig, axes) = plt.subplots()
    rates_data = []
    rates_labels = []
    if ((len(node_groups) == 1) and ('label' not in node_groups[0])):
        node_groups[0]['label'] = 'All Nodes'
    for (i, node_grp) in enumerate(node_groups):
        rates_labels.append(node_grp.get('label', 'Node Group {}'.format(i)))
        grp_ids = node_grp.pop('node_ids')
        grp_spikes = spikes_df[spikes_df['node_ids'].isin(grp_ids)]
        spike_rates = (grp_spikes.groupby('node_ids').size() / (recording_interval / 1000.0))
        rates_data.append(spike_rates)
    axes.boxplot(rates_data)
    axes.set_ylabel('Firing Rates (Hz)')
    axes.set_xticklabels(rates_labels)
    if title:
        axes.set_title(title)
    if save_as:
        plt.savefig(save_as)
    if show:
        plt.show()
    return fig