Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom field map to override default field types #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions nrrd/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@


def _get_field_type(field: str, custom_field_map: Optional[NRRDFieldMap]) -> NRRDFieldType:
if field in ['dimension', 'lineskip', 'line skip', 'byteskip', 'byte skip', 'space dimension']:
if custom_field_map and field in custom_field_map:
return custom_field_map[field]
elif field in ['dimension', 'lineskip', 'line skip', 'byteskip', 'byte skip', 'space dimension']:
return 'int'
elif field in ['min', 'max', 'oldmin', 'old min', 'oldmax', 'old max']:
return 'double'
Expand All @@ -111,9 +113,6 @@ def _get_field_type(field: str, custom_field_map: Optional[NRRDFieldMap]) -> NRR
elif field in ['space directions']:
return 'double matrix'
else:
if custom_field_map and field in custom_field_map:
return custom_field_map[field]

# Default the type to string if unknown type
return 'string'

Expand Down