Skip to content

Commit

Permalink
chore: improve progressbars
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwnvol committed Jul 4, 2024
1 parent 2324aa0 commit 5f910e3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions commit/trk2dictionary/trk2dictionary.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ cpdef cat_function( infilename, outfilename ):
cpdef compute_tdi( np.uint32_t[::1] v, np.float32_t[::1] l, int nx, int ny, int nz, int verbose):
cdef np.float32_t [::1] tdi = np.zeros( nx*ny*nz, dtype=np.float32 )
cdef unsigned long long i=0
with ProgressBar(total=v.size, disable=(verbose in [0, 1, 3]), hide_on_exit=True) as pbar:
with ProgressBar(total=v.size, disable=verbose<3, hide_on_exit=True) as pbar:

for i in range(v.size):
tdi[ v[i] ] += l[i]
Expand Down Expand Up @@ -322,14 +322,15 @@ cpdef run( filename_tractogram=None, path_out=None, filename_peaks=None, filenam
hdr = nibabel.streamlines.load( filename_tractogram, lazy_load=True ).header
temp_idx = np.arange(int(hdr['count']))
log_list = []
subinfo = logger.subinfo(f'Clustering with threshold = {blur_clust_thr[0]}', indent_lvl=2, indent_char='-', with_progress=verbose>2)
with ProgressBar(disable=verbose<3, hide_on_exit=True, subinfo=subinfo, log_list=log_list) as pbar:
ret_subinfo = logger.subinfo(f'Clustering with threshold = {blur_clust_thr[0]}', indent_lvl=2, indent_char='-', with_progress=verbose>2)
with ProgressBar(disable=verbose<3, hide_on_exit=True, subinfo=ret_subinfo, log_list=log_list):
idx_centroids = run_clustering(tractogram_in=filename_tractogram, tractogram_out=filename_out,
temp_folder=path_temp, atlas=blur_clust_groupby, clust_thr=blur_clust_thr[0],
n_threads=n_threads, keep_temp_files=True, force=True, verbose=1, log_list=log_list)
else:
logger.subinfo(f'Clustering with threshold = {blur_clust_thr[0]}', indent_lvl=2, indent_char='-', with_progress=verbose>2)
with ProgressBar(disable=verbose<3, hide_on_exit=True, subinfo=True) as pbar:
log_list = []
ret_subinfo = logger.subinfo(f'Clustering with threshold = {blur_clust_thr[0]}', indent_lvl=2, indent_char='-', with_progress=verbose>2)
with ProgressBar(disable=verbose<3, hide_on_exit=True, subinfo=ret_subinfo, log_list=log_list):
idx_centroids = run_clustering(tractogram_in=filename_tractogram, tractogram_out=filename_out,
temp_folder=path_temp, clust_thr=blur_clust_thr[0],
keep_temp_files=True, force=True, verbose=1)
Expand Down

0 comments on commit 5f910e3

Please sign in to comment.