[Matrix-SIG] Reading binary data from file into NumPy arrays: numpyio
Travis E. Oliphant
Thu, 18 Jun 1998 03:01:33 -0500
I needed a relatively low-level method to load arbitrary binary data
into NumPy arrays, so I wrote C-extension code to do it after learning
a little about the NumPy API through the source code.
I've called the module numpyio and it allows reading and writing
aribrary data-types to an open file stream. There are options to do
byte-swapping as well as type-casting on read-in.
There is also a packbits and unpackbits function as part of the module
to read and write binary-valued data (each element is only 0 or 1).
This module has come in handy as I've used it to create another module
(written in Python) to read and write Analyze-format medical imaging
volumes into Python for data analysis.
If anyone is interested in my source code, let me know and I will send
it to you or let me know where to put it.