示例#1
0
if not path.isdir(results_dir):
    # Create the results folder if it doesn't exist
    os.makedirs(results_dir)
files = os.listdir(files_dir)

types_delete = [97, 98, 99, 100]
types_replace = {
    94: 84,
    96: 85,
    101: 34,
    102: 86,
    103: 88
}

for file_name in files:
    if Util.get_file_extension(file_name) != ".xml":
        continue
    p = path.join(files_dir, file_name)
    print ("Processing {0}...".format(file_name))
    with open(p, "r+b") as f:
        xml = f.read()
        geom = gtd.GeometryTopologyData.from_xml(xml)
        geom.num_dimensions = 3
        points = []
        change_coords = geom.coordinate_system != geom.LPS
        for point[ in geom.points:
            if point.chest_type not in types_delete:
                if types_replace.has_key(point.chest_type):
                    # Replace type
                    point.chest_type = types_replace[point.chest_type]
                if change_coords:
示例#2
0
sys.path.append("/Users/jonieva/Projects/SlicerCIP/Scripted/CIP_Common/")
from CIP.logic import geometry_topology_data as gtd
from CIP.logic import Util

import os
import os.path
import re

wrong_cases_path = "/Volumes/Mac500/Dropbox/rola-jorge/LH ROI failure/"
xmls_path = "/Volumes/Mac500/Dropbox/ACIL-Biomarkers/parenchyma training 2015-10-02/"
results_path = "/Volumes/Mac500/Data/tempdata/parenchyma training 2015-10-02/Removed Points/LH ROI failure"
current_case = ""
caseIds = dict()

for file_name in os.listdir(wrong_cases_path):
    if Util.get_file_extension(file_name) != ".png":
        continue
    expr = "(?P<caseid>(^(.*?)_(.*?)_(.*?)_(.*?)_(.*?)))_(.*?)_p(?P<point>(.*?))_(.*)"
    r = re.match(expr, file_name)
    caseId = r.group("caseid")
    point = int(r.group("point"))
    if not caseIds.has_key(caseId):
        caseIds[caseId] = []
    caseIds[caseId].append(point)

for caseId, excludedPoints in caseIds.iteritems():
    # Load the Geometry object
    geom = gtd.GeometryTopologyData.from_xml_file(os.path.join(xmls_path, caseId + "_parenchymaTraining.xml"))
    newPoints=[]
    for i in range(len(geom.points)):
        if i not in excludedPoints:
示例#3
0
if not path.isdir(results_dir):
    # Create the results folder if it doesn't exist
    os.makedirs(results_dir)
files = os.listdir(files_dir)

types_delete = [97, 98, 99, 100]
types_replace = {
    94: 84,
    96: 85,
    101: 34,
    102: 86,
    103: 88
}

for file_name in files:
    if Util.get_file_extension(file_name) != ".xml":
        continue
    p = path.join(files_dir, file_name)
    print ("Processing {0}...".format(file_name))
    with open(p, "r+b") as f:
        xml = f.read()
        geom = gtd.GeometryTopologyData.from_xml(xml)
        geom.num_dimensions = 3
        points = []
        change_coords = geom.coordinate_system != geom.LPS
        for point in geom.points:
            if point.chest_type not in types_delete:
                if types_replace.has_key(point.chest_type):
                    # Replace type
                    point.chest_type = types_replace[point.chest_type]
                if change_coords:
示例#4
0
sys.path.append("/Users/jonieva/Projects/SlicerCIP/Scripted/CIP_Common/")
from CIP.logic import geometry_topology_data as gtd
from CIP.logic import Util

import os
import os.path
import re

wrong_cases_path = "/Volumes/Mac500/Dropbox/rola-jorge/LH ROI failure/"
xmls_path = "/Volumes/Mac500/Dropbox/ACIL-Biomarkers/parenchyma training 2015-10-02/"
results_path = "/Volumes/Mac500/Data/tempdata/parenchyma training 2015-10-02/Removed Points/LH ROI failure"
current_case = ""
caseIds = dict()

for file_name in os.listdir(wrong_cases_path):
    if Util.get_file_extension(file_name) != ".png":
        continue
    expr = "(?P<caseid>(^(.*?)_(.*?)_(.*?)_(.*?)_(.*?)))_(.*?)_p(?P<point>(.*?))_(.*)"
    r = re.match(expr, file_name)
    caseId = r.group("caseid")
    point = int(r.group("point"))
    if not caseIds.has_key(caseId):
        caseIds[caseId] = []
    caseIds[caseId].append(point)

for caseId, excludedPoints in caseIds.iteritems():
    # Load the Geometry object
    geom = gtd.GeometryTopologyData.from_xml_file(
        os.path.join(xmls_path, caseId + "_parenchymaTraining.xml"))
    newPoints = []
    for i in range(len(geom.points)):