Commit 7f10fc5a authored by Mo Shahdloo's avatar Mo Shahdloo
Browse files

fancy progressbar

parent 69a21c32
......@@ -65,8 +65,10 @@ def loop_mdh_read(fid, version, Nscans, scan, measOffset, measLength, print_prog
dmaOff = 0
dmaSkip = byteMDH
t = tqdm(total=np.float(str('%8.1f' % (measLength / 1024 ** 2))),
desc='Scan %d/%d, read all mdhs' % (scan + 1, Nscans), leave=True)
if print_prog:
last_progress = 0
t = tqdm(total=measLength, unit='B', unit_scale=True, unit_divisor=1024,
desc='Scan %d/%d, read all mdhs' % (scan + 1, Nscans), leave=True)
while True:
# Read mdh as binary (uint8) and evaluate as little as possible to know...
# ... where the next mdh is (ulDMALength / ushSamplesInScan & ushUsedChannels)
......@@ -141,12 +143,14 @@ def loop_mdh_read(fid, version, Nscans, scan, measOffset, measLength, print_prog
mdh_blob[:, n_acq - 1] = data_u8
filePos[n_acq - 1] = cPos
t.update(np.float(str('%8.1f' % (cPos / 1024 ** 2))))
if print_prog:
curr_progress = cPos
progress = curr_progress - last_progress
t.update(progress)
last_progress = curr_progress
cPos = cPos + ulDMALength
t.close()
if isEOF or n_acq == len(filePos):
n_acq = n_acq - 1 # ignore the last attempt
# import pdb; pdb.set_trace()
......
......@@ -12,7 +12,7 @@ class twix_map_obj:
@property
def filename(self):
return self.fname
@property
def rampSampTrj(self):
return self.rstrj
......@@ -20,7 +20,7 @@ class twix_map_obj:
@property
def dataType(self):
return self.dType
@property
def fullSize(self):
if self.full_size is None:
......@@ -30,7 +30,7 @@ class twix_map_obj:
# @fullSize.setter
# def fullSize(self, val):
# self.full_size = val
@property
def dataSize(self):
out = self.fullSize.copy()
......@@ -163,7 +163,6 @@ class twix_map_obj:
def RawDataCorrectionFactors(self, bval):
pass
def __init__(self, dataType, fname, version, rstraj=None, **kwargs):
self.ignoreROoffcenter = kwargs.get('ignoreROoffcenter', False)
self.removeOS = kwargs.get('removeOS', True)
......@@ -673,9 +672,9 @@ class twix_map_obj:
mem = mem.astype(int)
if outSize is None:
if selRange is None:
selRange = [slice(None,None,None),slice(None,None,None)]
#[np.arange(0, self.dataSize[0]).astype(int), np.arange(0, self.dataSize[1]).astype(int)]
# [slice(None,None,None),slice(None,None,None)]
selRange = [slice(None, None, None), slice(None, None, None)]
# [np.arange(0, self.dataSize[0]).astype(int), np.arange(0, self.dataSize[1]).astype(int)]
# [slice(None,None,None),slice(None,None,None)]
else:
selRange[0] = np.arange(self.dataSize[0]).astype(int) # slice(None,None,None)
selRange[1] = np.arange(self.dataSize[0]).astype(int) # slice(None,None,None)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment