My software notes

January 20, 2006

sort pseudo3D data to single FIDs (for Varian)

Filed under: NMRPipe and NMRview — kpwu @ 6:35 pm

Post for memo, found from NMRPipe discussion forum

/* sort_pseudo3D.c

(from grad_sort_nd.c)

Written by Lewis E. Kay on July 5 1992
To carry out time-domain manipulations on Rance-type
HSQC data to get pure-absn lineshape

Modified by L.E.Kay on December 13 1992
To carry out time-domain manipulations on the ni2
dimension of a phase2,phase 3D data set to get
pure absn lineshape.

Modified by L.E.Kay on April 11 1993
To carry out time-domain manipulations on 4D data
sets acquired as d3,d2,d4, phase3,phase2,phase data sets.

Modified by L.E.Kay on May 4 1993
To carry out time-domain manipulations on 2D data sets

Modified by Patrik Lundstrom, 030301
To separate 2D datasets recorded interleaved
Some code modifications and comments

Modified by Patrik Lundstrom, 040915
To separate any pseudo 3D into the respective planes

Modified by Patrik Lundstrom, 041018
To cover case where data is pseudo 4D and the
spectrometer operator has screwed up and used


#define MAXDATA 4096
#define MAX_PLANE 256

int main(int argc, char *argv[])

void help(char *name);

FILE *infile, /* ptr to input file */
*outfile[MAX_PLANE]; /* ptr to output files */

char head[50], /* headers preceeding each data-set */

long data[MAXDATA]; /* the FIDs. each point in 4 bytes so we must have long

int i,j,jj,k,
mode, /* acq.order can be ‘arraypar phase’ or ‘phase arraypar’ */
planes2=1, /* needed for pseudo 4D if array=’par1,phase,par2′ */
inflag = 1,
outflag = 1,
modeflag = 1,
niflag = 1,
npflag = 1;

/* Read arguments */
/* ————– */
i = 1;
while (i MAXDATA) {
fprintf(stderr, “np > 4096. If you want to continue, you\n”);
fprintf(stderr, “have to change the code and recompile.\n”);
return 1;
if (planes*planes2 > MAX_PLANE) {
fprintf(stderr, “Number of planes (plane*plane2) must be less than %d!\n”,
fprintf(stderr, “If you need this no. planes, change code and recompile!\n”,
return 1;

/* Read and write global header */
/* —————————- */
fread(head, 1, 32, infile);
for (i=0; i
-plane -mode -ni -np
\n\n”, name);
fprintf(stderr, “This program will separate a pseudo 3D experiment\n”);
fprintf(stderr, “recorded with array=’parameter,phase’ (or opposite)\n”);
fprintf(stderr, “into regular 2D fids.\n”);
fprintf(stderr, “‘parameter’ might be a relaxation delay, cpmg\n”);
fprintf(stderr, “repetition rate, offset or whatever.\n”);
fprintf(stderr, “The output files will be called 0.fid, 1.fid…\n\n”);
fprintf(stderr, “Arguments:\n\n”),
fprintf(stderr, “-in\tinput file\n”);
fprintf(stderr, “-plane\tNo. interleaved experiments (in 3rd dim.)\n”);
fprintf(stderr, “-plane2\tNo. interleaved experiments (in 4th dim.)\n”);
fprintf(stderr, “-mode\t0 for array=’par,phase’; 1 for ‘phase,par’; -1
for ‘par1,phase,par2’\n”);
fprintf(stderr, “-ni\tNumber of increments (ni)\n”);
fprintf(stderr, “-np\tTotal number of acq. points: np (REAL +

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: