def main(): # Construct the composite volume already containing the cube volume. volume = ctl.CompositeVolume(ctl.VoxelVolumeF.cube(150, 1.0, 0.02)) # We now construct the two ball volumes. sub_volume_1 = ctl.VoxelVolumeF.ball(10.0, 1.0, 0.05) sub_volume_2 = ctl.VoxelVolumeF.ball(25.0, 1.0, 0.10) # Here, we shift the ball volumes to the desired positions. sub_volume_1.set_volume_offset((0.0, -20.0, 0.0)) sub_volume_2.set_volume_offset((0.0, 30.0, 0.0)) # Now, we add the two balls as sub-volumes to our final volume. volume.add_sub_volume(sub_volume_1) volume.add_sub_volume(sub_volume_2) # First, we need to define an acquisition setup # (with a CT system and the number of views; 10 in this case)) setup = ctl.AcquisitionSetup( ctl.CTSystemBuilder.create_from_blueprint( ctl.blueprints.GenericCarmCT(ctl.DetectorBinning.Binning4x4)), 10) # We also need to specify the acquisition geometry, here we set a simple short scan trajectory setup.apply_preparation_protocol(ctl.protocols.ShortScanTrajectory(750.0)) # Now, we create our projector, here we simply use the standard pipeline. projector = ctl.StandardPipeline() # Pass the acquisition setup to the projector and create the projections: projector.configure(setup) projections = projector.project_composite(volume) # show projection #0 proj = projections.view(0).module(0).to_numpy() _ = plt.imshow(proj, cmap='gray'), plt.show()
def main(): # create a water ball volume = ctl.SpectralVolumeData.ball( 50., 0.5, 1.0, ctl.database.attenuation_model(ctl.database.Composite.Water)) # create a C-arm CT system and a short scan protocol with 10 views system = ctl.CTSystemBuilder.create_from_blueprint( ctl.blueprints.GenericCarmCT()) setup = ctl.AcquisitionSetup(system, 10) setup.apply_preparation_protocol(ctl.protocols.ShortScanTrajectory(750.0)) # create the standard pipeline and adjust the desired settings (focal spot & energy resolution) pipe = ctl.StandardPipeline() pipe.enable_areal_focal_spot() pipe.settings_spectral_effects().set_sampling_resolution(5.0) # pass the acquisition setup and run the simulation projections = pipe.configure_and_project(setup, volume) # show projection #1 proj = projections.view(1).module(0).numpy() _ = plt.imshow(proj, cmap='gray'), plt.show()
def main(): # Our starting volume remains the same. This is the sub-volume without spectral information. volume = ctl.CompositeVolume(ctl.VoxelVolumeF.cube(150, 1.0, 0.02)) # We now create two balls with spectral information (one representing blood, the other bone). sub_volume_1 = ctl.SpectralVolumeData.ball( 10.0, 1.0, 0.05, ctl.database.attenuation_model(ctl.database.Composite.Blood)) sub_volume_2 = ctl.SpectralVolumeData.ball( 25.0, 1.0, 0.10, ctl.database.attenuation_model(ctl.database.Composite.Bone_Cortical)) # Again, the shift to the desired positions... sub_volume_1.set_volume_offset((0.0, -20.0, 0.0)) sub_volume_2.set_volume_offset((0.0, 30.0, 0.0)) # ... and adding to the final volume. volume.add_sub_volume(sub_volume_1) volume.add_sub_volume(sub_volume_2) # In the projection code, we only change the setting for the # standard pipeline to 'No_Approximation'... setup = ctl.AcquisitionSetup( ctl.CTSystemBuilder.create_from_blueprint( ctl.blueprints.GenericCarmCT(ctl.DetectorBinning.Binning4x4)), 10) setup.apply_preparation_protocol(ctl.protocols.ShortScanTrajectory(750.0)) # ... here comes the changed line: projector = ctl.StandardPipeline(ctl.StandardPipeline.No_Approximation) # Pass the acquisition setup to the projector and create the projections: projector.configure(setup) projections = projector.project_composite(volume) # show projection #0 proj = projections.view(0).module(0).to_numpy() _ = plt.imshow(proj, cmap='gray'), plt.show()