[importers] get rid of Subject age, fix gender and handedness
authorDimitri Papadopoulos <dimitri.papadopoulos@cea.fr>
Fri, 26 Jul 2013 23:45:33 +0200
changeset 364 6985ee412eab
parent 363 829c677bba09
child 365 1cbe7540884d
[importers] get rid of Subject age, fix gender and handedness
importers/imagen.py
--- a/importers/imagen.py	Thu Aug 01 13:40:40 2013 +0200
+++ b/importers/imagen.py	Fri Jul 26 23:45:33 2013 +0200
@@ -990,8 +990,8 @@
         return SUBJECTS[identifier]
     # gender
     find = root.find('%(a)sdemographics/%(a)sgender' % {'a': XNAT})
-    if find:
-        gender = find[0].text
+    if find is not None:
+        gender = find.text
         vocabulary = ('male', 'female', 'unknown')
         if gender in vocabulary:
             gender = unicode(gender)
@@ -1005,8 +1005,8 @@
         gender = u'unknown'
     # handedness
     find = root.find('%(a)sdemographics/%(a)shandedness' % {'a': XNAT})
-    if find:
-        handedness = find[0].text
+    if find is not None:
+        handedness = find.text
         vocabulary = ('right', 'left', 'ambidextrous', 'unknown')
         if handedness in vocabulary:
             handedness = unicode(handedness)
@@ -1018,27 +1018,9 @@
         message = 'missing handedness'
         logger.warn('{0}: {1}'.format(tree.docinfo.URL, message))
         handedness = u'unknown'
-    # "age"
-    ages = []
-    # age is actually associated to experiments, not to subject
-    path = '//xnat:experiment/psytool:processed_age_for_test'
-    find = root.xpath(path, namespaces=nsmap)
-    for age in find:
-        ages.append(int(age.text))
-    # XXX age should clearly not be an attribute of Subject!
-    if ages:
-        s = set(ages)
-        if len(s) > 1:
-            message = 'inconsistent ages: {0}-{1}'.format(min(s), max(s))
-            logger.warn('{0}: {1}'.format(tree.docinfo.URL, message))
-        # "subject age" is the mean of all ages
-        age = sum(ages) / len(ages)
-    else:
-        age=None
     # Create entity
     entity = store.create_entity('Subject', identifier=identifier,
-                                 gender=gender, age=age,
-                                 handedness=handedness)
+                                 gender=gender, handedness=handedness)
     SUBJECTS[identifier] = entity.eid
     return entity.eid