-
Notifications
You must be signed in to change notification settings - Fork 11
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
Make native endianness always the default in NiftiHeader
#40
Conversation
edf1058
to
7c2e408
Compare
- necessary for the byte-by-byte check
@nilgoyette If I want to write an ndarray to nifti with a specific endianness, I have to create a header with a few other properties well defined, or it will not behave exactly as if no header was provided. let header = NiftiHeader {
datatype: NiftiType::Rgb24 as i16,
pixdim: [1.0; 8],
sform_code: 2,
srow_x: [1.0, 0.0, 0.0, 0.0],
srow_y: [0.0, 1.0, 0.0, 0.0],
srow_z: [0.0, 0.0, 1.0, 0.0],
endianness: Endianness::Little,
.. NiftiHeader::default()
};
write_rgb_nifti(&header_path, &data, Some(&header))?; Should we be worried about this inconsistency? Would it be reasonable for some (or all) of these properties to be the default in |
I was displeased to have to specify "so much" fields when I create my reference header in
Not totally related to what you ask, but some values should be irrelevant, in the sense that we should always overwrite them when writing, wathever the value.
With all this, I think the header creation will be simpler for the users. |
I am certainly not opposed to these two, it does seem to be more reasonable than suggesting voxels with zero volume, or a transformation that would just collapse all points in space to the Euclidean 0. We can do this in a separate PR.
This is indeed a part where additional expertise would be beneficial. To be honest, I never really needed to manipulate these two properties. I might do some extra research on this once I'm free from my current tight deadlines.
This PR actually proposes that this is changed to the system's default endianness. The current problem that really should be fixed is that the
Right, we can document that volume writing functions may choose to disregard these properties, especially when they are incompatible with the intended operation. |
Haha, yes, sorry, I forgot where I was :) I agree with your choice. "Faster on the same machine" make sense. My colleagues think alike. You can merge this. I'm asking another colleague, which we can call an expert on the subject, about |
Just making it so that
NiftiHeader::default()
providesa header with the system's native byte order.
This makes the behaviour consistent with the header builder
(which was already defaulting to
Endianness::native()
)and favours performance when handling files in the same
machine.