dispel.data.measures module#
A module containing models for measures.
- class dispel.data.measures.MeasureId[source]#
Bases:
DefinitionId
The definition of a measure id for a task.
- Parameters:
task_name – The name and abbreviation of the task. Note that if no abbreviation is provided the name is used directly in the id.
measure_name – The name of the measure and its abbreviation.
modalities – The modalities and their abbreviations under which the measure is constituted.
aggregation – A method that was used to aggregate a sequence of the underlying measure, e.g., for the measure
mean response time
it would bemean
.
Notes
The abbreviations of values are passed using
AbbreviatedValue
. To generate the actual id the .abbr accessor is used. If one passes only strings, the class actually wraps those intoAbbreviatedValue
instances.Examples
>>> from dispel.data.values import AbbreviatedValue as AV >>> from dispel.data.measures import MeasureId >>> MeasureId( ... task_name=AV('Cognitive Processing Speed', 'CPS'), ... measure_name=AV('reaction time', 'rt'), ... modalities=[AV('digit-to-digit', 'dtd')], ... aggregation='mean' ... ) cps-dtd-rt-mean
- __init__(task_name, measure_name, modalities=None, aggregation=None)[source]#
- Parameters:
task_name (str | AbbreviatedValue) –
measure_name (str | AbbreviatedValue) –
modalities (List[str | AbbreviatedValue] | None) –
aggregation (str | AbbreviatedValue | None) –
- classmethod from_str(value)[source]#
See
dispel.data.values.DefinitionId.from_str()
.- Parameters:
value (str) – The string from which the definition id is to be constructed.
- Raises:
NotImplementedError – Always raised. This method is not implemented since there is no unambiguous parsing of task ids.
- Return type:
- class dispel.data.measures.MeasureSet[source]#
Bases:
ValueSet
A collection of measures.
- VALUE_CLS#
alias of
MeasureValue
- class dispel.data.measures.MeasureValueDefinition[source]#
Bases:
ValueDefinition
The definition of measures from tasks.
- Parameters:
task_name – The full name of the task and its abbreviation, e.g.,
Cognitive Processing Speed test
andCPS
passed usingAbbreviatedValue
.measure_name – The name of the measure, e.g.
reaction time
and its abbreviation passed usingAbbreviatedValue
. Note that aggregation methods are specified inaggregation
and should not be direclty part of the measure name.unit – See
ValueDefinition
.description – See
ValueDefinition
.data_type – See
ValueDefinition
.validator – See
ValueDefinition
.modalities – The modalities of the tasks, i.e. if there is more than one variant of the task. An example would be the
digit-to-digit
andsymbol-to-digit
orpredefined key 1
,predefined key 2
andrandom key
variants of the CPS test. Abbreviations of the modalities can be passed usingAbbreviatedValue
.aggregation – If the measure is the result of an aggregation, the method that was used to aggregate. E.g. for
mean response time
it would bemean
. Abbreviations are passed usingAbbreviatedValue
.precision – See
ValueDefinition
.
Examples
>>> from dispel.data.values import AbbreviatedValue as AV >>> from dispel.data.measures import MeasureValueDefinition >>> from dispel.data.validators import RangeValidator >>> MeasureValueDefinition( ... task_name = AV('Cognitive Processing Speed test', 'CPS'), ... measure_name = AV('response time', 'rt'), ... unit = 's', ... description = 'The mean time to respond to a presented stimulus', ... data_type = 'float64', ... validator = RangeValidator(lower_bound=0), ... modalities = [ ... AV('digit-to-digit', 'dtd'), ... AV('predefined key 1', 'key1') ... ], ... aggregation = 'mean' ... ) <MeasureValueDefinition: cps-dtd_key1-rt-mean (CPS digit-to-digit ...>
- __init__(task_name, measure_name, unit=None, description=None, data_type=None, validator=None, modalities=None, aggregation=None, precision=None)[source]#
- Parameters:
task_name (str | AbbreviatedValue) –
measure_name (str | AbbreviatedValue) –
unit (str | None) –
description (str | None) –
data_type (str | None) –
modalities (List[str | AbbreviatedValue] | None) –
aggregation (str | AbbreviatedValue | None) –
precision (int | None) –
- class dispel.data.measures.MeasureValueDefinitionPrototype[source]#
Bases:
ValueDefinitionPrototype
A task measure value definition prototype.
This is a convenience method that populates the
cls
argument with theMeasureValueDefinition
class.
- dispel.data.measures.row_to_definition(row)[source]#
Convert a pandas series to a value definition.
- Parameters:
row (Series) – A pandas series containing definition information.
- Returns:
The corresponding value definition.
- Return type:
- Raises:
MissingColumnError – If required fields are missing from the pandas’ series.
- dispel.data.measures.row_to_value(row)[source]#
Convert a pandas series to a measure value.
- Parameters:
row (Series) – A pandas series containing definition information.
- Returns:
The corresponding measure value.
- Return type:
- Raises:
MissingColumnError – If
measure_value
field is missing from the pandas’ series.