[importers] Make the stores' relate methods compatible with the new API: add the subjtype kwarg.
authorVladimir Popescu <vladimir.popescu@logilab.fr>
Wed, 12 Jun 2013 15:20:33 +0200
changeset 161 f8396da98363
parent 160 6452d3f56a14
child 162 b3a13edace06
[importers] Make the stores' relate methods compatible with the new API: add the subjtype kwarg.
importers/abide.py
importers/mindboogle.py
importers/openfmri.py
importers/random.py
--- a/importers/abide.py	Thu Jun 27 18:51:46 2013 +0200
+++ b/importers/abide.py	Wed Jun 12 15:20:33 2013 +0200
@@ -544,8 +544,8 @@
                                    instance_of=questionnaire_eid)
     for eid in studies_eids:
         store.relate(adi_qrun.eid, 'related_study', eid)
-    store.relate(adi_qrun.eid, 'concerns', subject_eid, 'QuestionnaireRun')
-    store.relate(assessment.eid, 'generates', adi_qrun.eid, 'Assessment')
+    store.relate(adi_qrun.eid, 'concerns', subject_eid, subjtype='QuestionnaireRun')
+    store.relate(assessment.eid, 'generates', adi_qrun.eid, subjtype='Assessment')
     for ind, name in answers_listing:
         # Always create answer, even if without value
         score_value = store.create_entity('Answer', value=float(line[ind]) if line[ind] else None,
@@ -587,11 +587,11 @@
         scan_data['has_data'] = mri_data.eid
         scan_data['related_study'] = study_eid
         scan_data = store.create_entity('Scan', **scan_data)
-        store.relate(scan_data.eid, 'concerns', subject_eid, 'Scan')
-        store.relate(scan_data.eid, 'other_studies', abide_study, 'Scan')
+        store.relate(scan_data.eid, 'concerns', subject_eid, subjtype='Scan')
+        store.relate(scan_data.eid, 'other_studies', abide_study, subjtype='Scan')
         # XXX device
         #store.relate(scan_data.eid, 'uses_device', device_id)
-        store.relate(assessment.eid, 'generates', scan_data.eid, 'Assessment')
+        store.relate(assessment.eid, 'generates', scan_data.eid, subjtype='Assessment')
 
 
 
--- a/importers/mindboogle.py	Thu Jun 27 18:51:46 2013 +0200
+++ b/importers/mindboogle.py	Wed Jun 12 15:20:33 2013 +0200
@@ -71,8 +71,8 @@
                 anat['has_data'] = mri_data.eid
                 anat['related_study'] = study.eid
                 anat = store.create_entity('Scan', **anat)
-                store.relate(anat.eid, 'concerns', subject.eid, 'Scan')
-                store.relate(assessment.eid, 'generates', anat.eid, 'Assessment')
+                store.relate(anat.eid, 'concerns', subject.eid, subjtype='Scan')
+                store.relate(assessment.eid, 'generates', anat.eid, subjtype='Assessment')
             count_subject += 1
         # Flush
         store.flush()
--- a/importers/openfmri.py	Thu Jun 27 18:51:46 2013 +0200
+++ b/importers/openfmri.py	Wed Jun 12 15:20:33 2013 +0200
@@ -112,8 +112,8 @@
                 anat = store.create_entity('Scan', **anat)
                 if device_eid:
                     store.relate(anat.eid, 'uses_device', device_eid)
-                store.relate(anat.eid, 'concerns', subject.eid, 'Scan')
-                store.relate(assessment.eid, 'generates', anat.eid, 'Assessment')
+                store.relate(anat.eid, 'concerns', subject.eid, subjtype='Scan')
+                store.relate(assessment.eid, 'generates', anat.eid, subjtype='Assessment')
             # Model
             models = {}
             for model in glob.iglob(osp.join(study_path, subject_path, 'model/*')):
@@ -162,8 +162,8 @@
                 mri_data = store.create_entity('MRIData', **mri_data)
                 anat['has_data'] = mri_data.eid
                 anat = store.create_entity('Scan', **anat)
-                store.relate(anat.eid, 'concerns', subject.eid, 'Scan')
-                store.relate(assessment.eid, 'generates', anat.eid, 'Assessment')
+                store.relate(anat.eid, 'concerns', subject.eid, subjtype='Scan')
+                store.relate(assessment.eid, 'generates', anat.eid, subjtype='Assessment')
                 if device_eid:
                     store.relate(anat.eid, 'uses_device', device_eid)
                 for eid in models.get(run_id, []):
--- a/importers/random.py	Thu Jun 27 18:51:46 2013 +0200
+++ b/importers/random.py	Wed Jun 12 15:20:33 2013 +0200
@@ -58,8 +58,8 @@
                                    iteration=1, completed=True, valid=True,
                                    instance_of=questionnaire_eid)
     store.relate(q_qrun.eid, 'related_study', study_eid)
