clear
fileList = dir('*.DTA');
d30 = [60 40 28 20];
for i = 1:length(fileList)
    filename = fileList(i).name;
    [t, spc] = eprload(filename);
    spc = real(spc);
    N = numel(t);
    p0 = 16;
    p2 = 32;
    d2 = 96;
    d3 = 240;
    d2 = d2+p2;
    d3 = d3-d2;
    Tnew = 1:N;
    for j = 1:N
        Tnew(j) = d2+d3+0.5*p0-p2;
        r = j*d30(i);
        d3 = d3+r;
    end
    B = [Tnew' spc];
    filename1 = [filename(1:end-4) '.tsv'];
    fileID = fopen(filename1,'w');
    fprintf(fileID,'%1s\t%15s\n','T','Echo Intensity');
    fprintf(fileID,'%2s\t%2s\n','ns','');
    fprintf(fileID,'%9s\t%3s\n','DFB1 DTOL', T);
    fclose(fileID);
    dlmwrite(filename1, B,'delimiter','\t','-append');
end