MIC-DKFZ / LIDC-IDRI-processing

Scripts for the preprocessing of LIDC-IDRI data
MIT License
75 stars 18 forks source link

bug for lidcXmlHelper.py #21

Open Zouxxyy opened 2 years ago

Zouxxyy commented 2 years ago

When I read the tcia-lidc-xml of LIDC-IDRI dataset, I found that some xml files could not be read normally,

after I replaced this code, it worked.

before

    it = ET.iterparse(filepath)
    for _, el in it:
        if '}' in el.tag:
            el.tag = el.tag.split('}', 1)[1]  # strip all namespaces
        for at in el.attrib.keys(): # strip namespaces of attributes too
            if '}' in at:
                newat = at.split('}', 1)[1]
                el.attrib[newat] = el.attrib[at]
                del el.attrib[at]

after

    it = ET.iterparse(filepath)
    for _, el in it:
        prefix, has_namespace, postfix = el.tag.partition('}')
        if has_namespace:
            el.tag = postfix  # strip all namespaces