自动呼吸器官分割

Manual lung segmentation takes about 10 minutes and it requires a certain skill to get the same high-quality result as with automatic segmentation. Automatic segmentation takes about 15 seconds.

手动肺分割大约需要10分钟,并且需要一定的技能才能获得与自动分割相同的高质量结果。 自动分段大约需要15秒。

I assumed that without a neural network it would be possible to get an accuracy of no more than 70%. I also assumed, that morphological operations are only the preparation of an image for more complex algorithms. But as a result of processing of those, although few, 40 samples of tomographic data on hand, the algorithm segmented the lungs without errors. Moreover, after testing in the first five cases, the algorithm didn’t change significantly and correctly worked on the other 35 studies without changing the settings.

我假设没有神经网络,则准确度可能不会超过70%。 我还假设形态学操作只是为更复杂的算法准备图像。 但是,由于处理了这些手部断层扫描数据(尽管数量很少),尽管这些样本很少,但该算法对肺进行了分割,没有错误。 此外,在对前五种情况进行测试后,该算法并未发生明显变化,并且在不更改设置的情况下,在其他35项研究中也能正常工作。

Also, neural networks have a disadvantage — for their training we need hundreds of training samples of lungs, which need to be marked up manually.

此外,神经网络也有一个缺点-对于其训练,我们需要数百个肺部训练样本,这些样本需要手动标记。

内容 (Content)

呼吸系统的结构 (Structure of the respiratory system)

The respiratory system includes the airways and lungs. The airways are divided into the upper and lower airways. The point of separation between the lower and upper respiratory tract is the point of intersection of the esophagus and airways. All the organs that are above the larynx are the upper tract and the larynx and organs below are the lower tract.

呼吸系统包括气道和肺。 气道分为上,下气道。 下呼吸道与上呼吸道之间的分离点是食道与气道的交点。 喉以上的所有器官均为上呼吸道,喉及以下的器官为下呼吸道。

List of the respiratory organs:

呼吸器官清单:

The nasal cavity is an air-filled cavity between the nose and the pharynx. The pharynx is a channel through which food and air travels. The trachea is a tube connected to the larynx and bronchi. The larynx is responsible for the voice forming. It is at the level of the cervical vertebrae C4-C6. The bronchi are the respiratory channels, the main part of which is located inside the lungs. The lungs are the main respiratory organ.

鼻腔是在鼻子和咽之间的充满空气的腔。 是食物和空气传播的通道。 气管是连接到喉和支气管的管。 负责声音的形成。 它处于颈椎C4-C6的水平。 支气管是呼吸道,其主要部分位于肺部内部。 是主要的呼吸器官。

豪恩斯菲尔德量表 (Haunsfield scale)

Godfrey Hounsfield was an English electrical engineer who, together with American theorist Allan Cormack, developed computed tomography, for which he shared the Nobel Prize in 1979.

戈弗雷·霍恩斯菲尔德(Godfrey Hounsfield)是一位英国电气工程师,他与美国理论家艾伦·科马克(Allan Cormack)一起开发了计算机断层扫描技术,为此他在1979年获得了诺贝尔奖。

The Hounsfield scale — is a quantitative scale for describing radiodensity, which is measured in Hounsfield units, denoted as HU.

霍恩斯菲尔德标度-是用于描述无线电密度的定量标度,它以霍恩斯菲尔德单位表示,表示为HU。

Radiodensity is calculated on the basis of the radiation attenuation coefficient. Attenuation coefficient characterizes how easily a volume of material can be penetrated by the radiation.

辐射密度是根据辐射衰减系数计算的。 衰减系数表征了一定数量的材料可以被辐射穿透的程度。

Radiodensity is calculated by the formula:

辐射密度通过以下公式计算:

$$display$${μ_{X}-μ_{water} \over μ_{water}-μ_{air}} \times 1000$$display$$

$$ display $$ {μ_{X}-μ_{water} \ overμ_{water}-μ_{air}} \次1000 $$ display $$

where are linear attenuation coefficients for the measured material, water and air.

