:py:mod:`vamtoolbox.geometry` ============================= .. py:module:: vamtoolbox.geometry Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: vamtoolbox.geometry.ProjectionGeometry vamtoolbox.geometry.Volume vamtoolbox.geometry.TargetGeometry vamtoolbox.geometry.Sinogram vamtoolbox.geometry.Reconstruction Functions ~~~~~~~~~ .. autoapisummary:: vamtoolbox.geometry.defaultKwargs vamtoolbox.geometry.loadVolume vamtoolbox.geometry.getCircleMask vamtoolbox.geometry.getInds vamtoolbox.geometry.rebinFanBeam .. py:function:: defaultKwargs(**default_kwargs) .. py:class:: ProjectionGeometry(angles, ray_type, CUDA=False, **kwargs) .. py:method:: calcZeroDoseSinogram(A, target_geo) .. py:method:: calcAbsorptionMask(target_geo) .. py:class:: Volume(array: numpy.ndarray, proj_geo: ProjectionGeometry = None, options=None, **kwargs) .. py:method:: segmentZ(slices) Segment volume object by chosen z slices. Modifies the array attribute of the volume object. :param slices: index of the slice or slices to keep :type slices: int or list .. rubric:: Examples Keep z slices between and including 1 and 10 >>> vol.segmentZ([1,10]) Keep single z slice at index 10, converts volume object to 2D >>> vol.segmentZ(10) .. py:method:: save(name: str) Save geometry object .. py:method:: show(savepath=None, dpi='figure', transparent=False, **kwargs) :param savepath: :type savepath: str, optional :param dpi: image dots per inch from `matplotlib.pyplot.savefig `_ :type dpi: int, optional :param transparent: sets transparency of the axes patch `matplotlib.pyplot.savefig `_ :type transparent: bool, optional :param \*\*kwargs: accepts `matplotlib.pyplot.imshow `_ keyword arguments .. py:method:: constructCoordGrid(spatial_sampling_rate=None, device=None) Get coordinate grid centered around the object (target/recon) in physical length unit using spatial_sampling_rate. Unit of spatial_samplign_rate is voxel/cm .. py:method:: constructCoordVec(spatial_sampling_rate=None, device=None) Get coordinate vectors centered around the object (target/recon) in physical length unit using spatial_sampling_rate. Unit of spatial_samplign_rate is voxel/cm .. py:class:: TargetGeometry(target=None, stlfilename=None, resolution=None, imagefilename=None, pixels=None, rot_angles=[0, 0, 0], bodies='all', binarize_image=True, clip_to_circle=True, options=None) Bases: :py:obj:`Volume` .. py:method:: segmentZ(slices) Segment target geometry by chosen z slices. Modifies the array and insert attributes of the target geometry. :param slices: index of the slice or slices to keep :type slices: int or list .. rubric:: Examples Keep z slices between and including 1 and 10 >>> target_geo.segmentZ([1,10]) Keep single z slice at index 10, converts target_geo to 2D >>> target_geo.segmentZ(10) .. py:method:: show(show_bodies=False, savepath=None, dpi='figure', transparent=False, **kwargs) :param savepath: :type savepath: str, optional :param dpi: image dots per inch from `matplotlib.pyplot.savefig `_ :type dpi: int, optional :param transparent: sets transparency of the axes patch `matplotlib.pyplot.savefig `_ :type transparent: bool, optional :param \*\*kwargs: accepts `matplotlib.pyplot.imshow `_ keyword arguments .. py:class:: Sinogram(sinogram: numpy.ndarray, proj_geo: ProjectionGeometry, options=None) Bases: :py:obj:`Volume` .. py:class:: Reconstruction(reconstruction: numpy.ndarray, proj_geo: ProjectionGeometry, options=None) Bases: :py:obj:`Volume` .. py:function:: loadVolume(file_name: str) Load saved vamtoolbox.geometry.Volume object :param file_name: filepath to Volume object e.g. "C:\\A\\sinogram.sino" :type file_name: str :rtype: vamtoolbox.geometry.Volume .. py:function:: getCircleMask(target: numpy.ndarray) Generates a boolean mask of the inscribed circle of a square array :param target: square array to create a boolean mask :type target: np.ndarray :returns: boolean mask where inscribed circle is True, outside the circle is False :rtype: circle_mask .. py:function:: getInds(target: numpy.ndarray) Gets gel and void indices of the boolean target array :param target: binary target array :type target: np.ndarray :returns: **gel_inds, void_inds** -- boolean arrays where the target is 1 (gel_inds) and where the target is 0 (void_inds) :rtype: np.ndarray .. py:function:: rebinFanBeam(sinogram, vial_width, N_screen, n_write, throw_ratio) Rebins a parallel ray projection geometry (telecentric) to a converging fan beam projection geometry that can be used when the photopolymer vial is NOT indexed matched to its surrounding, i.e. when the projector light is directly incident on the outer wall of the vial at an air-vial interface. :param sinogram: sinogram generated for parallel ray geometry that is to be rebinned for use in a non telecentric VAM geometry :type sinogram: geometry.Sinogram :param vial_width: Apparent vial width in projector pixels. Apparent vial width is only equal to true vial width if projection is telecentric. :type vial_width: int :param N_screen: (N_U,N_v), (# of pixels in u-axis, # of pixels in v-axis) of the projected screen :type N_screen: tuple :param n_write: refractive index at the wavelength used for writing (projector wavelength) :type n_write: float :param throw_ratio: Throw ratio of projector :type throw_ratio: float :rtype: Rebinned sinogram in geometry.Sinogram object Based on code by @author: Antony Orth Antony Orth, Kathleen L. Sampson, Kayley Ting, Jonathan Boisvert, and Chantal Paquet, "Correcting ray distortion in tomographic additive manufacturing," Opt. Express 29, 11037-11054 (2021) Please use the above citation if used in your work. *Note* The resampling process can be thought of as a resampling from the parallel beam case to the non-parallel beam case (ie. virtual projector to physical projector), where refraction alters the tranjectory of the rays in the vial. The basic idea is to consider that the physical projector should sample Radon space (virtual projector space) at the appropriate coordinates in the virtual projector space. In other words, each pixel on the physical projector at each instant in time, corresponds to a particular position in Radon space. The correspondence is calculated with the equations for xv and thetav in the paper above. The desired object is Radon transformed (corresponding to the virtual projector space) and then resampled in the altered space that is accessible by the physical projector. In the paper above, the process is described as a resampling from the physical projector space to the virtual projector space. However, it makes more sense to think of it the other way around (virtual to physical). This may be addressed by a correction to the paper above in the near future (as of 18 Jan 2022).