Skip to content

Commit

Permalink
Merge pull request #108 from jsmentch/master
Browse files Browse the repository at this point in the history
edits to readthedocs
  • Loading branch information
adelavega committed Aug 2, 2022
2 parents 80cead1 + 3c86fc3 commit 4cec92c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
10 changes: 5 additions & 5 deletions docs/source/analyses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Creating analyses
Another major use of `pyNS` is to create `Neuroscout` analyses programatically.

This is particulary useful for users that want to create a large number of analyses, or specify a
BIDS Stats Model that is not currently support by the Neuroscout frontend web application.
BIDS Stats Model that is not currently supported by the Neuroscout frontend web application.

.. note::
To update analyses, you must be authenticated and be the owner of a particular analysis
Expand All @@ -20,7 +20,7 @@ BIDS Stats Model that is not currently support by the Neuroscout frontend web ap
Querying for Analyses
----------------------

First, as before, you can use `pyNS` to query and look up existing an
First, as before, you can use `pyNS` to query and look up existing any existing public analyses.

For example, we can find two arbitrary analyses named `brightness` by name:

Expand All @@ -37,7 +37,7 @@ The Analysis object
To make it easier to work with the analyses, `pyNS` provides a special `Analysis` which represents a single Neuroscout analysis
as a Python object. To create this object, you can use :meth:`pyns.endpoints.analyses.get_analysis` to create an object from an Analysis' ``hash_id``

This `Analysis` object has all attributes of an analysis as class attributes that can be modified and updated.
This `Analysis` object has all the attributes of an analysis as class attributes that can be modified and updated.

.. doctest::

Expand Down Expand Up @@ -66,7 +66,7 @@ This `Analysis` object has all attributes of an analysis as class attributes tha
Modifying analyses
----------------------

Assumping you are the owner of an analysis--and the analysis is still editable--you can modify it using the `Analysis` object.
Assuming you are the owner of an analysis--and the analysis is still editable--you can modify it using the `Analysis` object.
Simply modify the attributes of the :class:`pyns.endpoints.Analysis` object and then call `Analysis.push()` to push the changes to the server


Expand All @@ -88,7 +88,7 @@ Creating new analyses
----------------------

You can use the :meth:`pyns.endpoints.analyses.create_analysis` function to create a new :class:`pyns.endpoints.Analysis` object corresponding to a new analysis you just created.
This function mak`es it easy to create an analysis, by allowing you to specify your predictors, dataset, and other attributes
This function makes it easy to create an analysis, by allowing you to specify your predictors, dataset, and other attributes
of the analysis by name.

::
Expand Down
38 changes: 19 additions & 19 deletions docs/source/querying.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ For each of the available endpoints, the Neuroscout API provides a number of que

The valid arguments for each endpoint are listed in the official Neuroscout `API documentation <https://neuroscout.org/api/>`_.

In the documentation, we can see that we the ``name`` argument can be used to find a specific dataset.
In the documentation, we can see that the ``name`` argument can be used to find a specific dataset.

.. doctest::

Expand All @@ -22,9 +22,9 @@ In the documentation, we can see that we the ``name`` argument can be used to fi
>>> dataset['long_description']
'This dataset includes the data of 18 particpants who watched Sherlock movie and data of 18 participants who watched Merlin movie.'

---------------------------------------------------
Human friendly queries: conversion of _name to _id
---------------------------------------------------
----------------------------------
Human friendly queries
----------------------------------

