From ead120d78c0335d4fdc14ca6548a1071c0ae10d0 Mon Sep 17 00:00:00 2001
From: Matthew Webster <mwebster@fmrib.ox.ac.uk>
Date: Tue, 16 Oct 2018 13:13:10 +0000
Subject: [PATCH] corrected bug if new sizes are all 1

---
 fslcreatehd.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fslcreatehd.cc b/fslcreatehd.cc
index 947e991..cc270f9 100755
--- a/fslcreatehd.cc
+++ b/fslcreatehd.cc
@@ -110,7 +110,7 @@ int fslcreatehd_main(int argc, char *argv[])
   }
 
  /* if previously read buffer is wrong size then make a zero image here */
-  if ( header.nElements() != originalHeader.nElements() ) {
+  if ( !existingImage || header.nElements() != originalHeader.nElements() ) {
     if(buffer!=NULL)
       delete buffer;
     buffer = new char[header.nElements()*(header.bpvOfDatatype()/8)];
@@ -122,7 +122,6 @@ int fslcreatehd_main(int argc, char *argv[])
       filename=make_basename(filename)+outputExtension(filetype);
     }
 
-    //header.report();
     header.bitsPerVoxel=header.bpvOfDatatype();
     header.setNiftiVersion(FslNiftiVersionFileType(filetype),FslIsSingleFileType(filetype));
     reader.saveImage(filename,buffer,extensions,header, FslIsCompressedFileType(filetype));
-- 
GitLab