如何将 .nii 转换为 .nii.gz 文件?

How to convert .nii to .nii.gz file?

我有很多 .nii 文件。我想知道如何将 .nii 文件转换为 .nii.gz 文件?

谢谢

据我所知,压缩 NIfTI 文件没有什么特别之处。在 MATLAB 中,您可以简单地执行以下操作:

gzip('niftifilename.nii') % this will return niftifilename.nii.gz
gzip('*.nii') % for multiple nii files to create one .nii.gz

要再次使用该文件,您可以使用 gunzip 将其解压缩。我已经在我的 Mac 上试过了(不知道这是否适用于 Windows)。

通常,它们是卷数据,因此占用相当多的磁盘空间 space。压缩它纯粹是为了减小文件的大小,不应该修改数据。

你可以简单地做:

gzip({'*.nii'},outputdir)

这会将您所有的 nii 文件压缩到 nii.gz 并将其放入 outputdir。

来自文档:

To gzip all .m and .mat files in the current directory and store the results in the directory archive, type:

gzip({'.m','.mat'},'archive')