`pyNS`` adds several conveniences to the Neuroscout API to make querying easier.

Expand All @@ -37,10 +37,10 @@ which requires first looking up the dataset by name and then using the ``dataset
>>> neuroscout.runs.get(dataset_id=5)[0] # First run of SherlockMerlin
{'acquisition': None, 'dataset_id': 5, 'duration': 1453.5, 'id': 1428, 'number': None, 'session': None, 'subject': '17', 'task': 45, 'task_name': 'SherlockMovie'}

To make this query easier, `pyNS` automatically converts all arguments ending in ``_name`` to ``_id``, by looking up the corresponding `id`
To make this query easier, `pyNS` automatically converts all arguments ending in ``_name`` to ``_id``, by looking up the corresponding ``id``
in the Neuroscout API prior to making the subsequent API call.

For example, we can ask for the first run for the dataset ``NaturalisticNeuroimagingDatabase``, for the task ``500daysofsummer`` by name:
For example, we can ask for the first run from the dataset ``NaturalisticNeuroimagingDatabase``, for the task ``500daysofsummer`` by name:

.. doctest::

Expand All @@ -52,23 +52,23 @@ For example, we can ask for the first run for the dataset ``NaturalisticNeuroima
For example, the official API documentation does not list `dataset_name` as a valid argument for
`neuroscout.datasets.get`, and instead lists `dataset_id` as required.

----------------------------------------------------
Looking up Predictors by run_id, and by run entities
----------------------------------------------------
----------------------------------
Looking up Predictors by run
----------------------------------

Neuroscout provides a large number of pre-extracted ``Predictors`` all tasks and datasets.
It's important to note that the ``Predictors`` are always associated with ``run_ids`` rather than tasks or session directly, to enable maximum experimental design flexibility.
Neuroscout provides a large number of pre-extracted ``Predictors`` for all tasks and datasets.
It's important to note that the ``Predictors`` are always associated with ``run_ids`` rather than tasks or sessions directly, to enable maximum experimental design flexibility.
This means that when looking up ``Predictors``, we must refer to one or more ``run_ids``.

For example, here's we can ask for an arbitrary `predictor` associated with for the first run of ``500daysofsummer`` by referencing the ``run_id``:
For example, here we can ask for an arbitrary `predictor` associated with the first run of ``500daysofsummer`` by referencing the ``run_id``:

.. doctest::

>>> neuroscout.predictors.get(run_id=1581)[0]
{'dataset_id': 28, 'description': 'Degree of blur/sharpness of the image', 'extracted_feature': {'created_at': '2021-05-05 00:52:59.856713', 'description': 'Degree of blur/sharpness of the image', 'extractor_name': 'SharpnessExtractor', 'id': 425739, 'modality': 'image', 'resample_frequency': None}, 'id': 40254, 'max': 1.0, 'mean': 0.8604099357979763, 'min': 0.0, 'name': 'sharpness', 'num_na': 0, 'private': False, 'source': 'extracted'}


`pyNS`` makes this query easier by allowing the user to instead pass `run` identifiers directly, and automatically converting them to ``run_ids``.
`pyNS` makes this query easier by allowing the user to instead pass `run` identifiers directly, and automatically converting them to ``run_ids``.
For example, we can ask for a list of all `predictors` associated with the the task ``500daysofsummer`` directly:

.. doctest::
Expand All @@ -80,9 +80,9 @@ For example, we can ask for a list of all `predictors` associated with the the t

Under the hood, `pyNS` looks up the ``dataset_id`` and ``task_id`` for the given ``dataset_name`` and ``task_name`` and then uses these to lookup the ``run_id`` for the given `run`.

-------------------------------------------------
Getting the data: querying for `predictor_events`
-------------------------------------------------
----------------------------------
Getting the predictor data
----------------------------------

An important aspect of `pyNS` is the ability to retrieve moment by moment events for specific predictors.

Expand Down Expand Up @@ -113,7 +113,7 @@ Friendly outputs to pandas DataFrames
------------------------------------------

You can easily convert any query result to a pandas DataFrame. Simply pass the argument ``output_type='df'`` to the query.
This is particularly useful for `PredictorEvents`, as the are naturally represented as a pandas DataFrame`.
This is particularly useful for `PredictorEvents`, as the are naturally represented as a pandas DataFrame.

::

Expand All @@ -136,7 +136,7 @@ This is particularly useful for `PredictorEvents`, as the are naturally represen


To make the interpretation of the query easier, `pyNS` automatically converts all columns ending in `_id` to their respective names.
In the case of ``run_id``, we fetch the corresponding BIDS entities (i.e. ``subject``, ``number``, ``session``, ``acquisition``) and add them to the DataFrame.
In the case of ``run_id``, we fetch the corresponding BIDS entities (e.g. ``subject``, ``number``, ``session``, ``acquisition``) and add them to the DataFrame.

.. note::
Asking for PredictorEvents for a dataset or task without specifying a ``predictor_name`` may results in a very long running query.
Asking for PredictorEvents for a dataset or task without specifying a ``predictor_name`` may results in a very long running query.
4 changes: 2 additions & 2 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ First, instantiate a :py:class:`pyns.Neuroscout` API Client object, optionally p
Google single-sign-on is not currently supported in pyNS. Please register for a Neuroscout account if you
wish to use `pyNS` to create analyses.

The :py:class:`pyns.Neuroscout` object provides a connection the Neuroscout API, with each major endpoint represented as
The :py:class:`pyns.Neuroscout` object provides a connection to the Neuroscout API, with each major endpoint represented as
an object linked to the main :py:class:`pyns.Neuroscout` object.

For example, using the attribute `neuroscout.datasets`, we can query the Neuroscout API for a list of datasets.
Expand All @@ -34,4 +34,4 @@ For example, using the attribute `neuroscout.datasets`, we can query the Neurosc


The available Neuroscout endpoints are listed here: :py:mod:`pyns.endpoints`, and currently include:
``['analyses', 'datasets', 'tasks', 'runs', 'predictors', 'predictor_events', 'user']``
``['analyses', 'datasets', 'tasks', 'runs', 'predictors', 'predictor_events', 'user']``

0 comments on commit 4cec92c

Please sign in to comment.