Enet4 / nifti-rs

Rust implementation of the NIfTI-1 format
Apache License 2.0
40 stars 11 forks source link

InMemNiftiVolume::from_raw_data #16

Closed nilgoyette closed 5 years ago

nilgoyette commented 5 years ago

Usage would look like:

let mut header = obj.header().clone();
let mut volume = obj.into_volume();
// modify something in header, like dim, or modify raw_data, but it's a bad idea!
volume = InMemNiftiVolume::from_raw_data(&header, volume.to_raw_data()).unwrap();

I did what I did because I only have a single use-case to consider. I'm not too sure about:

  1. receiving a header. It seemed better than asking for dim, datatype, scl_slope, scl_inter and endianness, but it forces the programmer to create a header. I don't think it's a problem because it's easy to create one with default and the .. syntax.
  2. returning a Result. I don't like it, but I don't like asking for a datatype either.

I added a test for my "false 4D image" that I didn't push because I don't know if you want to have more toy images in your lib.