-
Notifications
You must be signed in to change notification settings - Fork 12
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
Writer options #75
Writer options #75
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this. Here is my first review, I might look into more of it and extend the review later.
I feel that the path update is "unclean". Maybe we should calculate the final path only in the write functions?
That might indeed be better, so as to reduce the number of unnecessary mutations.
We can constrain the other setter methods to simple validation (most of which is already done by the type system).
I wanted to add an option to set a reference path, in case the user doesn't want to load the header himself and simply give us the path to the header, but we would lose the [faster] reference: Option<&'a NiftiHeader>. If we don't care about copying this struct and we love this feature, I can do it. It would also remove the lifetime, which some people may like :)
I am a bit intrigued to see how that would look like. Maybe an additional enum layer would be the best way of representing the three possible combinations (no header, let the program infer everything; reference to in-memory header; path to header file).
Sorry, I totally forgot about this review! I'm on a 5 weeks vacation (only 3 left) because I'm a dad now :) As you can guess, I'm not much into programming right now. I'll probably return to this review when I'm back to work in october. |
No worries, take your time! And congratulations! |
I tried to code the "reference from file" idea.
Do you know how to make this cleaner? Or do we simply forget about this idea? |
#[derive(Debug, Clone, PartialEq)]
enum Reference<'a> {
None,
FromHeader(&'a NiftiHeader),
FromFile(PathBuf), // I don't think it's possible to use &'a Path here
} I don't see the problem in using Other than this, the logic for turning this |
Oh, I always write |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, these are good to go! Thank you for your patience and for keeping up with this.
Here's a first draft of
WriterOptions
. I don't see anything particularly horrible or insulting to a programmer :) Maybeheader_file: bool
is not a super name. Does nifti have a name for the distinct files (nii vs hdr+img)?write
functions?reference: Option<&'a NiftiHeader>
. If we don't care about copying this struct and we love this feature, I can do it. It would also remove the lifetime, which some people may like :)I still don't understand how I can write a single function for "normal" and rgb image. I see that they now share some common parameters, but we still have the problem with the traits.
[u8; 3]
must respectDataElement
andTriviallyTransmutable
. Because of this, I kept thewrite_nifti
andwrite_rgb_nifti
functions (now transformed to methods).Fix #49 and maybe some other stuff.