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 reading and writing of complex-valued data #105

Open
twitzelbos opened this issue Jun 15, 2023 · 7 comments
Open

Support reading and writing of complex-valued data #105

twitzelbos opened this issue Jun 15, 2023 · 7 comments
Assignees

Comments

@twitzelbos
Copy link
Contributor

I'm proposing (and volunteering) to add support for reading and writing of complex-valued data. I like to get buy-in here before proceeding.

@twitzelbos twitzelbos changed the title Support reading and writing of complex valued data Support reading and writing of complex-valued data Jun 15, 2023
@nilgoyette
Copy link
Collaborator

I confirm that no one else is doing it (afaik)

As you know, writing is already implemented for all standard Rust types. + RGB. This leads to code duplication which I really don't like. One of our goals was to merge write_nifti and write_rgb_nifti in order to have a single write_nifti function. As always, we forgot about it :)

I would prefer not having a write_complex_nifti function alongside two other writing functions, but I understand that playing with traits in Rust is much more complex and constrained than in C++. This being said, maybe it's super simple, maybe you simply need to add Complex to DataElement, I haven't checked.

@twitzelbos
Copy link
Contributor Author

twitzelbos commented Jun 15, 2023

Okay, to summarize:

  • create a patch that adds the ability to write complex valued and RGB data to write_nifti
  • make sure reading works the same

If that sounds good, please assign the issue to me.

@nilgoyette
Copy link
Collaborator

I wrote about RGB because I don't like the current design, but you don't have to "fix" anything. If your goal is to handle complex number, you're free to do only that :)

@twitzelbos
Copy link
Contributor Author

twitzelbos commented Jun 19, 2023

I made some progress, and I can successfully write and mostly read everything I want. A significant change I'm making is to remove safe_transmute in favor of bytemuck, which will simplify many things.

The reason is that safe_transmute and co. make use of custom traits to signal if something is safe to transmute. In Rust, you must own either the type or the trait to be allowed to implement a trait for a type, which keeps leading to dead ends. Bytemuck has sufficient adoption that many types implement its traits, getting us out of that hole.

@twitzelbos
Copy link
Contributor Author

Since this is merged, can we push a new version of the crate to crates.io, please?

@Enet4
Copy link
Owner

Enet4 commented Jul 5, 2023

Indeed, a new version is due. I will work on it when I'm able.

@Enet4
Copy link
Owner

Enet4 commented Jul 5, 2023

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants