最近跑了3D CNN,实现MRI的分割及分类。训练过程中将准确率等自动保存成一个txt文件,该文件有64M多,想要从中提取有用信息比如Mean accuracy、sensitivity、specificity和mean dsc等,人工筛选太繁琐,所以想到用python编程来实现。
去请教了一位研究自然语言处理的计算机系的师兄,实现代码如下:
| # -*- coding: utf-8 -*- | |
| # @Time : 18-4-18 | |
| # @Author : sadscv | |
| # @File : textExtract.py | |
| import json | |
| import re | |
| def readfile(): | |
| save = None | |
| count = 0 | |
| with open("data/trainSessionDeepMedic.txt", "r") as f: | |
| tmpfile = open("data/Epoch.txt", "wb") | |
| # split file | |
| for line in f: | |
| print(save) | |
| head = re.search("Starting new Epoch! Epoch", line, flags=0) | |
| if head: | |
| pos = re.search("#", line).span()[1] | |
| num = line[pos:pos + 2].rstrip("/") | |
| save = num | |
| open("data/Epoch_{}.txt".format(save), "wb") | |
| count += 1 | |
| tmpfile = open("data/Epoch_{}.txt".format(save), "a") | |
| elif save: | |

使用Python进行自然语言处理,从64M的MRI分割与分类准确率txt文件中自动化提取Mean accuracy、sensitivity、specificity和mean dsc等关键信息,避免了手动筛选的繁琐工作。
最低0.47元/天 解锁文章
565

被折叠的 条评论
为什么被折叠?



