[fixed]How to read raw data using simpleitk?

(Butui Hu) #1

Hi, I’m trying to read an image without meta header. I’m told that I could use ImageJ/Fiji to open the image by “File menu > import > Raw”, and set

Image type: 16-bit Unsigned
Width: 2048 pixels
Height: 2048 pixels
Offset to First Image: 1
Gap Between Images: 0 bytes
Check “White is Zero” only
Just like this:
image

So I think I could create a mhd file, according to this.
I’m not sure what ElementType should I use. Maybe I should use MET_USHORT_TYPE according to this? Also, which attribute is for “White is Zero” option?

1 Like
(Bradley Lowekamp) #2

Hello Butui Hu!

It sounds like you are on the right track. You linked to the old FAQ; the new one is here on ReadTheDocs:
https://simpleitk.readthedocs.io/en/master/Documentation/docs/source/faq.html#how-do-i-read-a-raw-image-into-simpleitk

Here is a link to more details on the meta data format:
https://itk.org/Wiki/ITK/MetaIO/Documentation

I believe you what:

ElementType = MET_USHORT

There is no option for white is zero in meta io. With certain microscopy formats (I encounter this with STEM) it is a viewing preference to see the image inverted, as ITK is focused on processing rather than viewing, in general it does not do much related to descriptor for “how to display” an image.

(Butui Hu) #3

Thank you. I save the image to mhd format using ImageJ/Fiji. And then I get a template for the mhd file. It works great so far. As for White is Zero, InvertIntensityImageFilter helps.

3 Likes