I want to embed text in the MRI nrrd file. Is there any method?
Many thanks!
You can add custom fields to NRRD files. Examples — pynrrd 0.4.2 documentation
You could save your MRI to a .nrrd file in Slicer, and then load using pynrrd, then do something like this
import nrrd # load pynnrd package
img_data, img_header = nrrd.read('my_saved_mri.nrrd')
# Add the text you want to save to the header
img_header["my_custom_field1"] = "the text I want to save goes here"
my_custom_field_map = {"my_custom_field1": "str"} # python dict of custom field names and data types
nrrd.write('output_including_text.nrrd', img_data, img_header, custom_field_map=my_custom_field_map)