【问题标题】:Copy one Nifti header to another将一个 Nifti 标头复制到另一个
【发布时间】:2017-11-15 17:24:14
【问题描述】:

我在 matlab 中有一个“prob_map”变量(概率图),我想将它保存为“.nii”格式。我用两行代码做到了:

 nii = make_nii(prob_map); 
 save_nii(nii,'prob.nii');

这已成功完成,但是标题信息与我名为“img.nii”的原始 CT 图像不兼容(因此在 ITK-SNAP 软件中,无法在图像上覆盖 prob_map)。我想在保存之前将 img.nii 的标头复制到“prob.nii”标头。事实上,我想尽可能地复制一个人的标题。例如,无法复制标题大小,而可以复制方向和其他信息。 是否有任何功能可以在保存 nii 之前将一个人的标题复制到另一个?必须复制哪些信息才能使两个 nii 保持一致?

【问题讨论】:

    标签: matlab header nifti


    【解决方案1】:

    您可以尝试使用spm matlab library

    # Grab header from an existing file (and optionally, get the data)
    HeaderInfo  = spm_vol('img.nii')          # use spm_vol to read file header
    NiftiData   = spm_read_vol(HeaderInfo)    # use spm_read_vol to get data
    
    # Update the header contents to correspond with your new data
    HeaderInfo.fname = 'prob.nii';
    HeaderInfo.private.dat.fname = HeaderInfo.fname;
    
    # Save the file with the adapted Header
    spm_write_vol(HeaderInfo,Data);           # where Data is your image array
    

    【讨论】:

      猜你喜欢
      • 2021-03-17
      • 1970-01-01
      • 2016-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-13
      • 2019-02-18
      • 1970-01-01
      相关资源
      最近更新 更多