dispel.providers.bdh.io package#
Functionality to read files from BDH apps.
Examples
To read a BDH json file and work with the contained data one can read the file:
bdh
>>> from dispel.providers.bdh.io import read_bdh
>>> reading = read_bdh(path)
And access raw sensor data for the first level
bdh
:options: +NORMALIZE_WHITESPACE
>>> id_ = reading.level_ids[0]
>>> reading.get_level(id_).get_raw_data_set('screen').data.head().tsTouch
0 2021-03-21 10:33:26.666
1 2021-03-21 10:33:26.674
2 2021-03-21 10:33:26.690
3 2021-03-21 10:33:26.698
4 2021-03-21 10:33:26.716
Name: tsTouch, dtype: datetime64[ns]
For further details on Reading
and the data model take a look at
dispel.data.core
.
- dispel.providers.bdh.io.create_levels(data, schema)[source]#
Create levels from uni-level activity data.
The BDH format does not split data in levels in the same way the ADS format does. For example, in the mood test, the two questions are lumped in the same level. This function splits the data in the way dispel expects.
- Parameters:
schema (ReadingSchema) – Data scheme
- Returns:
Level data
- Return type:
Dict[str, Any]
- dispel.providers.bdh.io.enrich_context(schema, level_id, context)[source]#
Enrich the context with level specific information.
- dispel.providers.bdh.io.get_context(config, schema_name)[source]#
Create a context from a config dictionary.
- dispel.providers.bdh.io.get_level_id(config, schema)[source]#
Parse level id from level type and configuration.
- Parameters:
config (dict) – The level configuration
schema (ReadingSchema) – The schema from data header
- Returns:
Level id for the level.
- Return type:
- Raises:
NotImplementedError – If the schema name parsing has not been implemented.
- dispel.providers.bdh.io.parsable_bdh_json(value)[source]#
Test if a value is a dictionary and contains BDH specific keys.
- dispel.providers.bdh.io.parse_bdh_reading(data)[source]#
Get class representation of dictionary representation.
- Parameters:
data (Dict) – The dictionary containing the information about the reading
- Returns:
The class representation of the record passed.
- Return type:
- Raises:
ValueError – If header, schema or body information is missing in
data
.
- dispel.providers.bdh.io.parse_device(device_dict)[source]#
Parse a device dictionary into a Device class.
- dispel.providers.bdh.io.parse_evaluation(data)[source]#
Parse the evaluation information for a reading.
- Parameters:
data (Dict) – The header of the BDH json file
- Returns:
The evaluation information for the reading
- Return type:
- Raises:
ValueError – If the evaluation id is missing from the data.
- dispel.providers.bdh.io.parse_level(data, schema, measure_definitions, raw_data_definitions)[source]#
Parse level id from dictionary containing level info.
- Parameters:
data (dict) – Dictionary containing level info
schema (ReadingSchema) – The schema from data header
measure_definitions (List[ValueDefinition]) – list of measure definitions
raw_data_definitions (Dict[Any, RawDataSetDefinition]) – Dict of raw data definitions
- Returns:
The parsed level
- Return type:
- dispel.providers.bdh.io.parse_levels(data, schema, measure_definitions, raw_data_definitions)[source]#
Parse levels from dict.
- Parameters:
data (dict) – Dict containing data body
schema (ReadingSchema) – The schema from data header
measure_definitions (List[ValueDefinition]) – list of measure definitions
raw_data_definitions (Dict[Any, RawDataSetDefinition]) – Dict of raw data definitions
- Returns:
list of levels
- Return type:
List[Level]
- Raises:
ValueError – If a level property is missing in
data
.
- dispel.providers.bdh.io.parse_measure_definition(id_, data)[source]#
Parse a measure definition.
- Parameters:
- Returns:
The created value definition.
- Return type:
- dispel.providers.bdh.io.parse_measures(data, definitions)[source]#
Parse measures from a reading.
- Parameters:
data (Dict[str, Any]) – The data dictionary for measures in BDH json format
definitions (Iterable[ValueDefinition]) – The definitions for the measures
- Returns:
The created measure set.
- Return type:
- dispel.providers.bdh.io.parse_raw_data_set_definition(id_, data)[source]#
Parse a raw data set definition for a reading.
- Parameters:
- Returns:
The created raw data set definition.
- Return type:
- Raises:
ValueError – If no source is defined for the given raw data source.
ValueError – If no values are defined for the given raw data source.
- dispel.providers.bdh.io.parse_raw_data_source(data)[source]#
Parse a raw data source definition.
- Parameters:
data (Dict) – The BDH raw data source definition dictionary in BDH json format.
- Returns:
The created BDH format raw data set source.
- Return type:
- dispel.providers.bdh.io.parse_raw_data_value_definition(id_, data)[source]#
Parse a raw data value definition.
- Parameters:
- Returns:
The created raw data value definition.
- Return type:
- dispel.providers.bdh.io.parse_schema(data)[source]#
Parse the schema of a reading.
- Parameters:
data (Dict) – A dictionary containing the schema attributes
- Returns:
The created reading schema.
- Return type:
- dispel.providers.bdh.io.parse_screen(device)[source]#
Parse a screen dictionary into a Screen class.
- dispel.providers.bdh.io.update_raw_data_definition(data, schema)[source]#
Update raw data definitions.
- Parameters:
schema (ReadingSchema) – Data scheme
- Returns:
Level data
- Return type:
Dict[str, Any]
Submodules#
- dispel.providers.bdh.io.core module
- dispel.providers.bdh.io.cps module
- dispel.providers.bdh.io.drawing module
- dispel.providers.bdh.io.gait module
- dispel.providers.bdh.io.msis29 module
- dispel.providers.bdh.io.neuroqol module
- dispel.providers.bdh.io.pinch module
- dispel.providers.bdh.io.sbt_utt module
- dispel.providers.bdh.io.survey module
- dispel.providers.bdh.io.voice module