-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrunme.py
More file actions
84 lines (69 loc) · 2.92 KB
/
Copy pathrunme.py
File metadata and controls
84 lines (69 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""Read data from the selected folder
This script will load and display Clarius supported file types.
Note: code is tested on mac, for other operating systems you may need to
use (\) instead of (/) for relative path.
Author: Reza Zahiri
"""
import numpy as np
from scipy.signal import hilbert
import matplotlib.pyplot as plt
import sys
libPath = "../../common/python"
if not libPath in sys.path: sys.path.append(libPath)
import rdataread as rd
if __name__ == '__main__':
# read rf data
path = "../data/wirephantom/"
filename = "phantom_rf.raw"
hdr, timestamps, data = rd.read_rf(path + filename)
numframes = 1 #hdr['frames']
# covnert to B
bdata = np.zeros((hdr['lines'], hdr['samples'], hdr['frames']), dtype='float')
for frame in range(numframes):
bdata[:,:,frame] = 20 * np.log10( np.abs(1 + hilbert(data[:,:,frame])) )
# display images
for frame in range(numframes):
plt.figure(figsize=(10,5))
plt.subplot(1,2,1)
plt.imshow(np.transpose(data[:,:,frame]), cmap=plt.cm.plasma, aspect='auto', vmin=-1000, vmax=1000 )
plt.title('RF frame ' + str(frame))
plt.subplot(1,2,2)
plt.imshow(np.transpose(bdata[:,:,frame]), cmap=plt.cm.gray, aspect='auto', vmin=15, vmax=70 )
plt.title('sample B frame ' + str(frame))
plt.show()
# read iq data
path = "../data/wirephantom/"
filename = "phantom_iq.raw"
hdr, timestamps, data = rd.read_iq(path + filename)
# separating i and q data
idata = data[:,0::2,:]
qdata = data[:,1::2,:]
# covnert IQ to B
numframes = 1 #hdr['frames']
bdata = np.zeros((hdr['lines'], hdr['samples'], hdr['frames']), dtype='float')
for frame in range(numframes):
bdata[:,:,frame] = 10 * np.log10(1 + np.power(idata[:,:,frame], 2) + np.power( qdata[:,:,frame], 2) )
# display images
for frame in range(numframes):
plt.figure(figsize=(15,5))
plt.subplot(1,3,1)
plt.imshow(np.transpose(idata[:,:,frame]), cmap=plt.cm.viridis, aspect='auto', vmin=-100, vmax=100 )
plt.title('I frame ' + str(frame))
plt.subplot(1,3,2)
plt.imshow(np.transpose(qdata[:,:,frame]), cmap=plt.cm.viridis, aspect='auto', vmin=-100, vmax=100 )
plt.title('Q frame ' + str(frame))
plt.subplot(1,3,3)
plt.imshow(np.transpose(bdata[:,:,frame]), cmap=plt.cm.gray, aspect='auto', vmin=15, vmax=70 )
plt.title('sample B frame ' + str(frame))
plt.show()
# read b/envelope data
path = "../data/wirephantom/"
filename = "phantom_env.raw"
hdr, timestamps, data = rd.read_env(path + filename)
# display b data
numframes = 1 #hdr['frames']
for frame in range(numframes):
plt.figure(figsize=(5,5))
plt.imshow(np.transpose(data[:,:,frame]), cmap=plt.cm.gray, aspect='auto', vmin=0, vmax=255 )
plt.title('envelope frame ' + str(frame))
plt.show()