コード例 #1
0
def initXRaySimulator():
    ########################

    # Set up the beam
    print("Set up the beam")
    gvxr.setSourcePosition(
        distance_source_detector_in_m - distance_object_detector_in_m, 0.0,
        0.0, "mm")
    gvxr.usePointSource()
    gvxr.useParallelBeam()
    for energy, percentage in energy_spectrum_in_keV:
        gvxr.addEnergyBinToSpectrum(energy, "keV", percentage)

    # Set up the detector
    print("Set up the detector")
    gvxr.setDetectorPosition(-distance_object_detector_in_m, 0.0, 0.0, "m")
    gvxr.setDetectorUpVector(0, 1, 0)
    gvxr.setDetectorNumberOfPixels(detector_width_in_pixels,
                                   detector_height_in_pixels)
    gvxr.setDetectorPixelSize(pixel_size_in_micrometer,
                              pixel_size_in_micrometer, "micrometer")

    global angular_step

    angular_step = angular_span_in_degrees / number_of_projections

    print("Number of projections: ", str(number_of_projections))
    print("angular_span_in_degrees: ", str(angular_span_in_degrees))
    print("angular_step: ", str(angular_step))
コード例 #2
0
ファイル: App.py プロジェクト: tianci07/gvxr-python3-gui
    def setSourceShape(self):
        if self.source_shape.get() == 0:
            print ("Use point source");
            gvxr.usePointSource();

        elif self.source_shape.get() == 1:
            print ("Use parallel beam");
            gvxr.useParallelBeam();

        x_ray_image = gvxr.computeXRayImage();
        gvxr.displayScene()
        self.xray_vis.draw(x_ray_image);
コード例 #3
0
def setXRayParameters(SOD, SDD):
    # Compute the source position in 3-D from the SOD
    gvxr.setSourcePosition(SOD,  0.0, 0.0, "cm");
    gvxr.setDetectorPosition(SOD - SDD, 0.0, 0.0, "cm");
    gvxr.usePointSource();
コード例 #4
0
ground_truth_SOD=100;
ground_truth_SDD=140;
ground_truth_angles = [-90, 20, -10, 0, 5, 0, 5, 0,
                        0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0, 0,]

# Create an OpenGL context
print("Create an OpenGL context")
gvxr.createWindow();
gvxr.setWindowSize(512, 512);

# Set up the beam
print("Set up the beam")
gvxr.usePointSource();
#gvxr.useParallelBeam();
gvxr.setMonoChromatic(0.08, "MeV", 1000);

# Set up the detector
print("Set up the detector");
gvxr.setDetectorUpVector(0, 0, -1);
gvxr.setDetectorNumberOfPixels(1024, 1536);
gvxr.setDetectorPixelSize(0.5, 0.5, "mm");

setXRayParameters(ground_truth_SOD, ground_truth_SDD);

# Load the data
print("Load the data");

