# \[fixed\]How to read raw data using simpleitk?

**URL:** https://discourse.itk.org/t/fixed-how-to-read-raw-data-using-simpleitk/1858
**Category:** Beginner Questions
**Created:** [May 10, 2019, 3:13am UTC](https://discourse.itk.org/t/fixed-how-to-read-raw-data-using-simpleitk/1858 "2019-05-10T03:13:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hubutui](https://discourse.itk.org/user_avatar/discourse.itk.org/hubutui/32/716_2.png) [@hubutui](https://discourse.itk.org/u/hubutui)
#### Post date: [May 10, 2019, 3:13am UTC](https://discourse.itk.org/t/fixed-how-to-read-raw-data-using-simpleitk/1858/1 "2019-05-10T03:13:22Z")

</div>

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](https://discourse.itk.org/uploads/default/original/1X/a4e8675c91239484c12ea39f983584809fc17d31.png)

So I think I could create a mhd file, according to [this](https://itk.org/Wiki/SimpleITK/FAQ#How_do_I_read_a_RAW_image_into_SimpleITK.3F).  
I’m not sure what ElementType should I use. Maybe I should use `MET_USHORT_TYPE` according to [this](https://github.com/Kitware/MetaIO/blob/master/src/metaTypes.h#L42)? Also, which attribute is for “White is Zero” option?

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [May 10, 2019, 1:13pm UTC](https://discourse.itk.org/t/fixed-how-to-read-raw-data-using-simpleitk/1858/2 "2019-05-10T13:13:35Z")

</div>

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](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](https://itk.org/Wiki/ITK/MetaIO/Documentation)

I believe you what:

```auto
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.

---

<div class="post-metadata">

### Author: ![hubutui](https://discourse.itk.org/user_avatar/discourse.itk.org/hubutui/32/716_2.png) [@hubutui](https://discourse.itk.org/u/hubutui)
#### Post date: [May 15, 2019, 8:32am UTC](https://discourse.itk.org/t/fixed-how-to-read-raw-data-using-simpleitk/1858/3 "2019-05-15T08:32:03Z")

</div>

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.
