資源簡介
基于LIDC數據集的肺結節(jié)識別完整項目包,采用了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-master\CNN_LSTM\
?????文件????????5476??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\README.md
?????文件????????7300??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\analysis_results.py
?????文件????????2634??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\convert_txt2json.py
?????目錄???????????0??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\data\
?????目錄???????????0??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\data\lung_data\
?????目錄???????????0??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\data\lung_data\lung_data\
?????文件??????????83??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\data\lung_data\lung_data\說明.txt
?????文件??????363612??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\data\lung_data\lung_test.json
?????文件?????2087919??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\data\lung_data\lung_train.json
?????文件??????253428??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\data\lung_data\lung_val.json
?????文件??????363612??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\data\lung_data\test.json
?????文件????????1089??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\data\lung_data\test_small.json
?????文件?????????837??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\download_data.sh
?????文件??????255393??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\dump.txt
?????文件?????2244434??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\evaluate.ipynb
?????文件????10961947??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\evaluate.ipynb.bak
?????文件????????5414??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\evaluate.py
?????文件????????4840??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\evaluate.py.bak
?????目錄???????????0??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\hypes\
?????文件????????1200??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\hypes\lstm.json
?????文件????????1301??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\hypes\lstm_resnet_rezoom.json
?????文件????????1397??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\hypes\lstm_resnet_rezoom_lung.json
?????文件????????1274??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\hypes\lstm_rezoom.json
?????文件????????1261??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\hypes\lstm_rezoom_lung.json
?????文件????????1201??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\hypes\overfeat.json
?????文件????????1302??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\hypes\overfeat_resnet_rezoom.json
?????文件????????1275??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\hypes\overfeat_rezoom.json
?????文件?????1111673??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\lung_test.txt
?????文件?????7519454??2019-02-18?06:57??lidc_nodule_detection-master\CNN_LSTM\lung_train.txt
............此處省略127個文件信息
評論
共有 條評論