Hello,
I adapted some nifty matlab code to read .rmha images into 3d slicer. As I understand, these are VivoQuant labelled ROI images.
The original code was written by Joseph Dalton Brook, which he made available in his Ph.D Thesis. Thanks mate! Full disclosure, ChatGPT did the grunt work as I don’t speak matlab very well. I’m amazed the code works at all but here we are.
And the metadata I was able to extract for one of our .rmha files:
print(dic)
{'ObjectType': 'ROI', 'NDims': 3, 'BinaryData': True, 'BinaryDataByteOrderMSB': False, 'CompressedData': 'RLE', 'TransformMatrix': [-1, 0, 0, 0, -1, 0, 0, 0, -1], 'Offset': [0, 0, 0], 'CenterOfRotation': [0, 0, 0], 'AnatomicalOrientation': 'LPS', 'ElementSpacing': [0.020446, 0.020446, 0.020446], 'DimSize': [490, 490, 587], 'ElementType': <class 'numpy.uint8'>, 'ROI[1]': 'Vis:red:1:0:127:255', 'ROI[2]': 'Upper_Bone:magenta:1:0:127:255', 'ROI[3]': 'Lower_Bone:green:1:0:127:255', 'ROI[4]': 'Implant:blue:1:0:127:255', 'PatientsName': '', 'PatientID': '', 'StudyDescription': '', 'StudyDate': '', 'StudyTime': '', 'SeriesDescription': '', 'SeriesDate': '', 'SeriesTime': '', 'ReferenceUID': '', 'ElementDataFile': 'LOCAL'}
The 3D slicer extension is very basic and simply loads the rmha file as a volume. It works, but there are a few things I still need to look at:
-
I haven’t used the named colours provided in the metadata to the different labels yet, but I’m pretty sure I can use the webcolors module for that. I’ll have a look at how other modules might apply a discrete look-up table to the volumetric data but any guidance here will be welcome.
-
I’m also discovering that whereas the original image (mha or mhd) may well have an origin offset, the rmha’s offset is always 0. So I still need to think about what to do. Do I check if in the rmha file’s directory, there’s a mha/mhd file from which I can copy the offset?
-
I’ve been reading up on past discussions on the volume orientation issues here and here… I’m still digesting the info but I understand this is something I need to take into account to match the orientation of the rmha to that of the mha / mhd supporting volume. I have a
'TransformMatrix': [-1, 0, 0, 0, -1, 0, 0, 0, -1]
and a'AnatomicalOrientation': 'LPS'
.
So that’s where I’m at, and I have some very rough code I can share if anyone is interested:
I’ll check some other extensions for code I can borrow and if I make any progress I’ll report back!
Kind regards,
Egor