Exemplo n.º 1
0
    def subjects(self):
        self.restLog("Returning info about subjects", 2)
        projects = Navigate.getProjects(self.nidm_files)
        result = {'subject': []}
        if 'fields' in self.query and len(self.query['fields']) > 0:
            result['fields'] = {}

        for proj in projects:
            subs = Navigate.getSubjects(self.nidm_files, proj)
            for s in subs:
                result['subject'].append([
                    Query.URITail(s),
                    Navigate.getSubjectIDfromUUID(self.nidm_files, s)
                ])

                # print ("getting info for " + str(s))
                x = self.getFieldInfoForSubject(proj, s)
                if x != {}:
                    result['fields'][Query.URITail(s)] = x
        return self.subjectFormat(result)
Exemplo n.º 2
0
 def subjectsList(self):
     match = re.match(r"^/?projects/([^/]+)/subjects/?$", self.command)
     project = match.group((1))
     self.restLog(
         "Returning all agents matching filter '{}' for project {}".format(
             self.query['filter'], project), 2)
     # result = Query.GetParticipantUUIDsForProject(self.nidm_files, project, self.query['filter'], None)
     all_subjects = Navigate.getSubjects(self.nidm_files, project)
     result = {}
     result['uuid'] = []
     result['subject id'] = []
     for sub_uuid in all_subjects:
         if Query.CheckSubjectMatchesFilter(self.nidm_files, project,
                                            sub_uuid, self.query['filter']):
             uuid_string = (str(sub_uuid)).split('/')[
                 -1]  # srip off the http://whatever/whatever/
             result['uuid'].append(uuid_string)
             sid = Navigate.getSubjectIDfromUUID(self.nidm_files, sub_uuid)
             result['subject id'].append(str(sid))
     return self.format(result)