Skip to content
Snippets Groups Projects
Commit 8af42928 authored by ferrari's avatar ferrari
Browse files

Added current number of files done

parent c666607c
Branches
No related tags found
No related merge requests found
......@@ -15,12 +15,14 @@ class BetterIter(object):
self.max_num = len(to_wrap)
self.to_wrap = to_wrap
self.overlap = False
self.curr_len = None
def __iter__(self):
return self
def _test_done(self, list_pass):
self.overlap = len(list_pass) >= self.max_num
self.curr_len = len(list_pass)
self.overlap = self.curr_len >= self.max_num
def __next__(self):
while True:
......@@ -39,7 +41,7 @@ class BetterIter(object):
return val
def _next_file(event, refs, order, df, save, args, outpath, done_file):
def _next_file(event, refs, order, df, save, args, outpath, done_file, text):
tmp = pd.DataFrame.from_dict(refs['callback'].df, orient='index')
ind = order.current
tmp['file'] = df.iloc[ind].filepredmax
......@@ -57,9 +59,10 @@ def _next_file(event, refs, order, df, save, args, outpath, done_file):
try:
ipi.reset(refs['callback'], os.path.join(args.wd, df.iloc[ind].filepredmax.strip('/')), args.channel)
refs['fig'].canvas.set_window_title('IPI of ' + df.iloc[ind].filepredmax.rsplit('/', 1)[-1])
text.set_text('{order.curr_len} files done')
except (RuntimeError,FileNotFoundError) as e:
print(e, 'Opening next file')
_next_file(event, refs, order, df, save, args, outpath, done_file)
_next_file(event, refs, order, df, save, args, outpath, done_file, text)
......@@ -94,8 +97,11 @@ def main(args):
print(e, 'Opening next file')
ind = samples_order.__next__()
ref_dict = ipi.init(os.path.join(args.wd, df.iloc[ind].filepredmax.strip('/')), args.channel)
text_ax = plt.subplot(ref_dict['gridspec'][-1, -4:-2])
text = text_ax.text(0.5, 0.5, f'{len(file_list)} files done', horizontalalignment='center',
verticalalignment='center', transform=text_ax.transAxes)
next_file = partial(_next_file, refs=ref_dict, order=samples_order, df=df, save=save, args=args, outpath=outpath,
done_file=done_file)
done_file=done_file, text=text)
next_ax = plt.subplot(ref_dict['gridspec'][-1, -2:])
next_button = Button(next_ax, 'Next file')
next_button.on_clicked(next_file)
......
......@@ -402,7 +402,7 @@ class Callback(object):
def play(self, event):
sound = (norm(self.song_resample[self.p:self.p+FSSR*20])*(2**15-1)).astype(np.int16)
try:
play(AudioSegment(sound.tobytes(), frame_rate=self.sr, sample_width=sound.dtype.itemsize, channels=1))
play(AudioSegment(sound.tobytes(), frame_rate=FSSR, sample_width=sound.dtype.itemsize, channels=1))
except KeyboardInterrupt:
pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment