-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wishlist: add mgh to nii conversion #28
Comments
Converting MGH/MGZ brain volumes (3D/4D) to NIFTI brain volumes is definitely possible, and you can get most of the required information from a proper MGH file. There are some limitations though. Note: Of course, some software libraries allow people to store data without proper header (basically the MGH is just a 4D array then), or some people store 1D-data (per-vertex overlays) in MGH files instead of using curv format, which also have no useful header then, of course. But if the MGH is a proper file representing a volume image, the information is mostly there. You can tell whether that's the case from the is_ras_valid field in the MGH file. MGH has, for example, no INTENT field (see NIFTI1 standard), so your converter would have to assume that the source MGH/MGZ is a brain volume (people could store whatever in the file, but you cannot know what they meant) and set some NIFTI header fields to zeros that are not useful for brain volumes. If the MGH file contains data with a different meaning (like p-values for each voxel, so a stats map), you cannot really know that, and so you cannot properly set the INTENT field in general. You have to make some assumptions. (Or you need a way more complex function that takes as an additional argument an INTENT, and fills the NIFTI header information based on the data and that intent information.) You can see the inverse operation to what you want to do here in Also note that various NIFTI header fields are simply unused (see linked NIFTI 1 standard document, Chapter 7). I thought I had already written a It's been a while since I messed with the NIFTI standard, and I would have to read up on the details of the header fields myself I guess. |
|
So it is fine with you if we assume that the file contains a 3D/4D brain volume, right? Then I could have a look. |
Right. Most likely when people read a mgh file, they are reading I guess as long as you mention in the help document that this is only intended for 3D/4D brain volumes, people should respect it. Thanks a lot : ) |
Yes, what people want in the end, in the case of a 3D/4D volume, is the correct RAS information to be extracted from the NII and stored in the respective header fields of the MGH. |
Hi @dfsp-spirit , I wonder how hard it would be to write a mgh/mgz to nii converter? I tried to implement by myself, but I don't know where to get rest of the header information or if the conversion is generally applicable. Can I steal some knowledge from you?
Thanks!
The text was updated successfully, but these errors were encountered: