Disclosure of Invention
The invention provides a method for simulating an X-ray imaging effect by utilizing a CT image in prosthesis planning, which solves the problems that the prosthesis implantation planning result on a CT three-dimensional image cannot be directly mapped into a two-dimensional X-ray commonly used by doctors in the prior art, so that the doctors need to repeatedly compare the CT with the X-ray, and the corresponding positions of the prosthesis on the two-dimensional X-ray image are presumed, thereby not only reducing the efficiency of diagnosis and operation planning, but also possibly causing errors and influencing the treatment effect.
The technical scheme of the invention is realized as follows:
the invention provides a method for simulating an X-ray imaging effect by using CT images in prosthesis planning, which comprises the following steps:
Setting a voxel value range of a prosthesis implantation area in the CT image;
placing the prosthesis model at a position to be implanted in the CT image;
assigning voxel values corresponding to the prosthesis model based on the set voxel value range;
and configuring corresponding opacity for the CT image and the prosthesis model based on the voxel values, and performing three-dimensional rendering on the CT image and the prosthesis model by using a three-dimensional volume rendering mapper to obtain the CT image simulating the imaging effect of the X-ray film.
Specifically, the method for setting the voxel value range of the prosthetic implantation area in the CT image comprises the following steps:
reconstructing a bone three-dimensional model based on the patient CT images;
Randomly sampling voxel values of n points falling into the three-dimensional model of the skeleton in the CT image;
sorting voxel values of n points in order from small to large;
Taking the average value of the voxel values of a plurality of points which are ranked forward as a voxel value lower limit value, and taking the average value of the voxel values of a plurality of points which are ranked backward as a voxel value upper limit value.
Specifically, the method for placing the prosthesis model at the position to be implanted in the CT image comprises the following steps:
In the preoperative planning stage, the prosthesis model is imported and moved in an MPR film reading mode of the CT image, so that the rotation center of the prosthesis model is located at the center of a position to be implanted no matter observed from a coronal view, an axial view or a sagittal view of the CT image, the front inclination angle of the prosthesis model is 5-25 degrees, and the abduction angle of the prosthesis model is 30-50 degrees.
Specifically, the method for assigning corresponding voxel values to a prosthetic model comprises the following steps:
generating an axial bounding box of the prosthesis model;
Filling the axial bounding box with voxels of the same size as the CT image voxels;
Traversing all voxels in the axial bounding box, setting the voxel value inside the prosthesis model as H, and setting the voxel value outside the prosthesis model as L-H, wherein H, L is the upper limit value and the lower limit value of the preset voxel value range respectively.
Specifically, the method for configuring the corresponding opacity for the CT image and the prosthesis model based on the voxel values comprises the following steps:
The voxel value-opacity transfer function is established as follows:
;
;
Wherein, theAnd H, L is respectively an upper limit value and a lower limit value of a preset voxel value range, and I is the preset opacity.
Further, the value of I is larger when the CT image is subjected to three-dimensional rendering than when the prosthesis model is subjected to three-dimensional rendering.
Further, the value of I is 0.2+/-0.05 when the CT image is subjected to three-dimensional rendering, and is 0.02+/-0.005 when the prosthesis model is subjected to three-dimensional rendering.
Specifically, a three-dimensional rendering is carried out on the CT image and the prosthesis model by adopting an accumulated mixed mode of a three-dimensional volume rendering mapper provided by a VTK library, so that a transparent superposition effect of the CT image and the prosthesis model under a specified visual angle is formed.
Compared with the prior art, the invention has the beneficial effects that:
(1) According to the invention, three-dimensional CT data and prosthesis planning information are directly converted into three-dimensional images simulating two-dimensional X-ray film effects through a high-efficiency volume rendering technology, so that a doctor is allowed to verify the prosthesis placement effects through a familiar two-dimensional X-ray view while keeping CT three-dimensional planning precision;
(2) The simulation result of the invention is essentially volume rendering projection of three-dimensional data, and X-ray films with different angles can be dynamically generated only by adjusting the view angle of a camera in the three-dimensional space of the three-dimensional volume rendering mapper, thereby meeting the film reading requirements of doctors with different view angles;
(3) According to the invention, the three-dimensional data is directly rendered through the accumulation mixed mode of the VTK three-dimensional volume rendering mapper, and the simulation X-ray film can be rapidly generated by means of high calculation efficiency of the volume rendering technology, so that the clinical real-time requirement is met.
Detailed Description
The technical solutions of the present invention will be clearly and completely described in conjunction with the embodiments of the present invention, and it is apparent that the described embodiments are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1, the present invention provides a method for simulating an imaging effect of an X-ray film by using a CT image in a prosthesis planning, comprising the following steps:
Step 1, setting a voxel value range of a prosthesis implantation area in a CT image, which specifically comprises the following steps:
step 101, reconstructing a bone three-dimensional model based on a patient CT image;
102, randomly sampling voxel values of n points (in the embodiment, the value of n is not less than 200, and the specific number can be flexibly adjusted according to actual conditions) falling into a three-dimensional model of a skeleton in a CT image;
step 103, sorting voxel values of n points in order from small to large;
step 104, taking the average value of the voxel values of the top-ranked points (the top 5% points in the embodiment, the specific number of which can be flexibly adjusted according to the actual situation) as the voxel value lower limit value L, and taking the average value of the voxel values of the bottom-ranked points (the bottom 5% points in the embodiment, the specific number of which can be flexibly adjusted according to the actual situation) as the voxel value upper limit value H.
In this embodiment, a deep learning method (e.g., U-Net) can be used to reconstruct a bone three-dimensional model based on a patient CT image (the method is the prior art), and the general procedure is as follows:
inputting a CT sequence (layer thickness is less than or equal to 1 mm) in a DICOM format of a patient;
Preprocessing, namely normalizing (mapping voxel values to [0,1 ]) and resampling (unifying voxel spacing to 1mm 3) the CT image;
Network training, namely adopting a marked skeleton mask dataset (such as a public dataset TCIA), wherein a Loss function is Dice Loss, and an optimizer is Adam (learning rate 0.001);
and outputting a binarized skeleton segmentation mask.
The segmentation mask is converted into a three-dimensional grid model (the model is a closed three-dimensional curved surface) through Marching Cubes algorithm, and the grid resolution is consistent with the original CT voxel spacing.
Step 2, placing the prosthesis model at the position to be implanted in the CT image, wherein the specific method comprises the following steps:
In the pre-operative planning stage, CT images are loaded in medical image software (such as a 3D slice), a multi-planar reconstruction (MPR) mode is started, a prosthesis STL model (such as an acetabular cup) is imported, the position of the prosthesis model is adjusted through an interactive translation/rotation tool, the embodiment takes the hip CT images and the acetabular cup prosthesis model as examples, namely the CT images are images, the acetabular cup prosthesis model is an image, the image is moved until the rotation center of the image coincides with the center of a native acetabular cup (the error is smaller than 2 mm) no matter observed from a coronal position view (Coronal), an Axial position view (Axial) or a sagittal position view (Saggital), the pre-tilt angle of the image is 5-25 degrees, the abduction angle of the image is 30-50 degrees, as shown in fig. 2, the example CT only reserves a pelvic bone part for highlighting a hip joint region, and the femur part is removed. The numerical evaluation indexes of the prostheses of different body parts are different, but the preoperative planning essence is to obtain a proper relative position relation between the prosthesis model and the CT image.
And 3, assigning voxel values corresponding to the prosthesis model based on the set voxel value range, wherein the specific steps are as follows:
step 301, generating an axial bounding box AABB of the displant, wherein the method comprises the following steps:
The geometric center of the prosthetic STL model is calculated, expanding along the XYZ axes to completely enclose the model, and the boundaries are rounded to the CT voxel size.
Step 302, voxelization processing, the method is as follows:
filling the axial bounding box (creating a voxel grid with the same resolution as the CT image in AABB) with voxels with the same size as the image voxels (such as 0.2mm x 0.2 mm), and marking the three-dimensional image formed by the new voxels as bin;
Step 303, traversing all voxels in the bin, setting the voxel value inside the implant (judging whether the voxel is inside the prosthesis model by the ray intersection method) as H, and setting the voxel value outside the prosthesis model as L-H (avoiding confusion with the CT value).
The 3D view, the coronal view, the axial view and the sagittal view of the processed bin are shown in fig. 3, the interior of the implant refers to the area occupied by the prosthesis model in the space, such as the white part in fig. 3, the prosthesis is generally made of high-density materials such as ceramics, metals and the like, the HU value (voxel value) of the prosthesis is close to or higher than that of bone, the highest HU value of the bone area set in the front is H, the voxel value of the prosthesis part is also set to be H so as to be convenient for displaying the effect of the high-density materials in the subsequent body painting, and similarly, the voxel value of the non-prosthesis part is set to be L-H, the value is very small (such as air), and the voxel value of the non-prosthesis part is hardly displayed in the body painting.
And 4, configuring corresponding opacity for the CT image and the prosthesis model based on the voxel values, and performing three-dimensional rendering on the CT image and the prosthesis model by using a three-dimensional volume rendering mapper to obtain the CT image simulating the imaging effect of the X-ray film, wherein the specific method comprises the following steps:
Establishing a voxel value-opacity transfer function:
;
;
Wherein, theH, L is respectively an upper limit value and a lower limit value of a preset voxel value range, and I is a preset maximum opacity which can be flexibly set according to actual conditions;
As shown in fig. 4, in combination with the above transfer function, it can be seen that the opacity of the portion of the image where the voxel value of the CT image and the prosthetic model is less than or equal to the lower limit value L is set to 0, the opacity of the portion where the voxel value is greater than or equal to the upper limit value H is set to I, and the portion of the voxel value between the lower limit value L and the upper limit value H has a linear relationship between the opacity and the voxel value, the slope is k, and the intercept is b.
In the implementation process, the value of I is larger when the CT image is subjected to three-dimensional rendering than when the prosthesis model is subjected to three-dimensional rendering.
Further, the value of I is 0.2+/-0.05 when the CT image is subjected to three-dimensional rendering, and is 0.02+/-0.005 when the prosthesis model is subjected to three-dimensional rendering.
In this embodiment, the value of I is 0.2 (simulating the gray-scale contrast of the skeleton in the X-ray film) when the CT image is three-dimensionally rendered, and is 0.02 (simulating the highlighting of the metal prosthesis) when the prosthesis model is three-dimensionally rendered, and 0.2 and 0.02 are experience values with wide applicability obtained by trying various skeleton CT and prosthesis models, and the implementation can be slightly customized on the basis of 0.2 and 0.02.
In this embodiment, a three-dimensional rendering is performed on the CT image and the prosthesis model by using an additive hybrid mode (additive blend mode) of a three-dimensional volume rendering mapper (vtkVolumeMapper) provided by the VTK library, the ray stepping is matched with the CT resolution, the projection view angle simulates the geometry of the bulb-detector of the X-ray machine (such as the source-image distance of 100cm, orthogonal projection), a single-channel gray-scale image (simulated X-ray film) is output, a transparent superposition effect of the CT image and the prosthesis model under a specified view angle is formed, and the final imaging effect is shown in fig. 5.
Medical X-ray imaging is a technology for forming images by utilizing the absorption difference of different tissues (such as bones, muscles and air) on rays when X-rays penetrate through a human body, wherein high-density tissues (such as bones) absorb more X-rays to be white, and low-density tissues (such as lungs) absorb less X-rays to be black. The accumulating and mixing mode of the VTK three-dimensional volume rendering mapper is a three-dimensional data visualization technology based on light projection, the core principle is that volume data are sampled along the direction of sight, opacity values of all sampling points are directly accumulated without considering shielding relation, and a transparent superposition effect is formed. The invention considers that the volume rendering method is very similar to the X-ray imaging principle, so the volume rendering of CT data is used for simulating the two-dimensional X-ray film, thereby considering the film reading requirements of CT and traditional X-ray images.
Because the X-ray film simulated by the application is actually the volume rendering of the three-dimensional image, the image and the bin are still in the three-dimensional space of the VTK three-dimensional volume rendering mapper, in the film reading process, if the viewing angle is required to be switched, the X-ray film effect under other viewing angles can be obtained only by moving the camera viewing angle in the three-dimensional space of the VTK three-dimensional volume rendering mapper during rendering, and as shown in fig. 6, the process does not need to rely on any additional calculation.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the invention.