This is from a Jupyter Notebook. View & download the notebook here.


Getting Documentation via Help()

Load AUViewer API & Print Help for API

[1]:
# Import the AUViewer API and set the data path
import auviewer.api as api
api.setDataPath('~/myproject')
[2]:
# Print help documentation for api (these will be the top-level methods available)
help(api)
Help on module auviewer.api in auviewer:

NAME
    auviewer.api - Python API for working with AUViewer.

FUNCTIONS
    downsampleFile(filepath: str, destinationpath: str) -> bool
        Downsamples an original file, placing the processed file in the destination folder.
        Raises an exception in case of error.
        :param filepath: path to the original file
        :param destinationpath: path to the destination folder
        :return: None

    getProject(id) -> Union[auviewer.project.Project, NoneType]
        Returns the project with matching ID.
        :return: the project instance belonging to the id, or None if not found

    getProjects() -> Dict[int, auviewer.project.Project]
        Returns loaded projects as a dict.
        :return: dict mapped from project ID to project instance of all loaded projects

    getProjectsPayload(user_id) -> List[Dict]
        Returns a list of project information accessible to a given user.
        :return: list of objects containing project information

    listAvailableProjects() -> List[List[str]]
        Returns list of available projects (ID, name, path) from the database.
        These projects are not necessarily loaded in memory (that is done using
        loadProjects() or loadProject().
        :return:

    listLoadedProjects() -> List[List[str]]
        Returns list of projects loaded in memory (ID, name, path).
        :return: list of lists

    listUsers() -> List[List[str]]
        Returns list of users (ID, email, first name, last name)
        :return: list of lists

    loadProject(id) -> Union[auviewer.project.Project, NoneType]
        Load a project into memory. Returns the project instance if successful.
        :return: the project instance, or None

    loadProjects() -> Dict[int, auviewer.project.Project]
        Load or reload projects into memory. If new projects are found on disk, they
        will be added to the database & loaded as well. Returns the same output as
        getProjects().
        :return: dict mapped from project ID to project of all loaded projects

    scaffoldProjectFolder(projDirPathObj)
        Generate the baseline project folder contents as needed

    setDataPath(path, load_projects=False) -> None
        Loads a data path for use via Python (instead of as a web server). If the
        optional load_projects parameter is False, then projects must be loaded
        manually using loadProject() or loadProjects().

    validateProjectFolder(projDirPathObj)
        Raises an exception if the project folder is invalid

DATA
    Dict = typing.Dict
    List = typing.List
    Optional = typing.Optional
    config = {'M': 3000, 'builtinDefaultInterfaceTemplates': '{\n\t"realti...
    loadedProjects = []

FILE
    /Users/guswelter/miniconda3/envs/auv/lib/python3.8/site-packages/auviewer/api.py


Load Project & Print Help for Project

[3]:
# List available projects
api.listAvailableProjects()
[3]:
[[1, 'my_new_project', '/Users/guswelter/myproject/projects/my_new_project']]
[4]:
# Load project
p = api.loadProject(1)
[5]:
# Print help documentation for project
help(p)
Help on Project in module auviewer.project object:

class Project(builtins.object)
 |  Project(projectModel, processNewFiles=True)
 |
 |  Represents an auviewer project.
 |
 |  Methods defined here:
 |
 |  __del__(self)
 |      Cleanup
 |
 |  __init__(self, projectModel, processNewFiles=True)
 |      The project name should also be the directory name in the projects directory.
 |
 |  createPatternSet(self, name: str, description=None, showByDefault: bool = True) -> auviewer.patternset.PatternSet
 |      Create and return a new pattern set.
 |      :return: a new PatternSet instance
 |
 |  detectPatterns(self, type, series, thresholdlow, thresholdhigh, duration, persistence, maxgap, expected_frequency=0, min_density=0)
 |      Run pattern detection on all files, and return a DataFrame of results.
 |      This DataFrame, or a subset thereof, can be passed into PatternSet.addPatterns() if desired.
 |
 |  getAnnotations(self, annotation_id: Union[int, List[int], NoneType] = None, file_id: Union[int, List[int], NoneType] = None, pattern_id: Union[int, List[int], NoneType] = None, pattern_set_id: Union[int, List[int], NoneType] = None, series: Union[~AnyStr, List[~AnyStr], NoneType] = None, user_id: Union[int, List[int], NoneType] = None) -> pandas.core.frame.DataFrame
 |      Returns a dataframe of annotations for this project, optionally filtered.
 |
 |  getAnnotationsOutput(self, user_id: int)
 |      Returns a list of user's annotations for all files in the project
 |
 |  getFile(self, id)
 |      Returns the file with matching ID or None.
 |
 |  getFileByFilename(self, filename)
 |      Returns the file with matching filename or None.
 |
 |  getInitialPayload(self, user_id)
 |      Returns initial project payload data
 |
 |  getPatternSet(self, id) -> Union[auviewer.patternset.PatternSet, NoneType]
 |      Get project's pattern set by ID.
 |      :return: the PatternSet instance belonging to the id, or None if not found
 |
 |  getPatternSets(self) -> Dict[int, auviewer.patternset.PatternSet]
 |      Get project's pattern sets.
 |      :return: a dict of the project's PatternSet instances, indexed by id
 |
 |  getPatterns(self, file_id: Union[int, List[int], NoneType] = None, pattern_id: Union[int, List[int], NoneType] = None, pattern_set_id: Union[int, List[int], NoneType] = None, series: Union[~AnyStr, List[~AnyStr], NoneType] = None, user_id: Union[int, List[int], NoneType] = None) -> pandas.core.frame.DataFrame
 |      Returns a dataframe of patterns for this project, optionally filtered.
 |
 |  getTotalPatternCount(self) -> int
 |      Get total count of patterns in all the project's pattern sets
 |      :return: number of patterns
 |
 |  listFiles(self) -> List[List[str]]
 |      Returns list of files for the project (ID, filename, file path, downsample path).
 |      :return: list of lists
 |
 |  listPatternSets(self) -> List[List[str]]
 |      Returns list of pattern sets (ID, names).
 |      :return: list of l:return:
 |
 |  loadPatternSets(self) -> None
 |      Load or reload the project's pattern sets.
 |
 |  loadProjectFiles(self, processNewFiles=True)
 |      Load or reload files belonging to the project, and process new files if desired.
 |
 |  setName(self, name)
 |      Rename the project.
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables (if defined)
 |
 |  __weakref__
 |      list of weak references to the object (if defined)

Load File & Print Help for File

[6]:
# List project files
p.listFiles()
[6]:
[[1,
  'sample_patient.h5',
  '/Users/guswelter/myproject/projects/my_new_project/originals/sample_patient.h5',
  '/Users/guswelter/myproject/projects/my_new_project/processed/sample_patient_processed.h5']]
[7]:
# Get a project file
f = p.getFile(1)
[8]:
# Print help documentation for file
help(f)
Help on File in module auviewer.file object:

class File(builtins.object)
 |  File(projparent, id, origFilePathObj, procFilePathObj, processNewFiles=True, processOnly=False)
 |
 |  Represents a project file. File may operate in file- or realtime-mode. In file-mode, all data is written to & read
 |  from a file. In realtime-mode, no file is dealt with and instead everything is kept in memory. If no filename
 |  parameter is passed to the constructor, File will operate in realtime-mode.
 |
 |  Methods defined here:
 |
 |  __del__(self)
 |
 |  __init__(self, projparent, id, origFilePathObj, procFilePathObj, processNewFiles=True, processOnly=False)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  addSeriesData(self, seriesData)
 |      Takes new data to add to one or more data series for the file (currently
 |      works only in realtime-mode). The new data is assumed to occur after any
 |      existing data. The parameter, seriesData, should be a dict of dicts of
 |      lists as follows:
 |
 |        {
 |          'seriesName': {
 |            'times': [ t1, t2, ... , tn ],
 |            'values': [ v1, v2, ... , vn ]
 |          }, ...
 |        }
 |      :param seriesData: dict of dicts
 |      :return: updated file data for transmission to realtime subscribers
 |
 |  createAnnotation(self, user_id, left=None, right=None, top=None, bottom=None, seriesID='', label='', pattern_id=None)
 |      Create an annotation for the file
 |
 |  deleteAnnotation(self, user_id, id)
 |      Deletes the annotation with the given ID, after some checks. Returns true or false to indicate success.
 |
 |  detectPatterns(self, type, series, thresholdlow=None, thresholdhigh=None, duration=300, persistence=0.7, maxgap=300, series2=None, expected_frequency=0, min_density=0)
 |      # TODO(gus): Turn this into DataFrame output in line with Project.detectPatterns.
 |
 |  getEvents(self)
 |      Returns all event series
 |
 |  getInitialPayload(self, user_id)
 |      Produces JSON output for all series in the file at the maximum time range.
 |
 |  getMetadata(self)
 |      Returns a dict of file metadata.
 |
 |  getSeries(self, seriesid)
 |      Returns the series instance corresponding to the provided series ID, or None if the series cannot be found.
 |      The seriesid format is [full_series_path]:[value_column], e.g. /data/numerics/HR:value.
 |
 |  getSeriesNames(self)
 |      Returns a list of series names available in the file.
 |
 |  getSeriesOrCreate(self, seriesid)
 |      Retreves or creates & returns the series corresponding to the provided series ID.
 |
 |  getSeriesRangedOutput(self, seriesids, start, stop)
 |      Produces JSON output for a given list of series in the file at a specified time range.
 |
 |  load(self)
 |      Loads the necessary data into memory for an already-processed data file
 |      (does not load data though). Sets up classes for all series from file but
 |      does not load series data into memory).
 |
 |  loadSeriesFromDataset(self, ds)
 |      Load all available series from a dataset
 |
 |  mode(self)
 |      Returns the mode in which File is operating, either "file" or "realtime".
 |
 |  process(self)
 |      Process and store all downsamples for all series for the file.
 |
 |  updateAnnotation(self, user_id, id, left=None, right=None, top=None, bottom=None, seriesID='', label='')
 |      Update an annotation with new values
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  f
 |
 |  pf
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  __dict__
 |      dictionary for instance variables (if defined)
 |
 |  __weakref__
 |      list of weak references to the object (if defined)

And so forth…

The same type of help() documentation is available for any object you load, such as pattern sets, patterns, annotation sets, and annotations.