-
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
Feature/write complex valued data #106
Feature/write complex valued data #106
Conversation
…DataRescaler trait
still need to cleanup the rescaling
This is ready for review, @nilgoyette @Enet4 |
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.
I need to open this PR in a real IDE and study what's going on. This might take several days, depending on what comes up at my job.
Still, I left you some comments.
Would you like me to change/add test cases, or is this enough for now? In principle, we could make tests where we write matrices of random content, read them back, and compare, but I feel the bitwise comparison to independently generated files is a better test. @nilgoyette @Enet4 |
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! I did a very quick code review for now. It seems mostly fine by me, and if there are no further objections other than the comments I made inline, I would guess that it's ready.
I also appreciate the effort and example of migrating the code to bytemuck
from safe_transmute
. Historically it made sense for me to use the crate I helped conceive myself, but nowadays it is considered safer to rely on what is considered the state-of-the-art crate for safe reinterpretation of bytes. This also means we have one more public dependency considered stable, which will help to stabilize this crate as well!
In principle, we could make tests where we write matrices of random content, read them back, and compare, but I feel the bitwise comparison to independently generated files is a better test.
Indeed, for these things I prefer to keep as many tests as fully deterministic as possible, so keeping a set of static curated test resources is a sufficiently good approach.
|
||
/// A vessel to host the NiftiDataRescaler trait | ||
#[derive(Debug)] | ||
pub struct DataRescaler; |
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.
There are lots of changes in this module. It makes me wonder if we could just keep all (or most) of it all private or pub(crate)
. But I guess this can be evaluated later.
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.
This did also occur to me, but presently this also leaks out to the public, so it cannot even be pub(crate). Presently many of the difficulties arise in the RandomAccess functionality, which I have never used, and haven't had the time to investigate yet. We are using this crate solely for the reading and writing of nifti files in rust (quite successfully I must say).
LGTM. Thank you for your work! |
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.
Yup, I think we are ready to move forward here? Thanks!
Okay, here it goes:
reads and writes RGB, RGBA, Complex64 and Complex128 now
the new (additional) tests write RGB and RGBA using write_nifti
I left the old write_rgb_nifti in place, but it can be removed
I made a bit of a mess replacing LinearTransform with NiftiDataRescaler (I did not like the name LinearTransform), resulting in more code, but could clean this up more.
For reading there is a function into_nifti_typed_data() now, which provides a vec of the native type, for when an ndarray is not needed/wanted
resolves issue Support reading and writing of complex-valued data #105