pymaid.get_time_invested

pymaid.get_time_invested(x, mode='SUM', by='USER', minimum_actions=10, max_inactive_time=3, treenodes=True, connectors=True, links=True, start_date=None, end_date=None, remote_instance=None)[source]

Calculate the time spent working on a set of neurons.

Use minimum_actions and max_inactive_time to fine tune how time invested is calculated: by default, time is binned over 3 minutes in which a user has to perform 3x10 actions for that interval to be counted towards the time spent tracing.

Important

Creation/Edition/Review times can overlap! This is why total time spent is not just creation + edition + review.

Please note that this does currently not take placement of pre-/postsynaptic nodes into account!

Be aware of the minimum_actions parameter: at low values even a single action (e.g. connecting a node) will add considerably to time invested. To keep total reconstruction time comparable to what Catmaid calculates, you should consider about 10 actions/minute (= a click every 6 seconds) and max_inactive_time of 3 mins.

CATMAID gives reconstruction time across all users. Here, we calculate the time spent tracing for individuals. This may lead to a discrepancy between sum of time invested over of all users from this function vs. CATMAID’s reconstruction time.

Parameters
  • x

    Which neurons to check. Can be either:

    1. skeleton IDs (int or str)

    2. neuron name (str, must be exact match)

    3. annotation: e.g. ‘annotation:PN right’

    4. CatmaidNeuron or CatmaidNeuronList object

    If you pass a CatmaidNeuron/List, its node/connectors are used to calculate time invested. You can exploit this to get time spent reconstructing in given compartment of a neurons, e.g. by pruning it to a volume before passing it to get_time_invested.

  • mode ('SUM' | 'SUM2' | 'OVER_TIME' | 'ACTIONS', optional) –

    1. ‘SUM’ will return total time invested (in minutes) broken down by creation, edition and review.

    2. ’SUM2’ will return total time invested (in minutes) broken down by treenodes, connectors and links.

    3. ’OVER_TIME’ will return minutes invested/day over time.

    4. ’ACTIONS’ will return actions (node/connectors placed/edited) per day.

  • by ('USER' | 'NEURON', optional) – Determines whether the stats are broken down by user or by neuron.

  • minimum_actions (int, optional) – Minimum number of actions per minute to be counted as active.

  • max_inactive_time (int, optional) – Interval in minutes over which time invested is binned. Essentially determines how much time can be between bouts of activity.

  • treenodes (bool, optional) – If False, treenodes will not be taken into account.

  • connectors (bool, optional) – If False, connectors will not be taken into account.

  • links (bool, optional) – If False, connector links will not be taken into account.

  • start_date (iterable | datetime.date | numpy.datetime64, optional) – Restricts time invested to window. Applies to creation but not edition time! If iterable, must be year, month day, e.g. [2018, 1, 1].

  • end_date (iterable | datetime.date | numpy.datetime64, optional) – See start_date.

  • remote_instance (CatmaidInstance, optional) – Either pass explicitly or define globally.

Returns

If mode='SUM', values represent minutes invested:

       total  creation  edition  review
user1
user2
..
.

If mode='SUM2', values represent minutes invested:

       total  treenodes  connectors  links
user1
user2
..
.

If mode='OVER_TIME' or mode='ACTIONS':

       date1  date2  date3  ...
user1
user2
..
.

For OVER_TIME, values respresent minutes invested on that day. For ACTIONS, values represent actions (creation, edition, review) on that day.

Return type

pandas.DataFrame

Examples

Get time invested for a set of neurons:

>>> da1 = pymaid.get_neurons('annotation:glomerulus DA1')
>>> time = pymaid.get_time_invested(da1)

Get time spent tracing in a specific compartment:

>>> da1_lh = pymaid.prune_by_volume('LH_R', inplace=False)
>>> time_lh = pymaid.get_time_invested(da1_lh)

Get contributions within a given time window:

>>> time_jan = pymaid.get_time_invested(da1,
...                                     start_date=[2018, 1, 1],
...                                     end_date=[2018, 1, 31])

Plot pie chart of contributions per user using Plotly:

>>> import plotly
>>> stats = pymaid.get_time_invested(skids, remote_instance)
>>> # Use plotly to generate pie chart
>>> fig = {"data": [{"values": stats.total.tolist(),
...        "labels": stats.user.tolist(), "type" : "pie" }]}
>>> plotly.offline.plot(fig)

Plot reconstruction efforts over time:

>>> stats = pymaid.get_time_invested(skids, mode='OVER_TIME')
>>> # Plot time invested over time
>>> stats.T.plot()
>>> # Plot cumulative time invested over time
>>> stats.T.cumsum(axis=0).plot()
>>> # Filter for major contributors
>>> stats[stats.sum(axis=1) > 20].T.cumsum(axis=0).plot()