Open yeruoforever opened 3 years ago
You can try with
header = niread(fn; mmap=true).header
This opens the data as a memory mapped file, only reading the array from disk, when you actually access it. You can also open larger files than your memory with that. But I'm not sure if it works with compressed files.
Thanks for your reply, and I tried it.It does not work on gzip files.It throws an error at this line.
if mmap
if header_gzipped
close(header_io)
close(file_io)
error("cannot mmap a gzipped NIfTI file")
We need to separate some of the processes here and have something like niload(f::AbstractString) -> IOMeta
and read(::IOMeta) -> AbstractArray
. It will take a little reworking because the whole I/O routine is pretty inflexible at the moment.
I am currently analyzing a lung CT data set. A simple task is to obtain the pixel spacing of the image for statistics. When I use niread(), I have to wait for an entire image array to be read from the disk, but The current work only needs to read the header information instead of a complete image array (NIVolume.raw), which seems to take a lot of unnecessary time, especially when this data set contains a lot of cases. A compromise solution is to implement a simple nihread() to read header information. But a better solution is to read only the header information when calling niread(), and only when NIVolume.raw is used the actual array would load from the hard disk into the memory.