哪里 是被测材料,水和空气的线性衰减系数。

Radiodensity can be negative because zero radiodensity corresponds to water. This means that all materials having a lower attenuation coefficient than water attenuation coefficient (for example, lung tissue, air) will have a negative radiodensity.

放射性密度可以为负,因为零放射性密度对应于水。 这意味着所有具有比水衰减系数低的衰减系数的材料(例如,肺组织,空气)将具有负的放射性密度。

The approximate radiodensities for various tissues are listed below:

下面列出了各种组织的大约射线密度:

  • Air: -1000 HU.

    空气:-1000 HU。
  • Respiratory organs: from -950 to -300 HU.

    呼吸器官:-950至-300 HU。
  • Blood (without contrasting the vessels): from 0 to 100 HU.

    血液(不与血管形成对比):从0到100 HU。
  • Bones: 100 to 1000 HU.

    骨骼:100至1000 HU。

Links to Wikipedia: Hounsfield scale, Godfrey Hounsfield, attenuation coefficient.

链接到Wikipedia: 霍恩斯菲尔德标度戈弗雷·霍恩斯菲尔德衰减系数

数学形态 (Mathematical morphology)

Morphological operations are the main tools which were used in the algorithm. In the field of computer vision, morphological operations are called a group of algorithms for the transformation of the shape of objects. Most often, morphological operations are applied to binarized images where units correspond to object voxels, and zeros to empty. The main morphological operations include:

形态学运算是算法中使用的主要工具。 在计算机视觉领域,形态学运算被称为一组用于变换对象形状的算法。 最常见的是,形态学运算应用于二进制化的图像,其中单位对应于对象体素,零对应于空白。 主要的形态学操作包括:

Morphological dilation is the adding new voxels to all edge voxels of the objects. In other words, algorithm scans all the voxels corresponding to the edge of the object and enlarge them using a kernel with a given form (sphere, cube, cross etc). The kernel has its own radius (for the sphere), or the width of the side (for the cube). This operation is often used to merge multiple nearby objects into a single object.

形态膨胀是向对象的所有边缘体素添加新的体素。 换句话说,算法扫描与对象边缘相对应的所有体素,并使用具有给定形式(球形,立方体,十字形等)的内核将其放大。 内核具有自己的半径(对于球体)或侧面的宽度(对于立方体)。 此操作通常用于将多个附近的对象合并为一个对象。

Morphological erosion is the cut-off of all voxels lying on the border (boundary) of the objects. This operation is reverse to dilation. This operation is useful for removing noise which has the form of many small interconnected objects. However, this method of noise removal should be only used if the object of interest has a thickness much greater than the radius of erosion. Otherwise, the useful information will be lost.

形态侵蚀是位于对象边界(边界)上的所有体素的截止。 此操作与扩张相反。 此操作对于消除具有许多小互连对象形式的噪声非常有用。 但是,仅当目标物体的厚度比腐蚀半径大得多时,才应使用这种噪声消除方法。 否则,有用的信息将丢失。

Morphological closing is a dilation followed by an erosion. It is used to close holes inside objects and to merge nearby objects.

形态学上的闭合是扩张,随后是侵蚀。 它用于封闭对象内部的Kong并合并附近的对象。

Morphological opening is an erosion followed by a dilation. It is used to remove small noise objects and to separate the objects into several objects.

形态学上的开放是侵蚀然后扩张。 它用于去除小噪音对象并将这些对象分成几个对象。

Lee算法和RLE压缩 (Lee algorithm and RLE compression)

To select objects in binarized voxel volume, the Lie algorithm is used. Originally this algorithm was invented to find the shortest way out of the labyrinth. We use it to select the object and move it from one three-dimensional array of voxels to another. The basic idea of the algorithm consists in parallel movement in all possible directions from the starting point. For a three-dimensional case, it is possible to move in 26 or 6 directions from one voxel.

为了选择二值化体素体积中的对象,使用了Lie算法。 最初,发明该算法是为了找到走出迷宫的最短路径。 我们使用它来选择对象并将其从三维三维像素阵列移动到另一个三维像素阵列。 该算法的基本思想是从起点开始在所有可能的方向上平行移动。 对于三维情况,可以从一个体素沿26或6个方向移动。

To optimize the performance, the run-length encoding algorithm was applied. The main idea of the algorithm is that the sequence of ones and zeros is replaced by a digit equal to the number of elements in the sequence. For example, the string “00110111” can be replaced by: “2; 2; 1; 3”. This reduces the number of memory accesses.

为了优化性能,应用了行程编码算法。 该算法的主要思想是将一和零的序列替换为一个数字,该数字等于该序列中元素的数量。 例如,字符串“ 00110111”可以替换为:“ 2; 2; 1; 3”。 这减少了内存访问的次数。

Wikipedia links: Lee algorithm, RLE algorithm.

Wikipedia链接: Lee算法RLE算法

基本体积的阈值转换 (Threshold transform of the base volume)

Using the tomograph there were obtained the data about an radiodensity at each point of the scanned space. Air voxels have an radiodensity in the range from -1100 to -900 HU, and respiratory organs voxels have radiodensity from -900 to -300 HU. Therefore, we can remove all unnecessary voxels with radiodensity greater than -300 HU. As a result, we obtain a binarized voxel volume containing only the respiratory organs and air.

使用断层扫描仪获得有关扫描空间每个点的射线密度的数据。 空气体素的辐射密度为-1100至-900 HU,而呼吸器官体素的辐射密度为-900至-300 HU。 因此,我们可以删除所有辐射密度大于-300 HU的不必要体素。 结果,我们获得了仅包含呼吸器官和空气的二值化体素体积。

外部空气排出 (External air removal)

To segment the internal air of the body, we delete all objects that are adjacent to the corners of the 3D volume. Thus, we remove the external air.

为了分割身体的内部空气,我们删除了3D立体角附近的所有对象。 因此,我们去除了外部空气。

However, not in all cases the air inside the tomograph table will be removed, because it may not have a connection with the corners of the 3D volume.

但是,并非所有情况都可以消除断层扫描仪工作台中的空气,因为断层扫描仪工作台可能与3D体积的角部没有任何联系。

Therefore, we will scan not only the corners, but also all the voxels lying on any of the edge planes of the f. But, as we can see in the image below, the lungs were also removed. It turns out that the trachea also had a connection with the upper plane of the 3D volume.

因此,我们不仅将扫描角,而且还将扫描位于f的任何边缘平面上的所有体素。 但是,如下图所示,肺也被切除了。 事实证明,气管还与3D体积的上平面有关。

We'll have to exclude the top plane from the scan area. There are also studies in which the lungs were not fully captured and the lower plane is connected to the lungs. So if you wish, you can exclude the lower plane too.

我们必须从扫描区域中排除顶部平面。 也有研究未完全捕获肺部并且下平面连接到肺部。 因此,如果您愿意,也可以排除下平面。

But this method only affects chest studies. In the case of the capture of the full volume of the body, the connection of internal and external air through the nasal cavity will appear Therefore, it is necessary to apply morphological erosion to separate the internal and external air.

但是这种方法仅影响胸部研究。 在捕获整个身体的情况下,将出现通过鼻腔的内部和外部空气的连接。因此,有必要进行形态学侵蚀以分离内部和外部空气。

After applying erosion, we can return to the previously obtained method of segmentation of external air which is based on connectivity of the external air with side planes of the 3D-volume.

施加腐蚀之后,我们可以返回先前获得的外部空气分割方法,该方法基于外部空气与3D体积侧面的连通性。

After the external air segmentation, we could immediately subtract the external air from the whole volume of the air and lungs and to get the internal air of the body and lungs. But there is one problem. After erosion, some of the information about the external air was lost. To restore it, we apply dilatation of external air.

在对外部空气进行分割之后,我们可以立即从整个空气和肺部体积中减去外部空气,从而获得身体和肺部的内部空气。 但是有一个问题。 侵蚀后,有关外部空气的一些信息丢失了。 为了恢复它,我们采用外部空气膨胀。

