I need to convert mutiple .nii files into one .nii.gz file.

24 ビュー (過去 30 日間)
Ed
Ed 2023 年 5 月 27 日
回答済み: Govind KM 2024 年 9 月 20 日
In Matlab, I used gzip('*.nii'), but it creates multiple nii.gz files for each single nii file. How could I create one combined nii.gz file from many .nii files?
Thanks in advance

回答 (1 件)

Govind KM
Govind KM 2024 年 9 月 20 日
Hi Ed,
The “gzip” command is designed to compress individual files rather than creating a single archive containing multiple files. Hence a separate .gz file will be created for each .nii file.
A workaround to create a combined .gz file is to use the “tar” function along with “gzip”. The “tar” function combines multiple files together into a single .tar file, which can then be compressed using “gzip” :
%Concatenate all .nii files into a single .tar file
tar("MyTar","*.nii"); %Replace MyTar with the desired output file name
%Compress the .tar file with gzip
gzip("MyTar.tar");
%To get the compress files back, use gunzip and untar
gunzip("MyTar.tar.gz");
untar("MyTar.tar");
More details on the “tar” and “untar” functions can be found in the following documentation:
Hope this helps!

カテゴリ

Help Center および File ExchangeSignal Processing Toolbox についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by