function header_out = reset_header_data(header_data, header_in, num_dims)
% header_out = reset_header_data(header_data, header_in, num_dims)
%   reset fields in header_in to reflect info in header_data ... num_dims
%   is the (optional) number of dimensions for spectrum described by
%   header_out ... if num_dims is not provided, the new spectrum is assumed
%   to have the same number of dims as the old spectrum

header_out = header_in;

header_out( 95 +1) = header_data( 1 , 1 ); % APOD
header_out( 428 +1) = header_data( 1 , 2 );  
header_out( 50 +1) = header_data( 1 , 3 );  
header_out( 53 +1) = header_data( 1 , 4 );  
header_out( 413 +1) = header_data( 2 , 1 ); % APODCODE
header_out( 414 +1) = header_data( 2 , 2 );  
header_out( 400 +1) = header_data( 2 , 3 );  
header_out( 405 +1) = header_data( 2 , 4 );  
header_out( 415 +1) = header_data( 3 , 1 ); % APODQ1
header_out( 420 +1) = header_data( 3 , 2 );  
header_out( 401 +1) = header_data( 3 , 3 );  
header_out( 406 +1) = header_data( 3 , 4 );  
header_out( 416 +1) = header_data( 4 , 1 ); % APODQ2
header_out( 421 +1) = header_data( 4 , 2 );  
header_out( 402 +1) = header_data( 4 , 3 );  
header_out( 407 +1) = header_data( 4 , 4 );  
header_out( 417 +1) = header_data( 5 , 1 ); % APODQ3
header_out( 422 +1) = header_data( 5 , 2 );  
header_out( 403 +1) = header_data( 5 , 3 );  
header_out( 408 +1) = header_data( 5 , 4 );  
header_out( 64 +1) = header_data( 6 , 1 ); % AQSIGN
header_out( 475 +1) = header_data( 6 , 2 );  
header_out( 476 +1) = header_data( 6 , 3 );  
header_out( 477 +1) = header_data( 6 , 4 );  
header_out( 418 +1) = header_data( 7 , 1 ); % C1
header_out( 423 +1) = header_data( 7 , 2 );  
header_out( 404 +1) = header_data( 7 , 3 );  
header_out( 409 +1) = header_data( 7 , 4 );  
header_out( 66 +1) = header_data( 8 , 1 ); % CAR
header_out( 67 +1) = header_data( 8 , 2 );  
header_out( 68 +1) = header_data( 8 , 3 );  
header_out( 69 +1) = header_data( 8 , 4 );  
header_out( 79 +1) = header_data( 9 , 1 ); % CENTER
header_out( 80 +1) = header_data( 9 , 2 );  
header_out( 81 +1) = header_data( 9 , 3 );  
header_out( 82 +1) = header_data( 9 , 4 );  
header_out( 220 +1) = header_data( 10 , 1 ); % FTFLAG
header_out( 222 +1) = header_data( 10 , 2 );  
header_out( 13 +1) = header_data( 10 , 3 );  
header_out( 31 +1) = header_data( 10 , 4 );  
header_out( 96 +1) = header_data( 11 , 1 ); % FTSIZE
header_out( 98 +1) = header_data( 11 , 2 );  
header_out( 200 +1) = header_data( 11 , 3 );  
header_out( 201 +1) = header_data( 11 , 4 );  
header_out( 16 +1) = header_data( 12 , 1 ); % LABEL
header_out( 18 +1) = header_data( 12 , 2 );  
header_out( 20 +1) = header_data( 12 , 3 );  
header_out( 22 +1) = header_data( 12 , 4 );  
header_out( 111 +1) = header_data( 13 , 1 ); % LB (x, y dims only)
header_out( 243 +1) = header_data( 13 , 2 );  
header_out( 119 +1) = header_data( 14 , 1 ); % OBS
header_out( 218 +1) = header_data( 14 , 2 );  
header_out( 10 +1) = header_data( 14 , 3 );  
header_out( 28 +1) = header_data( 14 , 4 );  
header_out( 480 +1) = header_data( 15 , 1 ); % OFFPPM
header_out( 481 +1) = header_data( 15 , 2 );  
header_out( 482 +1) = header_data( 15 , 3 );  
header_out( 483 +1) = header_data( 15 , 4 );  
header_out( 101 +1) = header_data( 16 , 1 ); % ORIG
header_out( 249 +1) = header_data( 16 , 2 );  
header_out( 12 +1) = header_data( 16 , 3 );  
header_out( 30 +1) = header_data( 16 , 4 );  
header_out( 109 +1) = header_data( 17 , 1 ); % P0
header_out( 245 +1) = header_data( 17 , 2 );  
header_out( 60 +1) = header_data( 17 , 3 );  
header_out( 62 +1) = header_data( 17 , 4 );  
header_out( 110 +1) = header_data( 18 , 1 ); % P1
header_out( 246 +1) = header_data( 18 , 2 );  
header_out( 61 +1) = header_data( 18 , 3 );  
header_out( 63 +1) = header_data( 18 , 4 );  
header_out( 56 +1) = header_data( 19 , 1 ); % QUADFLAG
header_out( 55 +1) = header_data( 19 , 2 );  
header_out( 51 +1) = header_data( 19 , 3 );  
header_out( 54 +1) = header_data( 19 , 4 );  
header_out( 100 +1) = header_data( 20 , 1 ); % SW
header_out( 229 +1) = header_data( 20 , 2 );  
header_out( 11 +1) = header_data( 20 , 3 );  
header_out( 29 +1) = header_data( 20 , 4 );  
header_out( 386 +1) = header_data( 21 , 1 ); % TDSIZE
header_out( 387 +1) = header_data( 21 , 2 );  
header_out( 388 +1) = header_data( 21 , 3 );  
header_out( 389 +1) = header_data( 21 , 4 );  
header_out( 152 +1) = header_data( 22 , 1 ); % UNITS
header_out( 234 +1) = header_data( 22 , 2 );  
header_out( 58 +1) = header_data( 22 , 3 );  
header_out( 59 +1) = header_data( 22 , 4 );  
header_out( 257 +1) = header_data( 23 , 1 ); % X1
header_out( 259 +1) = header_data( 23 , 2 );  
header_out( 261 +1) = header_data( 23 , 3 );  
header_out( 263 +1) = header_data( 23 , 4 );  
header_out( 258 +1) = header_data( 24 , 1 ); % XN
header_out( 260 +1) = header_data( 24 , 2 );  
header_out( 262 +1) = header_data( 24 , 3 );  
header_out( 264 +1) = header_data( 24 , 4 );  
header_out( 108 +1) = header_data( 25 , 1 ); % ZF
header_out( 437 +1) = header_data( 25 , 2 );  
header_out( 438 +1) = header_data( 25 , 3 );  
header_out( 439 +1) = header_data( 25 , 4 );  
header_out( 99 +1) = header_data( 26 , 1 ); % SIZE (not a separate component for y dim?)
header_out( 219 +1) = header_data( 26, 2);    % somehow number of slices for n > 2 D spectrum is number of points in y-dim
header_out( 15 +1) = header_data( 26 , 3 );  
header_out( 32 +1) = header_data( 26 , 4 ); 

if((nargin > 2)&&(num_dims > 0)) % need to reset number of dimensions
    header_out(9+1) = num_dims;
end