You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are there examples of how to extract ascconv from a pydicom or dicomwrapper object?
wrapper= nibabel.nicom.dicomwrappers.wrapper_from_file('path/to/dicom')
csa = nibabel.nicom.csareader.get_csa_header(wrapper.dcm_data, 'series')
mrprot= csa['tags']['MrPhoenixProtocol']['items'][0]
asc=nibabel.nicom.ascconv.parse_ascconv(mrprot, '""') #
--> 207 attrs, content = ASCCONV_RE.match(ascconv_str).groups()
208 attrs = OrderedDict(tuple(x.split('=')) for x in attrs.split())
209 # Normalize string start / end markers to something Python understands
AttributeError: 'NoneType' object has no attribute 'groups'
## hacking a bit for the regex to be smarter
nibabel.nicom.ascconv.ASCCONV_RE = re.compile(
r'.*### ASCCONV BEGIN((?:\s*[^=\s]+=[^=\s]+)*) ###\n(.*?)\n### ASCCONV END ###.*',
flags=re.M | re.S,
)
asc=nibabel.nicom.ascconv.parse_ascconv(mrprot, '""') #have to use double quote, as it seems to be the format when extracting the MrPhoenixProtocol the way above.
Cell In[100], line 1
asc=nibabel.nicom.ascconv.parse_ascconv(mrprot, '""')
File ~/.virtualenvs/neuromod_data3.10/lib/python3.10/site-packages/nibabel/nicom/ascconv.py:212 in parse_ascconv
tree = ast.parse(content)
File /usr/lib/python3.10/ast.py:50 in parse
return compile(source, filename, mode, flags,
File <unknown>:1261
sDiffusion.sFreeDiffusionData.sComment.0 = 0x55 # 'U'
^
SyntaxError: invalid syntax
Maybe ASCCONV format "evolved" and ast is no longer able to parse it when it contains new tag formats.
The text was updated successfully, but these errors were encountered:
Sorry for the late reply, and thanks for the pointer to that package.
I tested it and it worked without issue, and the parsed structure is really great.
Is the plan for nibabel to use that package in the near future to deprecate and replace the nibabel CSA parsers?
I believe that was the original idea. For now I created a branch of dcmstack that uses csa_header for parsing meta data to help test it out on more data: moloney/dcmstack#96
Are there examples of how to extract ascconv from a pydicom or dicomwrapper object?
Maybe ASCCONV format "evolved" and
ast
is no longer able to parse it when it contains new tag formats.The text was updated successfully, but these errors were encountered: