Skip to content

Conversation

matthew-brett
Copy link
Member

Split Analyze header object into WrapStruct - a general structured array carrying object, and the AnalyzeHeader, which extends WrapStruct by adding header-like and Analyze specific attributes.

This should make it easier for @cindeem to use in ecat.py - if you like...

Preparing for your actual binary header class, and it's own test_binary
testing code.

Move analyze-specific tests into test_analyze
Adapt testing of other headers to use self.log_chk (renamed from
_log_chk)
Split the Analyze header into a WrapStruct class, that wraps a
structured array, and the features specific to the Analyze header,
including general get_data_dtype etc.
@mih
Copy link
Member

mih commented Sep 14, 2011

That looks like it is also useful to add support for NIfTI2, right?

@matthew-brett
Copy link
Member Author

Well - I'm hoping that Nifti2 could be as simple as subclassing Nift1Image and Nifti1PairImage and subclassing nifti1header changing the dtype definition, and probably a few of the checks (the magic has changed?) and the empty_header (for the magic again?).

Trying to make the wrapstruct more independent of the header idea, in
the docs
The name more clearly expresses the meaning; it also matches the public
property ``structarr``
The name more clearly expresses what the method is for.  The method is
common enough that it seems reasonable to promote it to be part of the
public API.
Separating WrapStructs from headers at a conceptual level.  Subclasses
such as Analyze raise HeaderDataErrors if they want them trapped by
their own error machinery, but wrapstructs raise their own errors
internally.  In fact, the only time this happens at the moment is
checking the size of the binary block passed in.
I was using an int32, that numpy doctests show as e.g  ``array(3)`` on
32-bit systems, but ``array(3, dtype=int32)`` on 64 bit systems.
Changing to int16 means the dtype always appears in the output.
It makes more sense for this method not to require an instance.
Guessed endian needs to be written for each substantial subclass, so it
should be part of the API.  It makes more sense as a classmethod because
we should not need an instance to test other data for endianness.
We use cls._dtype in various places; it should be part of the public
API.
The field_recoders is a bit specific to headers; move to the header
classes, leave wrapstruct with generic stub interface to get_value_label
It was previously raising AttributeErrors trying to find the parts to
compare.
@matthew-brett
Copy link
Member Author

Any more comments on this one?

@cindeem
Copy link

cindeem commented Sep 22, 2011

thanks for the 32/64 bit fix..
and like the move of _dtype to public method

looks good

@matthew-brett
Copy link
Member Author

Thanks for the reviews guys - merging.

matthew-brett added a commit that referenced this pull request Sep 23, 2011
Abstract handling of binary structures into WrapStruct class
@matthew-brett matthew-brett merged commit 058af58 into nipy:master Sep 23, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants