You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would be great for this to get a more "proper" fix, but I think a simple (inefficient?) work-around for now could be something along the lines of:
functionmatread(io::IO)
# Write to a temporary file
tempfile =tempname()
write(tempfile, io)
# Read data from temporary file
data =matread(tempfile)
# Clean up temporary file and return datarm(tempfile)
return data
end
Would need a bit of work to make sure errors, etc. are handled correctly (e.g., what should be done if io is empty?).
@JeffFessler, is this something you're still looking at?
This should be doable for the old file formats (before v7.3), which are just binary files.
The new format (v7.3) is HDF5. I dont think HDF5.jl supports IOBuffer input. Reading the HDF5.API source code, you can see it calls into the libhdf5 C library. We currently use h5f_open inside MAT.jl, which uses a filepath. I'm not seeing a streaming alternative there. I also can't find information on a libhdf5 streaming options on the internet anywhere yet.
in-memory file support does seem possible: HDF5.jl In-memory-HDF5-files, so maybe we can use that? Do you really need streaming? Or can we just read the full IOBuffer into a byte vector, then turn it into an in-memory HDF5 object, and then read that with MAT.jl? Note this would also solve issue #96
Activity
dahong67 commentedon Jun 14, 2024
Would be great for this to get a more "proper" fix, but I think a simple (inefficient?) work-around for now could be something along the lines of:
Would need a bit of work to make sure errors, etc. are handled correctly (e.g., what should be done if
iois empty?).@JeffFessler, is this something you're still looking at?
JeffFessler commentedon Jun 14, 2024
I found a workaround of the form
data = matread(Downloads.download(dataurl))for my own use, e.g.,https://juliaimagerecon.github.io/Examples/generated/mri/5-l-plus-s/#Read-data
(You might be amused to see whose work is cited there.)
That does not address the OP question though, and it still (inefficiently?) uses an intermediate file.
dahong67 commentedon Jun 17, 2024
Fun! Just showed her. :)
matthijscox commentedon Apr 7, 2026
This should be doable for the old file formats (before v7.3), which are just binary files.
The new format (v7.3) is HDF5. I dont think HDF5.jl supports IOBuffer input. Reading the HDF5.API source code, you can see it calls into the
libhdf5C library. We currently useh5f_openinside MAT.jl, which uses a filepath. I'm not seeing a streaming alternative there. I also can't find information on a libhdf5 streaming options on the internet anywhere yet.in-memory file support does seem possible: HDF5.jl In-memory-HDF5-files, so maybe we can use that? Do you really need streaming? Or can we just read the full IOBuffer into a byte vector, then turn it into an in-memory HDF5 object, and then read that with MAT.jl? Note this would also solve issue #96