value=re.sub(r'[\t\n\r\f\v]*','',value.strip())#value = re.sub(r'\s*',' ',value) for some bonkers reason this inserts whitespace between all the letters! Just look for other whitespace that \s usually does.
value.strip())# value = re.sub(r'\s*',' ',value) for some bonkers reason this inserts whitespace between all the letters! Just look for other whitespace that \s usually does.
try:
value=float(value)
exceptValueError:
pass
xprot.update({name:value})
xprot.update({name:value})
returnxprot
defparse_buffer(buffer):
reASCCONV=re.compile(r'### ASCCONV BEGIN[^\n]*\n(.*)\s### ASCCONV END ###',re.DOTALL)
#print(f'buffer = {buffer[0:10]}')
#import pdb; pdb.set_trace()
reASCCONV=re.compile(r'### ASCCONV BEGIN[^\n]*\n(.*)\s### ASCCONV END ###',re.DOTALL)
#print(f'buffer = {buffer[0:10]}')
#import pdb; pdb.set_trace()
ascconv=reASCCONV.search(buffer)
#print(f'ascconv = {ascconv}')
#print(f'ascconv = {ascconv}')
ifascconvisnotNone:
prot=parse_ascconv(ascconv.group(0))
prot=parse_ascconv(ascconv.group(0))
else:
prot={}
prot=AttrDict()
xprot=reASCCONV.split(buffer)
#print(f'xprot = {xprot[0][0:10]}')
#print(f'xprot = {xprot[0][0:10]}')
ifxprotisnotNone:
xprot=''.join([foundforfoundinxprot])
prot2=parse_xprot(xprot)
prot.update(prot2)
returnprot
defread_twix_hdr(fid):
#function to read raw data header information from siemens MRI scanners
#(currently VB and VD software versions are supported and tested).
defread_twix_hdr(fid,prot):
# function to read raw data header information from siemens MRI scanners
# (currently VB and VD software versions are supported and tested).