Exemple #1
0
def test_navigate_get_subjects_for_acquisition():
    subjects = set([])
    sessions = Navigate.getSessions(BRAIN_VOL_FILES, PROJECT_URI)
    for s in sessions:
        acquisitions = Navigate.getAcquisitions(BRAIN_VOL_FILES, s)
        for acq in acquisitions:
            sub = Navigate.getSubject(BRAIN_VOL_FILES, acq)
            assert sub != None
            subjects.add(sub)
    assert len(subjects) > 5
Exemple #2
0
    def ExpandProjectMetaData(self, meta_data):
        """
        Takes in the meta_data from GetProjectsMetadata() and adds
        the following statistics about each project to the existing
        meta_data structure:
         age_max (float)
         age_min (float)
         handedness of subjects (list)
         genders of subjects (list)
         number of subjects (int)

        :param meta_data:
        :return:
        """
        for project_id in meta_data['projects']:

            project_uuid = str(project_id)[6:] if (
                str(project_id).startswith("niiri:")) else project_id
            project = meta_data['projects'][project_id]

            ages = set()
            hands = set()
            genders = set()

            for session in Navigate.getSessions(self.nidm_files, project_uuid):
                for acq in Navigate.getAcquisitions(self.nidm_files, session):
                    act_data = Navigate.getActivityData(self.nidm_files, acq)
                    for de in act_data.data:
                        if de.isAbout == "http://uri.interlex.org/ilx_0100400" or de.isAbout == "http://uri.interlex.org/base/ilx_0100400":
                            ages.add(float(de.value))
                        elif de.isAbout == "http://uri.interlex.org/ilx_0101292" or de.isAbout == "http://uri.interlex.org/base/ilx_0101292"\
                                or de.isAbout == "http://uri.interlex.org/ilx_0738439" or de.isAbout == \
                                "https://ndar.nih.gov/api/datadictionary/v2/dataelement/gender":
                            genders.add(de.value)
                        elif de.isAbout == "http://purl.obolibrary.org/obo/PATO_0002201":
                            hands.add(de.value)

            print(
                Query.GetParticipantUUIDsForProject(self.nidm_files,
                                                    project_uuid))

            project['age_max'] = max(ages) if len(ages) > 0 else 0
            project['age_min'] = min(ages) if len(ages) > 0 else 0
            project[Query.matchPrefix(str(
                Constants.NIDM_NUMBER_OF_SUBJECTS))] = len(
                    (Query.GetParticipantUUIDsForProject(
                        self.nidm_files, project_uuid))['uuid'])
            project[str(Constants.NIDM_GENDER)] = list(genders)
            project[str(Constants.NIDM_HANDEDNESS)] = list(hands)
Exemple #3
0
def test_navigate_get_acquisition_data_by_session():
    set_of_keys_returned = set([])
    set_of_activities = set([])

    sessions = Navigate.getSessions(BRAIN_VOL_FILES, PROJECT_URI)
    assert len(sessions) > 0
    for s in sessions:
        acquisitions = Navigate.getAcquisitions(BRAIN_VOL_FILES, s)
        assert len(acquisitions) > 0
        for a in acquisitions:
            set_of_activities.add(str(a))
            ad = Navigate.getActivityData(BRAIN_VOL_FILES, a)
            assert len(ad.data) > 5
            for vt in ad.data:
                set_of_keys_returned.add(vt.label)

    assert 'AGE_AT_SCAN' in set_of_keys_returned
    assert 'hadAcquisitionModality' in set_of_keys_returned
Exemple #4
0
def test_navigate_get_acquisition_data_by_session():
    set_of_keys_returned = set([])
    set_of_activities = set([])

    sessions = Navigate.getSessions(OPENNEURO_FILES, OPENNEURO_PROJECT_URI)
    assert len(sessions) > 0
    for s in sessions:
        acquisitions = Navigate.getAcquisitions(OPENNEURO_FILES, s)
        assert len(acquisitions) > 0
        for a in acquisitions:
            set_of_activities.add(str(a))
            ad = Navigate.getActivityData(OPENNEURO_FILES, a)
            assert len(ad.data) > 5
            for vt in ad.data:
                set_of_keys_returned.add(vt.label)

    print(set_of_keys_returned)

    assert 'age' in set_of_keys_returned
    assert 'hadAcquisitionModality' in set_of_keys_returned
Exemple #5
0
def test_navigate_get_acquisitions_for_session():
    sessions = Navigate.getSessions(BRAIN_VOL_FILES, PROJECT_URI)
    for s in sessions:
        acquisitions = Navigate.getAcquisitions(BRAIN_VOL_FILES, sessions[0])
        assert len(acquisitions) > 0
Exemple #6
0
def test_navigate_get_sessions():
    sessions = Navigate.getSessions(BRAIN_VOL_FILES, PROJECT_URI)
    assert len(sessions) > 0