Last active
May 6, 2024 11:24
-
-
Save koegl/96e79b4f7b6df568fa0eaa9c70e61c58 to your computer and use it in GitHub Desktop.
Convert .h5 to .nii.gz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this snippet shows how to convert a .h5 transformation to a .nii.gz displacement field using the ants python library | |
# based on this commend https://github.com/ANTsX/ANTs/issues/54#issuecomment-2085595485 | |
# to do this, we need the reference/fixed image and the .h5 transformation | |
from ants import utils as utils_ants | |
args = ['-d', '3', | |
'-r', 'reference.nii.gz', | |
'-t', 'transform.h5', | |
'-o', '[ transform.nii.gz, 1 ]', | |
'--verbose'] | |
libfn = utils_ants.get_lib_fn('antsApplyTransforms') | |
libfn(processed_args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment