Skip to content

int16 data sets not read properly #8

@ercius

Description

@ercius

I work for a large microscopy center which is starting to generate data written in HDF5 format (FEI's EMD format). Your HDF5 vibez plugin for Fiji is extremely useful for users who are not able to read the data using any other GUI based software. However, signed integer 16-bit data is not being properly read. It looks like there is an issue between converting from HDF5 int16 and ImageJ's int16 format.

I had a similar issue writing a Jython plugin for Fiji. The solution was to read unsigned and signed data as signed. Then everything worked when creating a ImagePlus.

The issue is probably in this part of the Vibez plugin

As per information from my issue posted to the ImageJ Forum linked above:

short in Java is always signed (-32,768 to 32,767)
a ShortProcessor in ImageJ1 is always unsigned

I am not a Java developer and not setup to compile/test this in ImageJ. Do you have anytime to look into this issue?

I can send a small test H5 file with int16 and uint16 datasets to show the problem. It's easy to create this using the following Python code

import h5py
import numpy as np

int1 = np.linspace(-32768,32767,100,dtype=np.int16)
uint1 = np.linspace(0,65535,100,dtype=np.uint16)

YY,XX = np.meshgrid(int1,int1)
YYu,XXu = np.meshgrid(uint1,uint1)

with h5py.File('integers.h5','w') as f1:
    f1.create_dataset('int16',data=XX.astype(np.int16),compression='gzip')
    f1.create_dataset('uint16',data=XXu.astype(np.uint16),compression='gzip')
    f1.create_dataset('XX',data=XX.astype(np.float32),compression='gzip')
    f1.create_dataset('XXu',data=XXu.astype(np.float32),compression='gzip')

Here is the data read into Fiji using your plugin:
uint16
image

int16
image

PS Thank you very much for all your work on this plugin. Its extremely useful and will see a lot more use as HDF5 data sets become more ubiquitous.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions