# How to read .img file in SimpleITK?

**URL:** <https://discourse.itk.org/t/how-to-read-img-file-in-simpleitk/6265>\
**Category:** Beginner Questions\
**Tags:** simpleitk, python\
**Created:** [October 27, 2023, 1:17pm UTC](https://discourse.itk.org/t/how-to-read-img-file-in-simpleitk/6265 "2023-10-27T13:17:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![debapriya](https://discourse.itk.org/letter_avatar_proxy/v4/letter/d/bc79bd/32.png) [@debapriya](https://discourse.itk.org/u/debapriya)\
**Post date:** [October 27, 2023, 1:17pm UTC](https://discourse.itk.org/t/how-to-read-img-file-in-simpleitk/6265/1 "2023-10-27T13:17:45Z")

</div>

I have downloaded 4D CT data from DIRLAB image database. The images are in `.img` format.

 ![image](https://discourse.itk.org/uploads/default/original/2X/7/7b1c552dccbf56a9e54481933b15b4a07b57fb32.png)

I tried to read these images using `sitk.ReadImage` method.  
`sitk.ReadImage(image_file_name, sitk.sitkFloat32)`.  
I am getting the following exception

 ![image](https://discourse.itk.org/uploads/default/original/2X/a/a965f4b1af84c14cfb75a4a8f4bcb2610a87383e.png)

Please tell me the correct process to read these images.

---

<div class="post-metadata">

**Author:** ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)\
**Post date:** [October 27, 2023, 1:38pm UTC](https://discourse.itk.org/t/how-to-read-img-file-in-simpleitk/6265/2 "2023-10-27T13:38:46Z")

</div>

Hello @debapriya,

Not sure what format your image is in, it isn’t automatically recognized by ITK/SimpleITK.

Given the generic “img” extension I suspect this may be a raw format which requires additional information from a header file, but this is just a guess. A SimpleITK example illustrating how to read raw image files is available on [read the docs](https://simpleitk.readthedocs.io/en/master/link_RawImageReading_docs.html).

If this is not the case you will need to provide additional information with respect to this format or possibly share an example image.

---

<div class="post-metadata">

**Author:** ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)\
**Post date:** [October 27, 2023, 8:38pm UTC](https://discourse.itk.org/t/how-to-read-img-file-in-simpleitk/6265/3 "2023-10-27T20:38:14Z")

</div>

Looking at the description of the DIRLAB data set, the images appear to be in Pinnacle TPS raw \*.img format. It seems like the images are raw 16-bit images, although I don’t know the file format, so who knows?

[https://med.emory.edu/departments/radiation-oncology/research-laboratories/deformable-image-registration/downloads-and-reference-data/index.html](https://med.emory.edu/departments/radiation-oncology/research-laboratories/deformable-image-registration/downloads-and-reference-data/index.html)

Googling around it seems that the PyMedPhys library has a Pinnacle to DICOM export tool

[https://docs.pymedphys.com/en/latest/users/ref/cli/pinnacle.html](https://docs.pymedphys.com/en/latest/users/ref/cli/pinnacle.html)
