diff --git a/avwcpgeom.c b/avwcpgeom.c index bfb77234c337bdc378ac077ee433c68f7b49abc8..7faff6f4d0a1df67f79702b0be0213326bfa844b 100644 --- a/avwcpgeom.c +++ b/avwcpgeom.c @@ -37,11 +37,12 @@ int main(argc,argv) char thestring[10000]; /* struct dsr hdr, hdr2; */ FSLIO *src = NULL, *dest = NULL; - short need_to_copy = 0, x, y, z, v, copydim=1; + short x, y, z, v, copydim=1, t; float vx, vy, vz, tr; char c; short orig[5]; void *buffer = NULL; + char desthdrname[10000]; if (argc<3) usage(); @@ -64,21 +65,21 @@ int main(argc,argv) exit(EXIT_FAILURE); } - if ( FslGetFileType(dest) == FSL_TYPE_NIFTI_GZ ) { - short t; - - need_to_copy = 1; - /* Read all the destination volumes... */ - FslGetDim(dest, &x, &y, &z, &v); - if( (buffer = malloc(x * y * z * v * (FslGetDataType(dest, &t) / 8))) == NULL ) { - perror("Unable to allocate memory for NIFTI_GZ copy"); - exit(EXIT_FAILURE); - } - FslReadVolumes(dest, buffer, v); + /* Read all the destination volumes... */ + FslGetDim(dest, &x, &y, &z, &v); + if( (buffer = malloc(x * y * z * v * (FslGetDataType(dest, &t) / 8))) == NULL ) { + perror("Unable to allocate memory for copy"); + exit(EXIT_FAILURE); } + FslReadVolumes(dest, buffer, v); + + + strcpy(desthdrname,dest->niftiptr->fname); FslClose(dest); /* ...and now reopen destination for writing */ - dest = FslOpen(argv[2], "w"); + dest = FslOpen(desthdrname, "w"); + + FslCloneHeader(dest,src); /* }}} */ /* {{{ copy geom */ @@ -117,10 +118,11 @@ int main(argc,argv) /* swap_hdr(&hdr2); */ FslWriteHeader(dest); - if(need_to_copy) - FslWriteVolumes(dest, buffer, v); + FslWriteVolumes(dest, buffer, v); FslClose(dest); + FslClose(src); + /* avw_write_hdr_only(thestring,&hdr2); */ /* }}} */