-    store.relate(q_qrun.eid, 'concerns', subject_eid, 'QuestionnaireRun')
-    store.relate(assessment.eid, 'generates', q_qrun.eid, 'Assessment')
+    store.relate(q_qrun.eid, 'concerns', subject_eid, subjtype='QuestionnaireRun')
+    store.relate(assessment.eid, 'generates', q_qrun.eid, subjtype='Assessment')
     for name, (question, _min, _max) in questions.iteritems():
         score_value = store.create_entity('Answer', value=nr.randint(_min, _max),
                                           question=question, datetime=date,
@@ -76,8 +76,8 @@
                                   platform=platform if platform else None,
                                   filepath=u'%s/genomics.tar.gz' % subject_eid,
                                   completed=True, valid=True, related_study=study_eid)
-    store.relate(measure.eid, 'concerns', subject_eid, 'GenomicMeasure')
-    store.relate(assessment.eid, 'generates', measure.eid, 'Assessment')
+    store.relate(measure.eid, 'concerns', subject_eid, subjtype='GenomicMeasure')
+    store.relate(assessment.eid, 'generates', measure.eid, subjtype='Assessment')
 
 def import_anat_images(store, subject_eid, center_eid, study_eid, mri_1, mri_2):
     date = random_date()
@@ -95,10 +95,10 @@
                                     format=u'nii.gz',
                                     completed=True, valid=True,
                                     filepath=u'%s/anat.nii.gz' % subject_eid).eid
-    store.relate(scan_data, 'concerns', subject_eid, 'Scan')
+    store.relate(scan_data, 'concerns', subject_eid, subjtype='Scan')
     device = nr.randint(1)
     store.relate(scan_data, 'uses_device', mri_1 if device else mri_2)
-    store.relate(assessment.eid, 'generates', scan_data, 'Assessment')
+    store.relate(assessment.eid, 'generates', scan_data, subjtype='Assessment')
 
 def import_fmri_images(store, subject_eid, center_eid, study_eid, mri_1, mri_2):
     date = random_date()
@@ -116,10 +116,10 @@
                                     format=u'nii.gz',
                                     completed=True, valid=True,
                                     filepath=u'%s/bold.nii.gz' % subject_eid).eid
-    store.relate(scan_data, 'concerns', subject_eid, 'Scan')
+    store.relate(scan_data, 'concerns', subject_eid, subjtype='Scan')
     device = nr.randint(1)
     store.relate(scan_data, 'uses_device', mri_1 if device else mri_2)
-    store.relate(assessment.eid, 'generates', scan_data, 'Assessment')
+    store.relate(assessment.eid, 'generates', scan_data, subjtype='Assessment')
 
 def import_constrat_images(store, subject_eid, center_eid, study_eid, mri_1, mri_2):
     date = random_date()
@@ -143,8 +143,8 @@
                                             completed=True, valid=True,
                                             filepath=u'%s/%s_%s.nii.gz' % (smap.replace(' ', ''),
                                                                            subject_eid, ind)).eid
-            store.relate(scan_data, 'concerns', subject_eid, 'Scan')
-            store.relate(assessment.eid, 'generates', scan_data, 'Assessment')
+            store.relate(scan_data, 'concerns', subject_eid, subjtype='Scan')
+            store.relate(assessment.eid, 'generates', scan_data, subjtype='Assessment')
 
 
 ###############################################################################