Ejemplo n.º 1
0
# Set the mesh filename
meshFilename = "bones/Asymknee22_boneSurface.vtk"
landmarksFilename = "bones/Asymknee22.csv"

# Select sub-bone of interest
subBones = ["Patella", "Tibia", "Femur", ""]
subBone = subBones[2]

# Check to see if it exists
subBoneFilename = meshFilename.split(
    ".")[0] + subBone + "." + meshFilename.split(".")[1]
open(subBoneFilename, 'r')

# Load the mesh model and generate graph
model = read_mesh(subBoneFilename)
modelGraph, idArray, invIdArray = generate_graph(model)

# Load all the landmarks Point IDs for this mesh
landmarks = load_landmarks(landmarksFilename)
allLandmarkIds = get_landmark_ids(model, landmarks)
landmarkIds = []
for i, ID in enumerate(allLandmarkIds):
    if i in LANDMARK_REGIONS[subBone]:
        landmarkIds.append(ID)

# These scalars may be set to many things, just initialising here
scalars = vtk.vtkDoubleArray()
scalars.SetNumberOfValues(model.GetNumberOfPoints())

# For example, set all scalars to 1
Ejemplo n.º 2
0
meshLocation = "bones"
landmarksFileLocation = meshLocation
mapLocation = "bones_markedLandmarksHeatmapTruthIndiv"
estimatorLocation = "estimators"

# Select sub-bone of interest
subBones = ["Patella", "Tibia", "Femur", ""]
subBone = subBones[1]

# Check to see if it exists
subBoneFilename = meshFilename.split(
    ".")[0] + subBone + "." + meshFilename.split(".")[1]
open(os.path.join(meshLocation, subBoneFilename), 'r')

# Load the mesh model and generate graph
model = read_mesh(os.path.join(meshLocation, subBoneFilename))
modelGraph, idArray, invIdArray = generate_graph(model)

# Load all the landmarks Point IDs for this mesh
landmarks = load_landmarks(
    os.path.join(landmarksFileLocation, landmarksFilename))
allLandmarkIds = get_landmark_ids(model, landmarks)
landmarkIds = []
for i, ID in enumerate(allLandmarkIds):
    if i in LANDMARK_REGIONS[subBone]:
        landmarkIds.append(ID)

# For each landmark, create an estimator to locate that landmark
for i, ID in enumerate(landmarkIds):
    actualLandmarkNo = LANDMARK_REGIONS[subBone][i]
    print("Creating estimator for landmark {} on file {}".format(
Ejemplo n.º 3
0
    subBoneFilename = meshFilename.split(
        ".")[0] + subBone + "." + meshFilename.split(".")[1]
    mapFilename = subBoneFilename.split(".")[0] + "_heatmap_landmark{}".format(
        actualLandmarkNo) + "." + subBoneFilename.split(".")[1]
    open(os.path.join(mapLocation, mapFilename),
         'r')  # check to see if it exists

    guessFilename = mapFilename.split(
        "."
    )[0] + "_guessedBy{}_Landmark{}_RFR_Order{}_SampleRate{}_Features-AvgNorms".format(
        landmarksFilename.split(".")[0], actualLandmarkNo, ORDER,
        int(SAMPLE_RATE * 100)) + "." + mapFilename.split(".")[1]
    open(os.path.join(guessLocation, guessFilename),
         'r')  # check to see if it exists

    mapModel = read_mesh(os.path.join(mapLocation, mapFilename))
    guessModel = read_mesh(os.path.join(guessLocation, guessFilename))

    mapScalars = mapModel.GetPointData().GetScalars()
    guessScalars = guessModel.GetPointData().GetScalars()
    pairwise_scalars = []

    for i in range(mapModel.GetNumberOfPoints()):
        pairwise_scalars.append(
            (i, mapScalars.GetValue(i), guessScalars.GetValue(i)))

    csvFilename = guessFilename.split(".")[0] + "_compared.csv"

    with open(csvFilename, 'wb') as csvfile:
        writer = csv.writer(csvfile)
Ejemplo n.º 4
0
from __future__ import print_function

from helper_loaders import read_mesh
from helper_loaders import generate_graph
from helper_loaders import load_landmarks
from helper_loaders import get_landmark_ids

# Set the mesh filename
meshFilename = "bones/Asymknee11_boneSurfaceRegions.vtk"
landmarksFilename = "bones/Asymknee11.csv"

# Check to see if it exists
open(meshFilename, 'r')

# Load the mesh model and generate graph
model = read_mesh(meshFilename)
modelGraph, idArray, invIdArray = generate_graph(model)

# Load all the landmarks Point IDs for this mesh
landmarks = load_landmarks(landmarksFilename)
landmarkIds = get_landmark_ids(model, landmarks)

# Find the landmarks and their associated scalar values
landmarkLocations = {}
scalars = model.GetPointData().GetScalars()

for i in landmarkIds:
    location = scalars.GetValue(i)
    if location not in landmarkLocations.keys():
        landmarkLocations[location] = []
    landmarkLocations[location].append(i)