pycpshealthcare.db package

Subpackages

Submodules

pycpshealthcare.db.connectors module

Submodule for managing MongoDB connection, dabases and connections.

class pycpshealthcare.db.connectors.CpsConnection(connection_uri=None, host=None, username=None, password=None, port=None, database_names={'ChronoNevado': 'ChronoNevado', 'Chronotype': 'Chronotype', 'GlobalInfo': 'GlobalInfo', 'Marcoleta': 'Marcoleta', 'MealTracker': 'MealTrackerV2', 'Pancreas': 'Pancreas', 'SanPedro': 'SanPedro'}, tzinfo=None)[source]

Bases: object

A class that manages the MongoDB client, databases and collections.

Parameters:
  • connection_uri (str, optional) – The full MongoDB connection uri. Not needed if host, username and password are passed.

  • host (str, optional) – Database host. Not needed if connection_uri is passed.

  • username (str, optional) – Database username. Not needed if connection_uri is passed.

  • password (str, optional) – Database password. Not needed if connection_uri is passed.

  • port (str|int, optional) – Database port. Not needed if connection_uri is passed.

  • database_names (dict, optional) – Database dict that maps pycpshealthcare studies names to databases names, defaults to { “mealtracker”: “MealTracker”, “pancreas”: “Pancreas”, “globalinfo”: “GlobalInfo”, “sanpedro”: “SanPedro”, “marcoleta”: “Marcoleta”, “chrononevado”: “ChronoNevado”}

  • tzinfo (pytz.Timezone, optional) – Timezone for results, defaults to pytz.UTC.

  • Example with connection_uri:

    connection = CpsConnection(uri="mongodb://user:pass@localhost:27017")
    
  • Example without connection_uri:

    connection = CpsConnection(username="user", password="pass", host="localhost", port="27017")
    
close()[source]

Closes database connection.

pycpshealthcare.db.cps_exceptions module

pycpshealthcare.db.participant module

class pycpshealthcare.db.participant.Participant(raw_data, connection)[source]

Bases: object

A class for representing a GlobalInfo.ParticipantInfo MongoDB document as a Python object. Contains ParticipantStudiesGroup family instances for each of the studies.

Parameters:
  • raw_data (dict) – A MongoDB document as a dictionary.

  • connection (pycpshealthcare.db.connector.CpsConnection) – A pycpshealthcare.db.connector.CpsConnection instance.

pycpshealthcare.db.participant_info module

class pycpshealthcare.db.participant_info.ParticipantInfo(connection)[source]

Bases: object

get_participants(participants_names=None, participants_ids=None, studies='all', bring_id=False)[source]
class pycpshealthcare.db.participant_info.ParticipantsResults(results, connection)[source]

Bases: object

astype(out_type, split_columns=False)[source]

pycpshealthcare.db.results module

class pycpshealthcare.db.results.StudyResults(results)[source]

Bases: object

astype(out_type, split_columns=False)[source]

pycpshealthcare.db.utils module

pycpshealthcare.db.utils.generate_narray_pipeline(id_match, bin_size=60, bin_unit='minute', timestamp_start=None, timestamp_end=None, types=[])[source]
pycpshealthcare.db.utils.generate_vector_magnitude_pipeline(id_match, timestamp_start=None, timestamp_end=None, coords=['accx', 'accy', 'accz'])[source]
pycpshealthcare.db.utils.generate_vector_stats_magnitude_pipeline(id_match, bin_size=60, bin_unit='minute', timestamp_start=None, timestamp_end=None, coords=['accx', 'accy', 'accz'])[source]

Module contents