help > mriCRON: Nifti to .hdr
Showing 1-3 of 3 posts
Display:
Results per page:
Apr 26, 2021  08:04 AM | rosenkohl
mriCRON: Nifti to .hdr
Hi all,

I am using the latest mriCron Version on a Linux machine. I would like to convert niftis, that I got from a SPM first level analysis, into .hdr format. I already know (from google) that this should be possible by "import -> convert nifti to .hdr" BUT my mriCron does not have this option or even this button in the GUI. The only option avaible is "convert DICOM to NIfti". How can I achive a conversion to .hrd and whats the reason for the missing button? Is it just that I am using the latest mriCRON version?

Thank you so much in advance and all the best,

Mareike
Apr 26, 2021  11:04 AM | Chris Rorden
RE: mriCRON: Nifti to .hdr
Modern SPM works well with single file NIfTI (filename.nii), so I am not sure why you need the dual file version (.hdr/.img). I have moved active development to MRIcroGL, so the MRIcron documentation might be getting a bit out of date.

I would use the FSL tool fslchfiletype to do this, but you could also use a Matlab script with SPM:



function nii_nii2hdr (fnms)
%Convert file.nii to file.hdr/file.img
% https://github.com/rordenlab/dcm2niix/is...
%n.b. FSL does not like file.nii and file.hdr co-existing
% fnms : (optional) images to convert
%Examples
% nii_nii2hdr
% nii_nii2hdr('T1_LM1003.nii');
% nii_nii2hdr(strvcat('T1_LM1003.nii','T2_LM1003.nii'));

if ~exist('fnms','var') %file not specified
[A,Apth] = uigetfile({'*.nii';'*.*'},'Select .nii file(s)', 'MultiSelect', 'on');
fnms = strcat(Apth,char(A));
end
for i=1:size(fnms,1)
fnm = fnms(i,:);
[pth, nm] = spm_fileparts(fnm);
hdr = spm_vol(fnm);
img = spm_read_vols(hdr);
hdr.fname = fullfile(pth, [nm, '.img']);
spm_write_vol(hdr,img);
end
Apr 26, 2021  12:04 PM | rosenkohl
RE: mriCRON: Nifti to .hdr
Hi Chris, thank you so much for your response, both alternatives worked perfectly fine for me (inside SPM & FSL)!

Did I understand that correctly, that there is a possibility in MRIcroGL to do the conversion (by using the GUI)?