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

Support NIFTI-2, resolves #89 #90

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/affine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ where
///
/// We get the translations from the center of the image (implied by `shape`).
#[rustfmt::skip]
pub(crate) fn shape_zoom_affine(shape: &[u16], spacing: &[f32]) -> Matrix4<f64> {
pub(crate) fn shape_zoom_affine(shape: &[u64], spacing: &[f64]) -> Matrix4<f64> {
// Get translations from center of image
let origin = Vector3::new(
(shape[0] as f64 - 1.0) / 2.0,
Expand Down
16 changes: 13 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ quick_error! {
/// The field `dim` is in an invalid state, as a consequence of
/// `dim[0]` or one of the elements in `1..dim[0] + 1` not being
/// positive.
InconsistentDim(index: u8, value: u16) {
InconsistentDim(index: u8, value: u64) {
display("Inconsistent value `{}` in header field dim[{}] ({})", value, index, match index {
0 if *value > 7 => "must not be higher than 7",
_ => "must be positive"
})
}
/// Attempted to read volume outside boundaries.
OutOfBounds(coords: Vec<u16>) {
OutOfBounds(coords: Vec<u64>) {
display("Out of bounds access to volume: {:?}", &coords[..])
}
/// Attempted to read a volume over a volume's unexistent dimension.
Expand Down Expand Up @@ -69,9 +69,19 @@ quick_error! {
display("Description length ({} bytes) is greater than 80 bytes.", len)
}
/// Header contains a code which is not valid for the given attribute
InvalidCode(typename: &'static str, code: i16) {
InvalidCode(typename: &'static str, code: i32) {
display("invalid code `{}` for header field {}", code, typename)
}
/// Integer field size is not large enough to hold assigned value
FieldSize(err: std::num::TryFromIntError) {
from()
source(err)
}
/// Invalid header size. Header size must be 540 for NIfTI-2 or 348 for
/// NIfTI-1.
InvalidHeaderSize(sizeof_hdr: i32) {
display("Invalid header size {} must eb 540 for NIfTI-2 or 348 for NIfTI-1.", sizeof_hdr)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
display("Invalid header size {} must eb 540 for NIfTI-2 or 348 for NIfTI-1.", sizeof_hdr)
display("Invalid header size {}: must be 540 for NIfTI-2 or 348 for NIfTI-1.", sizeof_hdr)

}
}
}

Expand Down
Loading