MATLAB之TOPAS输出文件画剂量分布图

TOPAS输出的CSV文件都具有固定格式,前三列为坐标位置,最后一列为坐标点剂量值。如下图所示

# TOPAS Version: 3.1.p3  
# Parameter File: 160MeV3mmProton_2x2.txt
# Results for scorer ScoreToWaterBox1
# Scored in component: ScoringBox1
# X in 1 bin  of 0.1 cm  
# Y in 100 bins of 0.1 cm  
# Z in 210 bins of 0.1 cm  
# DoseToMedium ( Gy ) : Sum     
0 0 0 1.15E-05
0 0 1 1.79E-05
0 0 2 1.48E-05
0 0 3 1.60E-05
0 0 4 1.45E-05

现在要做的就是在一个二维图上表示出剂量的大小,具体程序和解释如下所示:

%绘画TOPAS文件深度剂量分布(分层型)
filename='C:\Users\32628\OneDrive\Work_File\first_stage\110MeVproton2_5Bone.csv';
%从第九层开始读取
Spot_temp1=csvread(filename,8,0);
%文件的行列数
[Spot_row1,Spot_col1]=size(Spot_temp1);
%读取最大值
Spot_temp2(:,1)=Spot_temp1(:,4);
Max_value1 = max(Spot_temp2(:));
%给每一个坐标赋计算得到的剂量值,保存在Spot_z1,并归一化
for a=1:1:Spot_row1   
c=rem(a-1,210)+1;%z
d=floor(a/(60*210))+1;%x
e=floor(rem(a-1,60*210)/210)+1;%y
Spot_z1(c,e,d)=Spot_temp2(a,1)/Max_value1;
end
%画图的坐标范围
Spot_x1=-29:1:30;
Spot_y1=-29:1:30;
Spot_z=1:1:209;
for c=1:1:60
figure(1);
imagesc(Spot_z,Spot_y1,rot90(Spot_z1(1:210,1:60,c)));
string=sprintf('%d',c);
string = strcat(string,'mm');
picdir1 = strcat('C:\Users\32628\OneDrive\Work_File\110MeVproton2_5Bone.csv\' ,string);
Spot_h1=colorbar('eastOutside');
xlabel('水深度 (1 mm)','FontSize',10,'FontWeight','bold');
ylabel('纵向宽度 (1 mm)','FontSize',10,'FontWeight','bold');
set(get(Spot_h1,'Title'),'string','相对剂量','FontSize',10,'FontWeight','bold');
Spot_t1=get(Spot_h1,'YTickLabel');
set(Spot_h1,'YTickLabel',Spot_t1);
title(string,'FontSize',10,'FontWeight','bold');
set(gca,'FontSize',10,'FontWeight','bold');
print('-dpng',picdir1,'-r100');
end      

猜你喜欢

转载自blog.csdn.net/qq_40770653/article/details/81187582