Пример #1
0
    def subjectSummary(self):
        match = re.match(r"^/?subjects/([^/]+)/?$", self.command)
        self.restLog("Returning info about subject {}".format(match.group(1)),
                     2)
        id = match.group(1)

        # if we were passed in a sub_id rather than a UUID, lookup the associated UUID. (we might get multiple!)
        if validate_uuid(id):
            sub_ids = id
        else:
            sub_ids = Navigate.getSubjectUUIDsfromID(self.nidm_files, id)
            if len(sub_ids) == 1:
                sub_ids = sub_ids[0]

        activities = Navigate.getActivities(self.nidm_files, id)
        activityData = []
        for a in activities:
            data = Navigate.getActivityData(self.nidm_files, a)
            activityData.append(data)

        return self.subjectSummaryFormat_v2({
            'uuid':
            sub_ids,
            'instruments':
            list(filter(lambda x: x.category == 'instrument', activityData)),
            'derivatives':
            list(filter(lambda x: x.category == 'derivative', activityData))
        })
Пример #2
0
def test_navigate_get_sub_uuid_from_id():
    uuids = Navigate.getSubjectUUIDsfromID(nidm_file_tuples=BRAIN_VOL_FILES,
                                           sub_id='50653')
    assert len(uuids) == 1
    assert re.match(
        "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",
        uuids[0])  # check that it's a UUID