From eecfb1b0e9a5a7c0bae899cca7d9da0ec6a3577d Mon Sep 17 00:00:00 2001 From: Austin Kuo Date: Thu, 16 Feb 2023 13:33:04 -0800 Subject: [PATCH] =?UTF-8?q?Adjust=20default=20nifti=20header=20creation=20?= =?UTF-8?q?regarding=20=E2=80=98pixdim=E2=80=99=20field,=20responsible=20f?= =?UTF-8?q?or=20shifting=20xform=20origin=20coords=20new=20default=20behav?= =?UTF-8?q?ior:=20grab=20'pixdim'=20from=20original=20nifti=20header=20if?= =?UTF-8?q?=20it=20exists=20OR,=20fallback:=20set=20default=20pixdim=20fie?= =?UTF-8?q?ld=20to=20[...=203=201=201=201]=20(previously=20[...=200=200=20?= =?UTF-8?q?0=200])?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mrUtilities/File/mlrImage/mlrImageGetNiftiHeader.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mrUtilities/File/mlrImage/mlrImageGetNiftiHeader.m b/mrUtilities/File/mlrImage/mlrImageGetNiftiHeader.m index 67bbdf083..53b10c0e3 100644 --- a/mrUtilities/File/mlrImage/mlrImageGetNiftiHeader.m +++ b/mrUtilities/File/mlrImage/mlrImageGetNiftiHeader.m @@ -33,7 +33,8 @@ hdr.dim = hdr.dim(:); hdr.dim = hdr.dim(1:8); hdr.pixdim = [h.nDim h.pixdim]; -hdr.pixdim(end+1:8) = 0; +hdr.pixdim(end+1) = 3; % specify ndims of origin +hdr.pixdim(end+1:8) = 1; % specify origin; nifti headers seem to default to [1 1 1] hdr.pixdim = hdr.pixdim(:); hdr.pixdim = hdr.pixdim(1:8); @@ -70,11 +71,10 @@ % seem a bit strange (why recreate the nifti header if % it already exists as a field) but this is done so that % we can get a clean header - fieldsToCopyFromOriginalNiftiHeader = {'datatype','endian','bitpix','vox_offset','xyzt_units'}; + fieldsToCopyFromOriginalNiftiHeader = {'datatype','endian','bitpix','vox_offset','xyzt_units','pixdim'}; for iField = 1:length(fieldsToCopyFromOriginalNiftiHeader) if isfield(h.hdr,fieldsToCopyFromOriginalNiftiHeader{iField}) hdr.(fieldsToCopyFromOriginalNiftiHeader{iField}) = h.hdr.(fieldsToCopyFromOriginalNiftiHeader{iField}); end end -end - +end \ No newline at end of file