Commit 77e5e99e authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: Newly added variables get given instancing=2. Mostly done so the unit

tests/demo notebook/dummy test data  work as expected.
parent 530f282d
......@@ -947,14 +947,27 @@ def mergeCleanFunctions(vartable, tytable, clean, typeClean, globalClean):
else: vartable.loc[ vid, 'Clean'].update(gpp)
def addNewVariable(vartable, vid, name, dtype=None):
def addNewVariable(vartable, vid, name, dtype=None, instancing=None):
"""Add a new row to the variable table.
:arg vartable: The variable table
:arg vid: Integer variable ID
:arg name: Variable name - used as the description
:arg dtype: ``numpy`` data type. If ``None``, the variable type
is set to :attr:`.util.CTYPES.unknown`.
The ``instancing`` argument defines the meaning of the
:attr:`.Column.visit` field for columns associated with this variable.
The default value is ``2``, meaning that this variable may be associated
with columns corresponding to measurements acquired at different UK
BioBank assessments and imaging visits. See
https://biobank.ctsu.ox.ac.uk/crystal/schema.cgi?id=9 and
https://biobank.ctsu.ox.ac.uk/crystal/schema.cgi?id=10 for more details.
:arg vartable: The variable table
:arg vid: Integer variable ID
:arg name: Variable name - used as the description
:arg dtype: ``numpy`` data type. If ``None``, the variable type
is set to :attr:`.util.CTYPES.unknown`.
:arg instancing: Instancing code for the new variable - defaults to ``2``
"""
# set dtype to something which
......@@ -963,12 +976,18 @@ def addNewVariable(vartable, vid, name, dtype=None):
if dtype is None: dtype = object
else: dtype = dtype.type
# Assume that new variables
# are associated with visits
if instancing is None:
instancing = 2
if issubclass(dtype, np.integer): dtype = util.CTYPES.integer
elif issubclass(dtype, np.float): dtype = util.CTYPES.continuous
else: dtype = util.CTYPES.unknown
vartable.loc[vid, 'Description'] = name
vartable.loc[vid, 'Type'] = dtype
vartable.loc[vid, 'Instancing'] = instancing
def loadProcessingTable(procfile=None,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment