Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions PyHum/_pyhum_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ def read(humfile, sonpath, cs2cs_args, c, draft, doplot, t, bedpick, flip_lr, mo
if 2>1:
if bedpick == 1: # auto

print('Auto bed picking...')
x, bed = humutils.auto_bedpick(ft, dep_m, chunkmode, port_fp, c)

if len(dist_m)<len(bed):
Expand All @@ -700,6 +701,7 @@ def read(humfile, sonpath, cs2cs_args, c, draft, doplot, t, bedpick, flip_lr, mo

elif bedpick>1: # user prompt

print('Auto bed picking...')
x, bed = humutils.auto_bedpick(ft, dep_m, chunkmode, port_fp, c)

if len(dist_m)<len(bed):
Expand All @@ -712,25 +714,29 @@ def read(humfile, sonpath, cs2cs_args, c, draft, doplot, t, bedpick, flip_lr, mo
# manually intervene
fig = plt.figure()
ax = plt.gca()
print('Setting up bed picking figure...')
if chunkmode !=4:
im = ax.imshow(np.hstack(port_fp), cmap = 'gray', origin = 'upper')
else:
im = ax.imshow(port_fp, cmap = 'gray', origin = 'upper')
plt.plot(bed,'r')
plt.axis('normal'); plt.axis('tight')

pts1 = plt.ginput(n=300, timeout=30) # it will wait for 200 clicks or 60 seconds
raw_input("Bed picking - are you ready? Press Enter to continue...")
print('Use the left mouse button to pick, right to delete, and center to end picking.')

pts1 = plt.ginput(n=300, timeout=-1) # it will wait for 300 clicks or the window to close (center mouse button)
x1=map(lambda x: x[0],pts1) # map applies the function passed as
y1=map(lambda x: x[1],pts1) # first parameter to each element of pts
plt.close()
del fig

if x1 != []: # if x1 is not empty
tree = KDTree(zip(np.arange(1,len(bed)), bed))
tree = KDTree(np.asarray(zip(np.arange(1,len(bed)), bed)))
try:
dist, inds = tree.query(zip(x1, y1), k = 100, eps=5, n_jobs=-1)
dist, inds = tree.query(np.asarray(zip(x1, y1)), k = 100, eps=5, n_jobs=-1)
except:
dist, inds = tree.query(zip(x1, y1), k = 100, eps=5)
dist, inds = tree.query(np.asarray(zip(x1, y1)), k = 100, eps=5)

b = np.interp(inds,x1,y1)
bed2 = bed.copy()
Expand All @@ -750,27 +756,37 @@ def read(humfile, sonpath, cs2cs_args, c, draft, doplot, t, bedpick, flip_lr, mo

if chunkmode!=4:
for k in range(len(port_fp)):
raw_input("Bed picking "+str(k+1)+" of "+str(len(port_fp))+", are you ready? 30 seconds. Press Enter to continue...")

bed={}
fig = plt.figure()
ax = plt.gca()
im = ax.imshow(port_fp[k], cmap = 'gray', origin = 'upper')
pts1 = plt.ginput(n=300, timeout=30) # it will wait for 200 clicks or 60 seconds

raw_input("Bed picking "+str(k+1)+" of "+str(len(port_fp))+", are you ready? Press Enter to continue...")
print('Use the left mouse button to pick, right to delete, and center to end picking.')

pts1 = plt.ginput(n=300, timeout=-1) # it will wait for 300 clicks or the window to close (center mouse button)
x1=map(lambda x: x[0],pts1) # map applies the function passed as
y1=map(lambda x: x[1],pts1) # first parameter to each element of pts
bed = np.interp(np.r_[:ind_port[-1]],x1,y1)
plt.close()
del fig
beds.append(bed)
extent = np.shape(port_fp[k])[0]

bed = np.asarray(np.hstack(beds),'float')

else:
raw_input("Bed picking - are you ready? 30 seconds. Press Enter to continue...")

bed={}
fig = plt.figure()
ax = plt.gca()
im = ax.imshow(port_fp, cmap = 'gray', origin = 'upper')
pts1 = plt.ginput(n=300, timeout=30) # it will wait for 200 clicks or 60 seconds

raw_input("Bed picking - are you ready? Press Enter to continue...")
print('Use the left mouse button to pick, right to delete, and center to end picking.')

pts1 = plt.ginput(n=300, timeout=-1) # it will wait for 300 clicks or the window to close (center mouse button)
x1=map(lambda x: x[0],pts1) # map applies the function passed as
y1=map(lambda x: x[1],pts1) # first parameter to each element of pts
bed = np.interp(np.r_[:ind_port[-1]],x1,y1)
Expand Down