Disclosure of Invention
In view of the above-mentioned shortcomings of the prior art, an object of the present invention is to provide a method and a system, a medium, and a terminal for positioning a stereotactic frame, which effectively solve the problems of low positioning accuracy and long positioning time of the stereotactic frame.
To achieve the above and other related objects, the present invention provides a stereotactic frame positioning method, comprising the steps of: preprocessing a CT image containing a three-dimensional orientation frame, and filtering a frame of a positioner in the three-dimensional orientation frame; obtaining a priori coordinate point of the locator on the CT image of the frame which is filtered; acquiring a contour center position point of the positioner on each slice layer of the CT image with the frame filtered; filtering the contour center position points of each sheet layer to obtain effective sheet layers with three contour center position points on the left, right and upper sides; calculating the coordinates of the left, right and upper reference points under the coordinate system of the stereotactic frame on each effective slice layer based on the contour center position point of the effective slice layer; the reference point is a contour center position point which is positioned at the middle position on the left, right and upper sides; calculating a three-dimensional affine transformation matrix from the image coordinate system to the stereoscopic orientation frame coordinate system based on the reference point coordinates on each effective slice layer; mapping image coordinates of the stereotactic frame to the stereotactic frame coordinate system based on the three-dimensional affine transformation matrix.
In an embodiment of the present invention, the pre-processing of the CT image including the stereotactic frame comprises the following steps:
selecting a filtering threshold value;
filtering the CT image based on the filtering threshold to filter out a frame of the localizer within the stereotactic frame.
In an embodiment of the present invention, the obtaining the prior coordinate point of the locator includes the following steps:
searching coordinate points at the first non-zero value appearing on the left, right and upper parts of each slice layer of the CT image with the frame filtered out layer by layer;
and taking the coordinate point with the largest occurrence number as the prior coordinate point.
In an embodiment of the present invention, the contour center position point of the locator is obtained based on the pattern moment.
In an embodiment of the present invention, the filtering the contour center position points of each slice to obtain an effective slice having three contour center position points on the left, right, and upper sides includes the following steps:
according to the distance between the prior coordinate point and the contour center position point, filtering out the contour center position point of which the distance is greater than the radius of the locator on each slice;
and taking the slice with three contour center position points on the left, right and upper sides as an effective slice.
In an embodiment of the present invention, the stereotactic frame coordinate system comprises two custom parameters and a relative height; the relative height of the reference point is hrL λ, l being the locator height, λ being the ratio of the distance from the starting edge profile center position point of the three profile center position points to the reference point to the distance between the two edge profile center position points.
In an embodiment of the invention, a three-dimensional affine transformation matrix from an image coordinate system to a three-dimensional orientation frame coordinate system is calculated based on a least square method and a RANSAC abnormal point filtering algorithm.
Correspondingly, the invention provides a stereotactic frame positioning system, which comprises a preprocessing module, a first obtaining module, a second obtaining module, a filtering module, a first calculating module, a second calculating module and a mapping module, wherein the preprocessing module is used for acquiring a frame image;
the preprocessing module is used for preprocessing a CT image containing a stereotactic frame and filtering a frame of a positioner in the stereotactic frame;
the first acquisition module is used for acquiring a priori coordinate point of the positioner on the CT image of the filtered frame;
the second acquisition module is used for acquiring a contour center position point of the positioner on each slice layer of the CT image of the frame after being filtered;
the filtering module is used for filtering the contour center position points of all the sheet layers to obtain effective sheet layers with three contour center position points on the left, right and upper sides;
the first calculation module is used for calculating the coordinates of the left, right and upper reference points in a coordinate system of the stereotactic frame on each effective slice layer based on the contour center position point of the effective slice layer; the reference point is a contour center position point which is positioned at the middle position on the left, right and upper sides;
the second calculation module is used for calculating a three-dimensional affine transformation matrix from an image coordinate system to a three-dimensional orientation frame coordinate system based on the reference point coordinates on each effective slice layer;
the mapping module is configured to map image coordinates of the stereotactic frame to the stereotactic frame coordinate system based on the three-dimensional affine transformation matrix.
The present invention provides a storage medium having stored thereon a computer program which, when executed by a processor, implements the stereotactic frame positioning method described above.
Finally, the present invention provides a terminal comprising: a processor and a memory;
the memory is used for storing a computer program;
the processor is configured to execute the computer program stored in the memory, so as to enable the terminal to execute the stereotactic frame positioning method.
As described above, the stereotactic frame positioning method and system, medium, and terminal of the present invention have the following advantageous effects:
(1) the reference points can be automatically identified, and the reference points do not need to be manually selected or screened, so that subjective errors are reduced;
(2) the positioning can be realized according to the mapping relation between the reference point coordinates and the image coordinates, and the positioning time is effectively shortened;
(3) the problems of low positioning precision and long positioning time of the three-dimensional directional frame are solved.
Detailed Description
The embodiments of the present invention are described below with reference to specific embodiments, and other advantages and effects of the present invention will be easily understood by those skilled in the art from the disclosure of the present specification. The invention is capable of other and different embodiments and of being practiced or of being carried out in various ways, and its several details are capable of modification in various respects, all without departing from the spirit and scope of the present invention.
It should be noted that the drawings provided in the present embodiment are only for illustrating the basic idea of the present invention, and the components related to the present invention are only shown in the drawings rather than drawn according to the number, shape and size of the components in actual implementation, and the type, quantity and proportion of the components in actual implementation may be changed freely, and the layout of the components may be more complicated.
The method, the system, the medium and the terminal for positioning the three-dimensional orientation frame realize the accurate positioning of the three-dimensional orientation frame by automatically selecting the reference point and establishing the mapping relation between the reference point coordinate and the image coordinate, effectively solve the problems of lower positioning accuracy and longer positioning time of the three-dimensional orientation frame and have high practicability.
As shown in fig. 1, in an embodiment, the stereotactic frame positioning method of the present invention includes the following steps:
and step S1, preprocessing the CT image containing the stereotactic frame, and filtering out the frame of the localizer in the stereotactic frame.
Specifically, the positioner is disposed inside the stereotactic frame, so in order to determine the position of the positioner, the frames located at the edges of the positioner are first filtered out on the CT image containing the stereotactic frame.
In an embodiment of the present invention, the pre-processing of the CT image including the stereotactic frame comprises the following steps:
11) and selecting a filtering threshold value.
Specifically, the filtering threshold is used for performing a filtering operation on the CT image, so as to divide the CT image into a background portion and a target portion. In the invention, the positioner is made to be a target part and the frame is a background part by selecting a reasonable filtering threshold.
12) Filtering the CT image based on the filtering threshold to filter out a frame of the localizer within the stereotactic frame.
And step S2, acquiring prior coordinate points of the locator on the CT image of the frame which is filtered.
Specifically, on each slice of the CT image of the frame to be filtered, coordinate points at which a non-zero value appears for the first time are searched layer by layer above the left side, the right side, and the top side. Then, the respective coordinate points are counted, and the coordinate point with the largest occurrence number is taken as the prior coordinate point, i.e., the point indicating the position of the locator.
And step S3, acquiring the contour center position point of the locator on each slice of the CT image of the frame which is filtered.
Specifically, a contour center position point of the locator is acquired based on a pattern moment.
And step S4, filtering the contour center position points of each slice layer to obtain effective slice layers with three contour center position points on the left, right and upper sides.
Specifically, on the CT image of the frame to be filtered, there may be some burrs around the positioner, so the contour center point obtained in the above steps may be located on the burrs, and therefore a filtering process is required to improve the accuracy. After the filtering treatment, only the slice layer with three contour center position points at the left, right and upper parts is reserved as an effective slice layer. For slices with more or less than three contour center location points to the left, right, and above, the process is eliminated.
In an embodiment of the present invention, the filtering the contour center position points of each slice to obtain an effective slice having three contour center position points on the left, right, and upper sides includes the following steps:
41) and filtering contour center position points with the distances larger than the radius of the locator on each slice according to the distances between the prior coordinate points and the contour center position points.
42) And taking the slice with three contour center position points on the left, right and upper sides as an effective slice.
Step S5, calculating the coordinates of the left, right and upper reference points in the coordinate system of the stereotactic frame on each effective slice layer based on the contour center position point of the effective slice layer; the reference point is a contour center position point with the left, right and upper parts located at the middle position.
Specifically, on each active slice, the reference point coordinates of the left, right, and top are calculated. The reference point refers to the center position point of the contour, which is positioned at the middle position on the left, right and upper sides. In an embodiment of the present invention, the stereotactic frame coordinate system includes two custom parameters and a relative height. The relative height of the reference point is hrL λ, l being the locator height, λ being the ratio of the distance from the starting edge profile center position point of the three profile center position points to the reference point to the distance between the two edge profile center position points. And for the left and right directions, the contour center position points are arranged from top to bottom, and the contour center position point positioned at the top is the contour center position point of the starting edge. For the upper part, the contour center position points are arranged in the order from left to right, and the contour center position point positioned at the leftmost side is the contour center position point of the starting edge.
As shown in FIG. 2, there are A, B and C contour center points on the left side, and B is taken as a referenceAnd (4) point. The relative height of B is h
rL λ, wherein,
and step S6, calculating a three-dimensional affine transformation matrix from the image coordinate system to the stereotactic frame coordinate system based on the reference point coordinates on each effective slice layer.
Specifically, a three-dimensional affine transformation matrix from an image coordinate system to a three-dimensional orientation frame coordinate system is calculated based on a least square method and a RANSAC abnormal point filtering algorithm. In one embodiment, the three-dimensional affine transformation matrix is as follows:
wherein (x, y, z) represents image coordinates, (x ', y ', z ') represents reference point coordinates, and the matrix
Representing a three-dimensional affine matrix containing 12 parameters to be optimized.
And step S7, mapping the image coordinates of the stereotactic frame to the stereotactic frame coordinate system based on the three-dimensional affine transformation matrix.
Specifically, for the stereotactic frame, the image coordinates of the stereotactic frame are mapped to the stereotactic frame coordinate system through the three-dimensional affine transformation matrix, so that the automatic positioning of the stereotactic frame is realized.
As shown in fig. 3, in an embodiment, the stereotactic frame positioning system of the present invention comprises apreprocessing module 31, a first obtainingmodule 32, a second obtainingmodule 33, afiltering module 34, a first calculatingmodule 35, asecond calculating module 36 and amapping module 37.
Thepreprocessing module 31 is configured to preprocess a CT image including a stereotactic frame, and filter out a frame of a positioner in the stereotactic frame.
The first obtainingmodule 32 is connected to thepreprocessing module 31, and is configured to obtain a priori coordinate points of the locator on the CT image of the frame filtered out.
The second obtainingmodule 33 is connected to thepreprocessing module 31, and is configured to obtain a contour center position point of the positioner on each slice of the CT image with the frame filtered out.
Thefiltering module 34 is connected to the first obtainingmodule 32 and the second obtainingmodule 33, and configured to filter the contour center position points of each slice, and obtain an effective slice having three contour center position points on the left, right, and upper sides.
Thefirst calculating module 35 is connected to thefiltering module 34, and is configured to calculate, on each effective slice layer, left, right, and upper reference point coordinates in a stereotactic frame coordinate system based on a contour center position point of the effective slice layer; the reference point is a contour center position point with the left, right and upper parts located at the middle position.
Thesecond calculating module 36 is connected to the first calculatingmodule 35, and is configured to calculate a three-dimensional affine transformation matrix from the image coordinate system to the stereotactic frame coordinate system based on the reference point coordinates on each active slice layer.
Themapping module 37 is connected to thesecond computing module 36, and is configured to map the image coordinates of the stereotactic frame to the stereotactic frame coordinate system based on the three-dimensional affine transformation matrix.
The structures and principles of thepreprocessing module 31, the first obtainingmodule 32, the second obtainingmodule 33, thefiltering module 34, the first calculatingmodule 35, thesecond calculating module 36, and themapping module 37 correspond to the steps of the stereotactic frame positioning method one to one, and therefore, the descriptions thereof are omitted here.
It should be noted that the division of the modules of the above apparatus is only a logical division, and the actual implementation may be wholly or partially integrated into one physical entity, or may be physically separated. And these modules can be realized in the form of software called by processing element; or may be implemented entirely in hardware; and part of the modules can be realized in the form of calling software by the processing element, and part of the modules can be realized in the form of hardware. For example, the x module may be a processing element that is set up separately, or may be implemented by being integrated in a chip of the apparatus, or may be stored in a memory of the apparatus in the form of program code, and the function of the x module may be called and executed by a processing element of the apparatus. Other modules are implemented similarly. In addition, all or part of the modules can be integrated together or can be independently realized. The processing element described herein may be an integrated circuit having signal processing capabilities. In implementation, each step of the above method or each module above may be implemented by an integrated logic circuit of hardware in a processor element or an instruction in the form of software.
For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more Application Specific Integrated Circuits (ASICs), or one or more microprocessors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs), among others. For another example, when one of the above modules is implemented in the form of a Processing element scheduler code, the Processing element may be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
The storage medium of the present invention has stored thereon a computer program which, when executed by a processor, implements the stereotactic frame positioning method described above. The storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic disk, U-disk, memory card, or optical disk.
As shown in fig. 4, in an embodiment, the terminal of the present invention includes: aprocessor 41 and amemory 42.
Thememory 42 is used for storing computer programs.
Thememory 42 includes: various media that can store program codes, such as ROM, RAM, magnetic disk, U-disk, memory card, or optical disk.
Theprocessor 41 is connected to thememory 42, and is configured to execute the computer program stored in thememory 42, so as to enable the terminal to execute the above-mentioned stereotactic frame positioning method.
Preferably, theProcessor 41 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, or discrete hardware components.
In conclusion, the stereotactic frame positioning method, the stereotactic frame positioning system, the medium and the terminal can automatically identify the reference point without manually selecting or screening the reference point, so that subjective errors are reduced; the positioning can be realized according to the mapping relation between the reference point coordinates and the image coordinates, and the positioning time is effectively shortened; the problems of low positioning precision and long positioning time of the three-dimensional directional frame are solved. Therefore, the invention effectively overcomes various defects in the prior art and has high industrial utilization value.
The foregoing embodiments are merely illustrative of the principles and utilities of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or change the above-mentioned embodiments without departing from the spirit and scope of the present invention. Accordingly, it is intended that all equivalent modifications or changes which can be made by those skilled in the art without departing from the spirit and technical spirit of the present invention be covered by the claims of the present invention.