MagneticResonanceImaging / MRIReco.jl

Julia Package for MRI Reconstruction
https://magneticresonanceimaging.github.io/MRIReco.jl/latest/
Other
85 stars 22 forks source link

MRIFiles: Fixing `save` of `ISMRMRDFile`'s in Julia 1.11 and 1.12 #197

Closed cncastillo closed 1 month ago

cncastillo commented 2 months ago

The write(IO, ...) function used in writeProfiles now uses the new Memory type that behaves a little differently. From Julia 1.11 changelogs:

New Memory type that provides a lower-level container as an alternative to Array. Memory has less overhead and a faster constructor, making it a good choice for situations that do not need all the features of Array (e.g. multiple dimensions). Most of the Array type is now implemented in Julia on top of Memory, leading to significant speedups for several functions (e.g. push!) as well as more maintainable code (#51319).

The fallback method write(::IO, ::AbstractArray) used to recursively call write on each element, but now writes the in-memory representation of each value. For example, write(io, 'a':'b') now writes 4 bytes for each character, instead of writing the UTF-8 representation of each character. The new format is compatible with that used by Array, making it possible to use read! to get the data back (#42593).

In this PR, I added a sizehint argument to the IOBuffer (that was also available pre-Julia 1.11), as without it, the write function was adding extra bytes of random information when the added data surpassed the current Memory capacity in iobuf.data.

Fixes #194

cncastillo commented 1 month ago

Hi @tknopp, sorry to tag you but I couldn't choose any reviewers. I believe this one to be a small but necessary patch.

No other changes have been made to MRIFiles since v0.3.1 (https://github.com/MagneticResonanceImaging/MRIReco.jl/commit/dee7b36f74de86b5220d25e1afc2ed897e2368c5).

The CI problems seem to be unrelated to this PR

  MethodError: no method matching proxTV!(::Vector{ComplexF32}, ::Float64, ::Tuple{Int64, Int64}, ::UnitRange{Int64}; iterationsTV::Int64)

Cheers!

tknopp commented 1 month ago

Thanks!