# How do you access the "Modality" metadata from the MHA header?

**URL:** https://discourse.itk.org/t/how-do-you-access-the-modality-metadata-from-the-mha-header/6547
**Category:** Beginner Questions
**Tags:** python, simpleitk
**Created:** [March 28, 2024, 3:18pm UTC](https://discourse.itk.org/t/how-do-you-access-the-modality-metadata-from-the-mha-header/6547 "2024-03-28T15:18:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nicoco](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/7c8e57/32.png) [@nicoco](https://discourse.itk.org/u/nicoco)
#### Post date: [March 28, 2024, 3:18pm UTC](https://discourse.itk.org/t/how-do-you-access-the-modality-metadata-from-the-mha-header/6547/1 "2024-03-28T15:18:54Z")

</div>

Some MHAs contain a “Modality” tag, which seems to be treated differently than other keys. How do we access it?

Some sort of MWE:

```auto
> cat /tmp/test.mha
ObjectType = Image
NDims = 3
BinaryData = True
BinaryDataByteOrderMSB = False
CompressedData = False
TransformMatrix = 1 0 0 0 1 0 0 0 1
Offset = 0 0 0
CenterOfRotation = 0 0 0
AnatomicalOrientation = RAI
ElementSpacing = 1 1 1
CustomMeta = CustomValue
DimSize = 2 2 2
ElementType = MET_DOUBLE
Modality = CT
ElementDataFile = LOCAL

python -c "import SimpleITK as sitk
           img = sitk.ReadImage('/tmp/test.mha')
           print(img.GetMetaDataKeys())
           print(img.GetModality())"
('CustomMeta', 'ITK_InputFilterName', 'ITK_original_direction', 'ITK_original_spacing')
Traceback (most recent call last):
  File "<string>", line 4, in <module>
AttributeError: 'Image' object has no attribute 'GetModality'

```

Is this field just dropped or do my doc-searching skills needs improving?

---

<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: [March 28, 2024, 6:46pm UTC](https://discourse.itk.org/t/how-do-you-access-the-modality-metadata-from-the-mha-header/6547/2 "2024-03-28T18:46:35Z")

</div>

Hello @nicoco,

Welcome to the ITK community. Your doc-searching skills and bug finding skills are good as they are!

Hopefully, this [pull request](https://github.com/InsightSoftwareConsortium/ITK/pull/4549) will resolve the issue.