gvxr.loadSceneGraph("/home/ti/Documents/gvxr-python3-gui/hand.dae", "m");
コード例 #5
0
ファイル: gvxrGUI.py プロジェクト: tianci07/gvxr-python3-gui
def main(argv):
    global x_ray_image

    parser = argparse.ArgumentParser()
    parser.add_argument(
        "-input",
        type=str,
        help=
        "Input file (see http://assimp.sourceforge.net/main_features_formats.html for a list of supported file formats)"
    )
    parser.add_argument(
        "-unit",
        type=str,
        help="Unit of length corresponding to the input",
        choices=["um", "mm", "cm", "dm", "m", "dam", "hm", "km"])

    args = parser.parse_args()
    if args.input and args.unit:
        # Create an OpenGL context
        print("Create an OpenGL context")
        gvxr.createWindow()
        gvxr.setWindowSize(512, 512)

        # Set up the beam
        print("Set up the beam")
        gvxr.setSourcePosition(100.0, 0.0, 0.0, "cm")
        gvxr.usePointSource()
        #gvxr.useParallelBeam();
        gvxr.setMonoChromatic(0.08, "MeV", 1)

        # Set up the detector
        print("Set up the detector")
        gvxr.setDetectorPosition(-40.0, 0.0, 0.0, "cm")
        gvxr.setDetectorUpVector(0, 0, -1)
        gvxr.setDetectorNumberOfPixels(1024, 1024)
        gvxr.setDetectorPixelSize(0.5, 0.5, "mm")

        # Load the data
        print("Load the data")

        gvxr.loadSceneGraph(args.input, args.unit)

        gvxr.disableArtefactFiltering()

        #gvxr.loadMeshFile("chest", "./HVPTest/chest2.obj", "mm");
        #gvxr.invertNormalVectors("armR");
        #gvxr.invertNormalVectors("chest");

        node_label_set = []
        node_label_set.append('root')

        # The list is not empty
        while (len(node_label_set)):

            # Get the last node
            last_node = node_label_set[-1]

            # Initialise the material properties
            #print("Set ", label, "'s Hounsfield unit");
            #gvxr.setHU(label, 1000)
            Z = gvxr.getElementAtomicNumber("H")
            gvxr.setElement(last_node, gvxr.getElementName(Z))

            # Change the node colour to a random colour
            gvxr.setColour(last_node, random.uniform(0, 1),
                           random.uniform(0, 1), random.uniform(0, 1), 1.0)

            # Remove it from the list
            node_label_set.pop()

            # Add its Children
            for i in range(gvxr.getNumberOfChildren(last_node)):
                node_label_set.append(gvxr.getChildLabel(last_node, i))
            '''
        for label in gvxr.getMeshLabelSet():
            print("Move ", label, " to the centre");
            #gvxr.moveToCentre(label);

            #print("Move the mesh to the center");
            #gvxr.moveToCenter(label);

            #gvxr.invertNormalVectors(label);
        '''
        #gvxr.moveToCentre();
        gvxr.moveToCentre('root')

        # Compute an X-ray image
        #print("Compute an X-ray image");
        #gvxr.disableArtefactFiltering();
        #gvxr.enableArtefactFilteringOnGPU();
        # Not working anymore gvxr.enableArtefactFilteringOnGPU();
        # Not working anymore gvxr.enableArtefactFilteringOnCPU();
        x_ray_image = np.array(gvxr.computeXRayImage())
        '''x_ray_image -= 0.0799;
        x_ray_image /= 0.08 - 0.0799;
        plt.ioff();
        plt.imshow(x_ray_image, cmap="gray");
        plt.show()
        '''
        #gvxr.setShiftFilter(-0.0786232874);
        #gvxr.setScaleFilter(726.368958);

        gvxr.displayScene()

        app = App.App(0.08)
コード例 #6
0
ファイル: gvxrPythonTest.py プロジェクト: effepivi/inp2stl
    #print("Move the mesh to the center");
    #gvxr.moveToCenter(label);

    # print("Set ", label, "'s Hounsfield unit");
    # gvxr.setHU(label, 1000);

centre = [
    min_corner[0] + (max_corner[0] - min_corner[0]) / 2.0,
    min_corner[1] + (max_corner[1] - min_corner[1]) / 2.0,
    min_corner[2] + (max_corner[2] - min_corner[2]) / 2.0
]

# Set up the beam
print("Set up the beam")
gvxr.setSourcePosition(centre[0], centre[1], centre[2] - 10.0, "cm")
gvxr.usePointSource()
#gvxr.useParallelBeam();
gvxr.setMonoChromatic(0.08, "MeV", 1000)

# Set up the detector
print("Set up the detector")
gvxr.setDetectorPosition(centre[0], centre[1], centre[2] + 10.0, "cm")
gvxr.setDetectorUpVector(0, -1, 0)
gvxr.setDetectorNumberOfPixels(640, 320)
gvxr.setDetectorPixelSize(0.125, 0.125, "mm")

# Compute an X-ray image
print("Compute an X-ray image")
gvxr.disableArtefactFiltering()
# Not working anymore gvxr.enableArtefactFilteringOnGPU();
# Not working anymore gvxr.enableArtefactFilteringOnCPU();