[ITK-users] [ITK] using MHA file to store additional information about image

Yaniv, Ziv Rafael (NIH/NLM/LHC) [C] zivrafael.yaniv at nih.gov
Wed May 30 16:10:03 EDT 2018


Hello Andrew,

The users mailing list for ITK has moved to a discussion forum: https://discourse.itk.org/, please post there in the future.

I do not think that the MHA format will allow you to do this, but maybe I’m wrong.

This is relatively common using the DICOM format and private tags (pp. 59 in part 5 of the standard, http://dicom.nema.org/medical/dicom/current/output/pdf/part05.pdf).

The SimpleITK code below does what I believe you want (too long for ITK here).

      hope this helps
            Ziv

import SimpleITK as sitk

private_creator = "0009|0010"
private_tag = "0009|0011"

img = sitk.Image((128,128), sitk.sitkUInt8)
img.SetMetaData(private_creator, "UWO Encoder Values")
img.SetMetaData(private_tag,"0.18 0.76 0.97 0.87")
sitk.WriteImage(img, "image_with_encoder_data.dcm")

# read the image we just wrote, tell the reader to load the private tags
image_reader = sitk.ImageFileReader()
image_reader.SetFileName("image_with_encoder_data.dcm")
image_reader.LoadPrivateTagsOn()
img_read = image_reader.Execute()
encoder_values_string = img_read.GetMetaData(private_tag)

# convert the returned string to a list of floats
encoder_values = [float(x) for x in encoder_values_string.split()]



From: Andrew Harris <aharr8 at uwo.ca>
Date: Wednesday, May 30, 2018 at 2:54 PM
To: Insight-users <insight-users at itk.org>
Subject: [ITK] [ITK-users] using MHA file to store additional information about image

Hello, I was wondering if it is possible to store additional information about an image as part of an MHA file.  Specifically, we are capturing ultrasound using an arm that has encoders attached that report position in space, and I'd like to be able to include that information in the MHA file rather than keeping a separate record. Thanks in advance for the help.

--

AH



Andrew Harris, BSc with Honours (Medical Physics)

PhD (CAMPEP) & MClSc Candidate

-----------------------------------------------------------------------------------------------

This email and any attachments thereto may contain private, confidential, and privileged materials for the sole use of the intended recipient. Any reviewing, copying, or distribution of this email (or any attachments thereto) by other than the intended recipient is strictly prohibited. If you are not the intended recipient, please contact the sender immediately and permanently destroy this email and any attachments thereto.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://itk.org/pipermail/insight-users/attachments/20180530/b4747391/attachment.html>


More information about the Insight-users mailing list