这个里面
Channel = Default Beam
Focal Law = Linear L1 : 1-1
Type = A-Scan
ScanStart (m) = 0.00
ScanQty (sample) = 151.0
ScanResol (m) = 1.00
IndexStart (m) = 0.00
IndexQty (sample) = 1.0
IndexResol (m) = 1.00
USoundStart (mm) = 0.00
USoundQty (sample) = 1484.0
USoundResol (mm) = 0.04
AmplMin (sample) = 0.0
AmplMax (sample) = 255.0
AmplStart (%) = 0.00
AmplResol (%) = 0.39
这是代表每一个channel 的信息 (总过有128个channel)
每一个channel 里面含有multiple lines of data(含有很多line of data 类似于在L1-1)
类似于在channel 1(L1-1里面)
line 1的信息始于1.1……止于0.3
line 2 的信息始于 2.7……止于0.7
line 3的信息始于 2。7……止于 0.7
line m……止于0 (我猜测每个line的长度n都是一样的)
Channel 2
……
channel i
我的思路是把每一个channel 的信息都读取并且储存起来变成一个i*m*n的矩阵,然后绘制成一个3D的图
我刚开始学用python 目前的
import numpy as np
from tifffile import imsave
import io
#number of elements in array
i = 128
#open the text file with all headers打开text file
data = io.open('BreastPhantomTest.txt','r',encoding='cp1252')
#create a list of all lines with data in them - the typical format is for 16 lines of header,
#followed by 'n' lines of data each 'm' tab delimited data points long
#where 'n' is the number of points in the scan direction and 'm' is the number of digitization points
#This repeats for each 'i element.
#line = data.readlines() ##-- this method will get slow for larger datasets I believe
datatrimmed=[]
#assume lines with data start with a non-zero number this should scale up in data size.
#We can also use this method to get other parameters out of the header.
for line in data:
#line = line.rstrip()
if not line[0].isdigit():continue #take only the digits
#if not line[0]!=0:continue #take only the lines that don't start with a zero.
#line=data.readline()
f = line.split()# I put read() in the middle of line and split, saying 'str' has no attribute 'read'
datatrimmed.append(f)
datatrimmed.append(f)
m = len(f)
volume=np.reshape(datatrimmed,(i,-1,m)) #create the volume, leaving the number of scan points to float
volume1=np.float32(volume)
imsave(‘volume.tiff',volume1)
但是这个运行起来 总是出现 volumerror:total size of new array must be unchanged
我已经被编程搞得头疼死了(哭