Exemplo n.º 1
0
    # ========================== METADATA ==========================
    # ==================== subject ====================
    subject_info = {
        c: nwb['general']['subject'][c].value.decode('UTF-8')
        for c in ('subject_id', 'description', 'sex', 'species', 'weight',
                  'age', 'genotype')
    }
    # force subject_id to be lower-case for consistency
    subject_info['subject_id'] = subject_info['subject_id'].lower()

    # dob and sex
    subject_info['sex'] = subject_info['sex'][0].upper()
    dob_str = re.search('(?<=Date of birth:\s)(.*)',
                        subject_info['description'])
    if utilities.parse_prefix(dob_str.group()) is not None:
        subject_info['date_of_birth'] = utilities.parse_prefix(dob_str.group())

    # source and strain
    strain_str = re.search(
        '(?<=Animal Strain:\s)(.*)', subject_info['description']
    )  # extract the information related to animal strain
    if strain_str is not None:  # if found, search found string to find matched strain in db
        for s in subject.StrainAlias.fetch():
            m = re.search(re.escape(s[0]), strain_str.group(), re.I)
            if m is not None:
                subject_info['strain'] = (subject.StrainAlias & {
                    'strain_alias': s[0]
                }).fetch1('strain')
                break
    source_str = re.search(
        print('=================================')
        print(f'!!! ERROR LOADING FILE: {fname}')   
        print('=================================')
        continue

    # ========================== METADATA ==========================
    # ==================== Subject ====================
    subject_info = {c: nwb['general']['subject'][c].value.decode('UTF-8')
                    for c in ('subject_id', 'description', 'sex', 'species', 'age', 'genotype')}
    # force subject_id to be lower-case for consistency
    subject_info['subject_id'] = subject_info['subject_id'].lower()

    # dob and sex
    subject_info['sex'] = subject_info['sex'][0].upper()
    dob_str = re.search('(?<=dateOfBirth:\s)(.*)(?=\n)', subject_info['description'])
    if utilities.parse_prefix(dob_str.group()) is not None:
        subject_info['date_of_birth'] = utilities.parse_prefix(dob_str.group())
    
    # source and strain
    strain_str = re.search('(?<=animalStrain:\s)(.*)', subject_info['description']) # extract the information related to animal strain
    if strain_str is not None: # if found, search found string to find matched strain in db
        for s in subject.StrainAlias.fetch():
            m = re.search(re.escape(s[0]), strain_str.group(), re.I) 
            if m is not None:
                subject_info['strain'] = (subject.StrainAlias & {'strain_alias': s[0]}).fetch1('strain')
                break
    source_str = re.search('(?<=animalSource:\s)(.*)', subject_info['description'])  # extract the information related to animal strain
    if source_str is not None:  # if found, search found string to find matched strain in db
        for s in reference.AnimalSourceAlias.fetch():
            m = re.search(re.escape(s[0]), source_str.group(), re.I) 
            if m is not None: