matplotlib 绘制心肌模型图方法一:Axes.pie

matplotlib 绘制心肌模型图方法一:Axes.pie_第1张图片
美国心脏协会(AHA)发表了左心室心肌的分割和命名法,即心脏分割模型,现在医学界广泛使用该模型描述疾病对心肌区域和壁功能的影响。该模型图类似靶心图、牛眼图、嵌套环形图、bullseye chart.

下图是上述网站提供的模型图之一,它精确的表述了心肌模型的定义。
matplotlib 绘制心肌模型图方法一:Axes.pie_第2张图片
matplotlib 官网上有一个心肌模型的模拟实现:
https://matplotlib.org/gallery/specialty_plots/leftventricle_bulleye.html?highlight=bullseye

matplotlib 绘制心肌模型图方法一:Axes.pie_第3张图片
上图是心肌模型的近似模拟,与官网的定义有一些差别。

我尝试用 matplotlib 实现了心肌模型的定义的2D投影图。

心肌模型的元数据,和使用 matplotlib 实现心肌模型图的完整代码、高清成图请移步 https://download.csdn.net/download/sinat_32570141/15173848 下载。

17-Segment Model (AHA) 基础

参考网站

The American Heart Association (AHA)

https://radiopaedia.org/articles/cardiac-segmentation-model-1

17-Segment Model (AHA): https://www.pmod.com/files/download/v34/doc/pcardp/3615.htm

模型解读

模型过于专业,为便于对模型的理解,采用了中英文对照。翻译部分只是我的理解,不保证准确性,仅供参考!

The American Heart Association (AHA) has published the nomenclature and segmentation of the left ventricular myocardium (the cardiac segmentation model), now widely used for the description of disease-affected myocardial territories and wall function.

美国心脏协会(AHA)发表了左心室心肌的分割和命名法,即心脏分割模型,现在医学界广泛使用该模型描述疾病对心肌区域和壁功能的影响。

There are 17 segments that have a reasonably consistent vascular supply from one of the three main coronary arteries (RCA, LAD and LCx), but significant anatomic variation does exist. This standard segmentation model can be used in cardiac nuclear tests, computed tomography, magnetic resonance imaging, echocardiography and coronary angiography. Having a standard model optimizes intra- and inter-modality comparison.

左心室的心肌被分割为 17 个区域,相当稳定的由三个主要冠状动脉中的一个血管供应,分别是 (RCA, LAD and LCx), 但有显著的解剖学变异 anatomic variation . 该标准的分割模型可用于心脏核试验,计算机断层扫描,磁共振成像,超声心动图和冠状动脉造影。可以对标准模型进行模内优化和模间比较。

Myocardial segments 心肌分段

In the long axis, the left ventricle is divided into equal thirds named the basal, mid and apical thirds. The tip of the apex forms a separate final segment. When these thirds are viewed in short axis they form rings that are numbered counterclockwise which can be further divided into equal sectors:

在长轴上,左心室 left ventricle 被分为 basal, mid and apical 均等的三份。顶点的尖端 apex 形成一个单独的最后部分。这三部分从短轴上看形成环 rings,这些环可以进一步划分为相等的扇区,扇区按逆时针方向编号:

  • the basal third has six 60° sectors,basal 三分之一有6个 6 0 0 60^0 600 扇区
    • basal anterior (segment 1),基部前壁
    • basal anteroseptal (segment 2),基部前间壁
    • basal inferoseptal (segment 3),基部后间壁
    • basal inferior (segment 4),基部后壁(下壁)
    • basal inferolateral (segment 5),基部后侧壁
    • basal anterolateral (segment 6),基部前侧壁
  • the mid third has six 60° sectors,mid 三分之一有6个 6 0 0 60^0 600 扇区
    • mid anterior (segment 7),中部前壁
    • mid anteroseptal (segment 8),中部前间壁
    • mid inferoseptal (segment 9),中部后间壁
    • mid inferior (segment 10),中部后壁(下壁)
    • mid inferolateral (segment 11),中部后侧壁
    • mid anterolateral (segment 12),中部前侧壁
  • the apical third has four 90° sectors,apical 三分之一有4个 9 0 0 90^0 900 扇区
    • apical anterior (segment 13),心尖前壁
    • apical septal (segment 14),心尖间壁
    • apical inferior (segment 15),心尖后壁(下壁)
    • apical lateral (segment 16),心尖侧壁
  • finally, the tip of the ventricular apex is its own segment,最后,心室尖的尖端是它自己的一段
    • apex (segment 17),心尖

Coronary artery territories 冠状动脉区域

  • Left Anterior Descending (LAD),左前降支,LAD 供应 1, 2, 7, 8, 13, 14 and 17 段
  • Right Coronary Artery (RCA),右冠状动脉,RCA 供应 3, 4, 9, 10 and 15 段
  • Left Circumflex (LCX),左回旋支,LCx 供应 5, 6, 11, 12 and 16 段

Echocardiography 心电图

The inability to visualize the whole chamber often necessitates utilization of anatomical landmarks to delineate the thirds:

无法想象整个腔室,常常需要使用解剖标志来描述三个部分:

  • basal: mitral annulus to the tips of the papillary muscles in end-diastole

  • mid: along the length of the papillary muscles

  • apical: below the papillary muscles to the apex

Region

  • anterior, 前壁
  • inferior,后壁,下壁
  • inferolateral,后间壁,下侧壁
  • anterolateral,前间壁,前侧壁
  • septal,间壁,间隔
  • lateral,侧壁,侧面的
  • apex,尖,顶点,尖端

使用 Axes.pie() 方法实现

模型数据的读入

import numpy as np
import pandas as pd

MS_df = pd.read_csv('17-Segment.csv')

数据结构如下图:
matplotlib 绘制心肌模型图方法一:Axes.pie_第4张图片

自定义颜色转换函数

# 将[0,255]整数表示的RGB颜色值转化为[0,1]浮点数表示的RGB值元组
def make_color(df_col):
    ca_rgb = []
    for i in df_col:
        temp = i.replace('(','').replace(')','')
        temp_rgb = tuple([(int(j)/255) for j in temp.split(',')])
        ca_rgb.append(temp_rgb)
    return ca_rgb        
ms = ('basal','mid','apical','apex')
ca = ('LAD','RCA','LCX')
c_cmp = make_color(MS_df['CA_Color'])
c_ticks = MS_df['MS_N']

提取 axes.pie() 参数数据

# pie(x)
x_basal = MS_df[MS_df['MS']=='basal']['Angle'].values.tolist()
x_mid = MS_df[MS_df['MS']=='mid']['Angle'].values.tolist()
x_apical = MS_df[MS_df['MS']=='apical']['Angle'].values.tolist()
x_apex = MS_df[MS_df['MS']=='apex']['Angle'].values.tolist()
# colors
c_basal = make_color(MS_df[MS_df['MS']=='basal']['CA_Color'])
c_mid = make_color(MS_df[MS_df['MS']=='mid']['CA_Color'])
c_apical = make_color(MS_df[MS_df['MS']=='apical']['CA_Color'])
c_apex = make_color(MS_df[MS_df['MS']=='apex']['CA_Color'])
# labels
l_basal = MS_df[MS_df['MS']=='basal']['MS_N'].values.tolist()
l_mid = MS_df[MS_df['MS']=='mid']['MS_N'].values.tolist()
l_apical = MS_df[MS_df['MS']=='apical']['MS_N'].values.tolist()
l_apex = MS_df[MS_df['MS']=='apex']['MS_N'].values.tolist()

主图的实现

import matplotlib.pyplot as plt
import matplotlib as mpl

fig = plt.figure(figsize=(6.4,4.8),facecolor='w',constrained_layout=False)

#用于主图的 axes
ax = plt.axes((0.125,0.15,0.75,0.775))
#用于colorbar的 axes
axc = fig.add_axes([0.255, 0.11, 0.5, 0.04])

size = 0.25

# 用作标记 ca = ('LAD','RCA','LCX')的 pie
ax.pie((120,120,120),
       radius=1,
       colors='w',
       startangle=60,
       labels=ca,
       labeldistance=1.2,
       textprops={
     'fontfamily':'Calibri',
                  'fontsize':12,'va':'center','ha':'center'},
      )

....
....
# 完整的代码请前往https://download.csdn.net/download/sinat_32570141/15173848 下载

plt.savefig('M17S_pie.png',facecolor='w',dpi=600)
plt.show()

结果如下图:matplotlib 绘制心肌模型图方法一:Axes.pie_第5张图片
基本是官网上的心肌模型图的精确实现。

下一篇,将用 axes.bar() + polar 再现该图。

你可能感兴趣的:(matplotlib,python,matplotlib)