0

I need to read a 16-bit unsigned integer big endian binary file in Python. Here's some information that may be relevant:

  • No. of Dimensions: 3
  • Dimension Size: 64 x 384 x 384
  • Max Dimension Size: 64 x 384 x 384
  • Data type: 16-bit unsigned integer
  • Storage Layout: CHUNKED 32 x 128 x 128
  • Compression: 2.526:1 GZIP: level=2
  • Storage: SIZE: 742159, allocation time: Incremental
  • Fill value: NONE

The file itself is supposed to be a 3-dimensional image of a brain. I exported the file from an IMS file using HDFView. I want to convert the file to a numpy array. The file extension is ".bin".

Supplementary Information:

Picture of HDFView, a tool used to export the data in question from an IMS file

HDFViewer

Link to a description of the IMS file-type

https://imaris.oxinst.com/support/imaris-file-format

Link to the machine used to make the IMS file

https://www.zeiss.com/microscopy/en/products/light-microscopes/light-sheet-microscopes/lightsheet-7.html

Data:

Google drive link to the data

https://drive.google.com/file/d/1wo4iSBLvNu51qYPTyUpGdKgdwJUG0eed/view?usp=sharing

halfer
  • 19,824
  • 17
  • 99
  • 186
  • It would be helpful if you shared the name of the imaging device and a link to it. Also, if you could share a Dropbox or Google Drive link to the binary file that would help. – Mark Setchell Oct 12 '22 at 00:22
  • Okay, I'll do this – Captain Ahab Oct 12 '22 at 00:43
  • Mmmm... I know nothing about hdf5 stuff, so may be wrong, but ... the expected size of your file would be `64x384x384x2` bytes if uint16. The screen capture says it has been gzipped to 7472159 bytes at a ratio of 2.526 and the maths is correct. I'm now stuck because your file is not 747kB and it doesn't have the correct magic number at the start for `gzip`. – Mark Setchell Oct 12 '22 at 07:21
  • With `np.fromfile` you can read flat bin data with a dtype like 'u2'. But that doesn't have an shape information. I'm not familiar with what `HDFView` can export, so can't help with further details. But with the `h5py` module it is possible to load data from `HDF5` files directly. – hpaulj Oct 12 '22 at 16:11
  • I used h5py and was able to export the data to a numpy array. Thank you @hpaulj ! – Captain Ahab Oct 12 '22 at 19:47

0 Answers0