Next, we subtract the external air from the whole air and respiratory organs and get the internal air and respiratory organs.

接下来,我们从整个空气和呼吸器官中减去外部空气,得到内部空气和呼吸器官。

最大体积对象的分割 (Segmentation of the maximum volume object)

Next, we segment the respiratory organs as the maximum object in volume. The respiratory organs have no connection with the air inside the gastrointestinal tract.

接下来,我们将呼吸器官分割为体积最大的对象。 呼吸器官与胃肠道内的空气无关。

It is worth noting that the correct choice of the radiodensity threshold at the initial step is important. Otherwise, in some cases, there may be no connection between the two lungs as a result of low resolution. For example, if we assume that voxels of the respiratory organs have radiodensity from -500 HU and less, then in the case below, segmentation of the respiratory organs as the largest object in volume will lead to an error, because there is no connection between the two lungs. Therefore, the threshold should be increased to -300 HU.

值得注意的是,在初始步骤正确选择射线密度阈值很重要。 否则,在某些情况下,由于分辨率低,两个肺之间可能没有连接。 例如,如果我们假设呼吸器官的体素具有-500 HU及以下的放射密度,则在以下情况下,将呼吸器官分割为体积最大的对象将导致错误,因为两个肺。 因此,阈值应增加到-300 HU。

关闭肺部血管 (Closing the vessels inside the lungs)

To capture the vessels inside the lungs we will use morphological closing, that is, dilation followed by erosion with the same radius. Radiodensity of vessels (without contrasting) is about 0..100 HU.

为了捕获肺内的血管,我们将使用形态学上的闭合,即扩张,然后以相同的半径进行侵蚀。 血管的放射密度(无反差)约为0..100 HU。

In the image we can see that large blood channels are not closed. But this is not necessary. The purpose of this operation was to destroy the many small holes inside the lungs to simplify lung segmentation process in the next steps.

在图像中,我们可以看到大的血液通道没有关闭。 但这不是必需的。 此操作的目的是破坏肺内的许多小Kong,以简化后续步骤中的肺分割过程。

呼吸器官分割算法 (Respiratory organs segmentation algorithm)

As a result, we obtain the following respiratory organs segmentation algorithm:

结果,我们获得了以下呼吸器官分割算法:

  1. Threshold transform of the base volume with the threshold “< -300 HU”.

    具有阈值“ <-300 HU”的基本卷的阈值变换。
  2. Morphological erosion with the 3 mm radius for the separation of external and internal air.

    半径为3 mm的形态腐蚀,用于外部和内部空气的分离。
  3. Segmentation of external air based on external air connectivity with the boundary side planes of the 3D volume.

    基于外部空气与3D体积边界侧平面的连通性对外部空气进行细分。
  4. Morphological dilation of the external air to restore the information lost after the erosion.

    外部空气的形态膨胀可恢复侵蚀后丢失的信息。
  5. Subtraction of the external air from the whole air and respiratory organs to obtain the internal air and respiratory organs.

    从整个空气和呼吸器官中减去外部空气以获得内部空气和呼吸器官。
  6. Segmentation of the maximum volume object.

    最大体积对象的分段。
  7. Morphological closing of the vessels inside the lungs.

    肺内血管的形态闭合。

MATLAB中的算法实现 (Algorithm implementation in MATLAB)

函数“ getRespiratoryOrgans” (Function "getRespiratoryOrgans")

% Returns the whole respiratory organs volume (lung and airway volume)
% without separating of the left and right lung.

