pymaid.get_user_actions

pymaid.get_user_actions(users=None, neurons=None, start_date=None, end_date=None, remote_instance=None)[source]

Get timestamps of user actions (creations, editions, reviews, linking).

Important

This function returns most but not all user actions:

1. The API endpoint used for finding neurons worked on by a given user
   (:func:`pymaid.find_neurons`) does not return single-node neurons.
   Hence, placing e.g. postsynaptic nodes is not taken into account.
2. Any creation is also an edit. However, only the last edit is kept
   track of. So each creation counts as an edit for the creator until a
   different user makes an edit.
Parameters:
  • users (str | list, optional) – Users login(s) for which to return timestamps.

  • neurons (list of skeleton IDs | CatmaidNeuron/List, optional) – Neurons for which to return timestamps. If None, will find neurons by user.

  • start_date (tuple | datetime.date, optional) –

  • end_date (tuple | datetime.date, optional) – Start and end date of time window to check.

  • remote_instance (CatmaidInstance, optional) –

Returns:

DataFrame in which each row is a user action:

   user   timestamp   action
0
1
...

Return type:

pandas.DataFrame

Examples

In the first example we will have a look at how active a user is over the course of a day.

>>> import pandas as pd
>>> import matplotlib.pyplot as plt
>>> # Get all actions for a single user
>>> actions = pymaid.get_user_actions(users='schlegelp',
....                                  start_date=(2017, 11, 1))
>>> # Group by hour and see what time of the day user is usually active
>>> actions.set_index(pd.DatetimeIndex(actions.timestamp), inplace=True)
>>> hours = actions.groupby(actions.index.hour).count()
>>> ax = hours.action.plot()
>>> plt.show()
>>> # Plot day-by-day activity
>>> ax = plt.subplot()
>>> ax.scatter(actions.timestamp.date.values,
...            actions.timestamp.time.values,
...            marker='_')