I’m using MetaImage and NRRD file types with custom header fields to store additional information about my volume. I am currently interested in updating the values of these custom fields, but I have only had success with writing the updated header field which also rewrites the image data.
I’ve currently been using SimpleITK to update the fields as I was unable to find an option in Slicer to save the custom fields.
import SimpleITK as sitk image = sitk.ReadImage("path/to/image.mhd") image.SetMetaData("MyCustomField", "MyCustomValue") writer = sitk.ImageFileWriter() writer.SetFileName("same/path/to/image.mhd") writer.Execute(image) # also writes out the image raw file
I understand that likely only updating the header is possible when using split file formats like mhd+raw or nhdr+raw. Or is there a method with MHA and NRRD that can update the header fields and shift the bits so not to write the image data again?
Does anyone know of a method of only updating a field for the header file without the obvious opening of the file manually and writing it as simple text.