% V = base volume with radiodensity data in Hounsfield units.
% cr = radius of vessels morphological closing.
% ci = iteration count of vessels morphological closing (f.e. 3-times
% make dilation and after that 3-times make erosion.

function RO = getRespiratoryOrgans(V,cr,ci)
% Threshold transform of the base volume with the threshold level "<-300 HU".
AL=~imbinarize(V,-300);
% Morphological erosion with the 3 mm radius for the separation of external
% and internal air.
SE=strel('sphere',3);
EAL=imerode(AL,SE);
% Segmentation of external air based on external air connectivity with the
% boundary side planes of the 3D volume.
EA=getExternalAir(EAL);
% Morphological dilation of the external air to restore the information lost
% after the erosion.
DEA=EA;
for i=1:4
    DEA=imdilate(DEA,SE);
    DEA=DEA&AL;
end
% Subtraction of the external air from the whole air and respiratory organs to
% obtain the internal air and respiratory organs.
IAL=AL-DEA;
% Segmentation of the maximum volume object.
RO=getMaxObject(IAL);
Morphological closing of the vessels inside the lungs.
RO=closeVoxelVolume(RO,3,2);

函数“ getExternalAir” (Function "getExternalAir")

% Returns the volume which is connected with the edge surfaces of
% the voxel scene (except the top surface, because lungs can have
% a connection with the top surface).

% EAL = eroded lung-and-air binarized volume.

function EA = getExternalAir(EAL)
% The “bwlabeln” function segments objects: voxels of a one object
% equates   to 1,  and of another one  - to 2, etc.
V=bwlabeln(EAL);
% We request such characteristics of the objects as bounding box and
% list of all object voxels.
R=regionprops3(V,'BoundingBox','VoxelList');
n=height(R);
% Create a 3D matrix for storing external air voxels.
s=size(EAL);
EA=zeros(s,'logical');
% Scan all the objects to find objects belonging to the external air.
for i=1:n
    % Define the minimum and maximum x and y coordinates of the object.
    x0=R(i,1).BoundingBox(1);
    y0=R(i,1).BoundingBox(2);
    x1=x0+R(i,1).BoundingBox(4);
    y1=y0+R(i,1).BoundingBox(5);
   % If the edge voxels of the object are in contact with the side planes of
   % the 3D volume, then copy all the voxels of this object into the matrix EA.
    if (x0 < 1 || x1 > s(1)-1 || y0 < 1 || y1 > s(2)-1)
        % Convert the object voxel coordinates data to the matrix type:
        % [[x1 y1 z1] [x2 y2 z3] ... [xn yn zn]].
        mat=cell2mat(R(i,2).VoxelList);
        ms=size(mat);
        % Fill the matrix containing the voxels of the external air.
        for j=1:ms(1)
            x=mat(j,2);
            y=mat(j,1);
            z=mat(j,3);
            EA(x,y,z)=1;
        end
    end
end

函数“ getMaxObject” (Function "getMaxObject")

% Returns the largest object in the voxel volume V.

% O = the voxels of the largest object.
% m = the volume of the largest object.

function [O,m] = getMaxObject(V)
% Segment the objects. 
V=bwlabeln(V);
% Reqiest the information about the objects volume and objects voxel coordinates.
R=regionprops3(V,'Volume','VoxelList');
% Determine the index of the maximum volume object.
v=R(:,1).Volume;
[m,i]=max(v);
% Create the 3D matrix for storing the largest object voxels.
s=size(V);
O=zeros(s,'logical');
% Copy the largest object voxels to the new matrix.
mat=cell2mat(R(i,2).VoxelList);
ms=size(mat);
for j=1:ms(1)
    x=mat(j,2);
    y=mat(j,1);
    z=mat(j,3);
    O(x,y,z)=1;
end

The source code can be downloaded by the reference.

可以通过参考下载源代码。

结论 (Conclusion)

The following articles are going to be:

以下文章将是:

  1. trachea and bronchi segmentation;

    气管和支气管分割;
  2. lung segmentation;

    肺分割
  3. lung lobes segmentation.

    肺叶分割。

The following algorithms will be considered:

将考虑以下算法:

  1. distance transform;

    距离变换
  2. nearest neighbor transform, also known as feature transform;

    最近邻变换,也称为特征变换;
  3. calculation of the eigenvalues ​​of the Hessian matrix for segmentation of flat 3D objects;

    计算Hessian矩阵的特征值以分割平面3D对象;
  4. watershed segmentation.

    分水岭分割。

翻译自: https://habr.com/en/company/inobitec/blog/461329/

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值