肺结节识别采用CNN


基于LIDC数据集的肺结节识别完整项目包,采用了CNN算法(python3),需要自取。
资源截图
代码片段和文件信息
import cPickle
import logging
import os
import xml.etree.ElementTree as etree
import numpy as np

from nodule_structs import RadAnnotation SmallNodule NormalNodule 
    NoduleRoi NonNodule AnnotationHeader

NS = {‘nih‘: ‘http://www.nih.gov‘}


def find_all_files(root suffix=None):
    res = []
    for root _ files in os.walk(root):
        for f in files:
            if suffix is not None and not f.endswith(suffix):
                continue
            res.append(os.path.join(root f))
    return res


def parse_dir(dirname outdir flatten=True pickle=True):
    assert os.path.isdir(dirname)

    if not flatten:
        return parse_original_xmls(dirname outdir pickle)

    pickle_file = os.path.join(outdir ‘annotation_flatten.pkl‘)
    if os.path.isfile(pickle_file):
        logging.info(“Loading annotations from file %s“ % pickle_file)
        with open(pickle_file ‘r‘) as f:
            annotations = cPickle.load(f)
        logging.info(“Load annotations complete“)
        return annotations
    annotations = parse_original_xmls(dirname outdir pickle)
    annotations = flatten_annotation(annotations)
    if pickle:
        logging.info(“Saving annotations to file %s“ % pickle_file)
        with open(pickle_file ‘w‘) as f:
            cPickle.dump(annotations f)
    return annotations


def parse_original_xmls(dirname outdir pickle=True):
    pickle_file = pickle and os.path.join(outdir ‘annotation.pkl‘) or None
    if pickle and os.path.isfile(pickle_file):
        logging.info(“Loading annotations from file %s“ % pickle_file)
        with open(pickle_file ‘r‘) as f:
            annotations = cPickle.load(f)
        logging.info(“Load annotations complete“)
    else:
        logging.info(“Reading annotations“)
        annotations = []
        xml_files = find_all_files(dirname ‘.xml‘)
        for f in xml_files:
            annotations.append(parse(f))
    if pickle and not os.path.isfile(pickle_file):
        logging.info(“Saving annotations to file %s“ % pickle_file)
        with open(pickle_file ‘w‘) as f:
            cPickle.dump(annotations f)
    return annotations


def parse(xml_filename):
    logging.info(“Parsing %s“ % xml_filename)
    annotations = []
    # ET is the library we use to parse xml data
    tree = etree.parse(xml_filename)
    root = tree.getroot()
    # header = parse_header(root)
    # readingSession-> holds radiologist‘s annotation info
    for read_session in root.findall(‘nih:readingSession‘ NS):
        # to hold each radiologists annotation
        # i.e. readingSession in xml file
        rad_annotation = RadAnnotation()
        rad_annotation.version = 
            read_session.find(‘nih:annotationVersion‘ NS).text
        rad_annotation.id = 
            read_session.find(‘nih:servicingRadiologistID‘ NS).text

        # nodules
        nodule_nodes = read_session.findall(‘nih:unblindedReadNodule‘ NS)
        for node in nodule_nodes:
            nodule = parse_nodule(node)
    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-02-18 06:57  lidc_nodule_detection-master
     目录           0  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTM
     文件        5476  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMREADME.md
     文件        7300  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTManalysis_results.py
     文件        2634  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMconvert_txt2json.py
     目录           0  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMdata
     目录           0  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMdatalung_data
     目录           0  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMdatalung_datalung_data
     文件          83  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMdatalung_datalung_data说明.txt
     文件      363612  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMdatalung_datalung_test.json
     文件     2087919  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMdatalung_datalung_train.json
     文件      253428  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMdatalung_datalung_val.json
     文件      363612  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMdatalung_data est.json
     文件        1089  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMdatalung_data est_small.json
     文件         837  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMdownload_data.sh
     文件      255393  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMdump.txt
     文件     2244434  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMevaluate.ipynb
     文件    10961947  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMevaluate.ipynb.bak
     文件        5414  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMevaluate.py
     文件        4840  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMevaluate.py.bak
     目录           0  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMhypes
     文件        1200  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMhypeslstm.json
     文件        1301  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMhypeslstm_resnet_rezoom.json
     文件        1397  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMhypeslstm_resnet_rezoom_lung.json
     文件        1274  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMhypeslstm_rezoom.json
     文件        1261  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMhypeslstm_rezoom_lung.json
     文件        1201  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMhypesoverfeat.json
     文件        1302  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMhypesoverfeat_resnet_rezoom.json
     文件        1275  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMhypesoverfeat_rezoom.json
     文件     1111673  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMlung_test.txt
     文件     7519454  2019-02-18 06:57  lidc_nodule_detection-masterCNN_LSTMlung_train.txt
............此处省略127个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)