Skip to content

Generalize (deprecate?) get_xyzt_units #1116

Open
@effigies

Description

@effigies

Nifti1Header.get_xyzt_units is entirely based on the bitfield as it is implemented in nifti1.h. Attempting to generalize it to Minc (#1098) requires reducing the available information, specifically raising a ValueError if the spatial axes have different units.

I think it makes sense to keep this interface which will be mostly useful, but we could start by generalizing, e.g.,

class HasUnits:
    def get_units(self)
        ...

And keep the old behavior:

    def get_xyzt_units(self):
        all_units = self.get_units()
        spatial_units = ...
        temporal_units = ...
        if len(set(spatial_units)) > 1:
            raise ValueError
        if len(set(temporal_units)) > 1:
            raise ValueError
        return spatial_units[0], temporal_units[0]

OTOH, maybe with get_units(), get_xyzt_units() is redundant and can be deprecated.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions