Example #1
0
def setup():
    global cmu_test_project_uuid, PROJECT_URI, OPENNEURO_PROJECT_URI

    for f in BRAIN_VOL_FILES:
        if Path(f).is_file():
            os.remove(f)

    if not Path('./cmu_a.nidm.ttl').is_file():
        urllib.request.urlretrieve(
            "https://raw.githubusercontent.com/dbkeator/simple2_NIDM_examples/master/datasets.datalad.org/abide/RawDataBIDS/CMU_a/nidm.ttl",
            "cmu_a.nidm.ttl")

    if not Path('./caltech.nidm.ttl').is_file():
        urllib.request.urlretrieve(
            "https://raw.githubusercontent.com/dbkeator/simple2_NIDM_examples/master/datasets.datalad.org/abide/RawDataBIDS/Caltech/nidm.ttl",
            "caltech.nidm.ttl")

    projects = Navigate.getProjects(BRAIN_VOL_FILES)
    PROJECT_URI = projects[0]

    if not Path('./ds000168.nidm.ttl').is_file():
        urllib.request.urlretrieve(
            "https://raw.githubusercontent.com/dbkeator/simple2_NIDM_examples/master/datasets.datalad.org/openneuro/ds000168/nidm.ttl",
            "ds000168.nidm.ttl")

    projects2 = Navigate.getProjects(OPENNEURO_FILES)
    OPENNEURO_PROJECT_URI = projects2[0]
Example #2
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)
Example #3
0
def GetProjectsComputedMetadata(nidm_file_list):
    '''
     :param nidm_file_list: List of one or more NIDM files to query across for list of Projects
    :return: Dictionay or projects, each project having a dictionary of project stats
             including age_max, age_min, gender list, and handedness list.
    '''

    meta_data = {"projects": {}}
    projects = Navigate.getProjects(tuple(nidm_file_list))
    for p in projects:
        proj_id = nidm.experiment.tools.rest.RestParser.getTailOfURI(str(p))
        meta_data["projects"][proj_id] = {"age_max": 0, "age_min": sys.maxsize, "gender": [], "handedness": [] }
        meta_data["projects"][proj_id].update(Navigate.GetProjectAttributes(tuple(nidm_file_list), p))
        gender_set = set()
        hand_set = set()
        subjects = Navigate.getSubjects(tuple(nidm_file_list), p)
        for s in subjects:
            activities = Navigate.getActivities(tuple(nidm_file_list), s)
            meta_data["projects"][proj_id]["number_of_subjects"] = len(subjects)

            for a in activities:
                data = Navigate.getActivityData(tuple(nidm_file_list), a)
                if type(data) == nidm.experiment.Navigate.ActivityData:
                    for x in data.data:
                        if x.isAbout == Constants.NIDM_IS_ABOUT_AGE:
                            if float(x.value) > meta_data["projects"][proj_id]["age_max"]:
                                meta_data["projects"][proj_id]["age_max"] = float(x.value)
                            if float(x.value) < meta_data["projects"][proj_id]["age_min"]:
                                meta_data["projects"][proj_id]["age_min"] = float(x.value)
                        if x.isAbout == Constants.NIDM_IS_ABOUT_GENDER:
                            gender_set.add(str(x.value))
                        if x.isAbout == Constants.NIDM_IS_ABOUT_HANDEDNESS:
                            hand_set.add(str(x.value))
        meta_data["projects"][proj_id]["gender"] = list(gender_set)
        meta_data["projects"][proj_id]["handedness"] = list(hand_set)


    return meta_data
Example #4
0
def test_navigate_get_projects():
    projects = Navigate.getProjects(BRAIN_VOL_FILES)
    assert len(projects) == 2