Bug/issue opening mha files

Hi All,

Using IJ.openImage() for mha files shows the image but does not return an imp.
For tif files it does the opposite (correct) thing: it does not show the image but returns the imp. It would be great if the behavior for the mha files could be fixed!

mha_bug.zip (291.2 KB)

from ij import IJ
imp = IJ.openImage("C:\\Users\\almf\\Desktop\\result.0.mha");
imp = IJ.openImage("C:\\Users\\almf\\Desktop\\result.0.tif");

This gives:

img[result.0.tif (512x512x1x1x1)]

This is because MetaImage_Reader explicitly calls imp.show(). (I guess FIBSEM_Reader will have the same problem.)

Looking at the other classes in https://github.com/fiji/IO/tree/master/src/main/java/sc/fiji/io, I guess this should be fixable by making MetaImage_Reader extend ImagePlus and implement PlugIn, but a better (and more future-proof) option might be to convert this reader into a SCIFIO format. That way, other tools (e.g. KNIME) would profit immediately from the ability to read .mha files as well.

1 Like