diff --git a/setup.cfg b/setup.cfg index 03a2b69..00e8c1d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -36,6 +36,7 @@ install_requires = numpy >= 1.16.5 ontquery ~= 0.2.3 pandas + pyarrow patsy prov pybids >= 0.12.4 @@ -44,7 +45,7 @@ install_requires = pyld >= 1.0.5, <3.0 python-dateutil ~= 2.0 rapidfuzz - rdflib + rdflib ~= 6.3.2 requests scikit-learn scipy diff --git a/src/nidm/experiment/tools/csv2nidm.py b/src/nidm/experiment/tools/csv2nidm.py index 56e634b..dc5c47d 100644 --- a/src/nidm/experiment/tools/csv2nidm.py +++ b/src/nidm/experiment/tools/csv2nidm.py @@ -193,16 +193,23 @@ def main(): id_field = None for key, value in column_to_terms.items(): if "isAbout" in value: - for isabout_key, isabout_value in value["isAbout"].items(): - if isabout_key in ("url", "@id"): - if isabout_value == Constants.NIDM_SUBJECTID._uri: - key_tuple = eval(key) - # id_field=key - id_field = key_tuple.variable - # make sure id_field is a string for zero-padded subject ids - # re-read data file with constraint that key field is read as string - df = pd.read_csv(args.csv_file, dtype={id_field: str}) - break + for concept in value["isAbout"]: + for isabout_key, isabout_value in concept.items(): + if isabout_key in ("url", "@id"): + if isabout_value == Constants.NIDM_SUBJECTID._uri: + # get variable name from NIDM JSON file format: + # DD(source=assessment_name, variable=column) + id_field = ( + key.split("variable")[1] + .split("=")[1] + .split(")")[0] + .lstrip("'") + .rstrip("'") + ) + # make sure id_field is a string for zero-padded subject ids + # re-read data file with constraint that key field is read as string + df = pd.read_csv(args.csv_file, dtype={id_field: str}) + break # if we couldn't find a subject ID field in column_to_terms, ask user if id_field is None: