/*** ^^A -*-C++-*- **********************************************/ /* program name dumbo 01.12.2003 */ /****************************************************************/ /* Short Description : */ /* Program to generate shape file for DUMBO */ /****************************************************************/ /* Keywords : homonuclear decoupling, phase modulation */ /* DUMBO, eDUMBO-22 */ /****************************************************************/ /* Description/Usage: */ /* This program calculates the phase modulation using */ /* 100 kHz RF field for either a 32 us DUMBO pulse */ /* (answer d when prompted for) or a 32 us eDUMBO-22 pulse */ /* (answer e when prompted for). The program needs 3 more */ /* inputs: */ /* 1. the number of cycles (default 1) to repeat the */ /* modulation (the pulse length multiplies correspondingly)*/ /* 2. the number of steps per cycle (32 or 64), which */ /* defines the timing resolution to 1 us or 0.5 us. */ /* More steps for finer resolution are possible. */ /* 3. Added angle to define the relative phase of the */ /* modulation. Integer values >= 0 and < 360 can be used */ /* The following parameters are set by the program: */ /* in case of DUMBO */ /* spnam1 = dumbo_X+Y where X is number of cyles and */ /* Y is the added angle */ /* p10 = 32us * X, where X = number of cycles */ /* in case of eDUMBO-22 */ /* spnam2 = edumbo22_X+Y where X is number of cyles */ /* and Y is the added angle */ /* p20 = 32us * X, where X = number of cycles */ /* Corresponding pulse programs: */ /* dumbo1d, dumbo2d, dumboct2d, dumbodq2d */ /****************************************************************/ /* Author(s) : */ /* Name : Stefan Steuernagel */ /* Organisation : Bruker BioSpin GmbH */ /* Email : stefan.steuernagel@bruker-biospin.de */ /****************************************************************/ /* Name Date Modification: */ /* ste 031201 created */ /****************************************************************/ /* $Id: dumbo,v 1.2 2007/02/02 15:51:59 wem Exp $ */ AUERR = dumbo(curdat); QUIT #include int dumbo(const char* curdat) { static const double a0[] = {11.7, 6.804, 8.568, 3.852, 1.368, -0.468}; static const double b0[] = {47.16, 70.092, 6.984, 40.464, -16.416, 31.284}; static const double a1[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; static const double b1[] = {73.8, 82.44, 12.6, 55.44, -6.84, 13.32}; char outputfile[PATH_MAX], fname[64]; int steps = 64, cycles = 1, ang = 0; int i, j; double scale; double* phi; double* wbuf; double* wp; const double* ap; const double* bp; if (i_argc >= 3) fname[0] = i_argv[2][0]; else { strcpy(fname, "d"); GETSTRING("Create DUMBO (d) or eDUMBO-22 (e) shape?:", fname) } if (fname[0] != 'e' && fname[0] != 'd') STOPMSG("invalid shape value") if (i_argc >= 4) cycles = atoi(i_argv[3]); else GETINT("Enter number of cycles:", cycles) if (cycles <= 0) STOPMSG("invalid cycle value") if (i_argc >= 5) steps = atoi(i_argv[4]); else GETINT("Enter number of steps per cycle:", steps) if (steps <= 0) STOPMSG("invalid steps value") if (i_argc >= 6) ang = atoi(i_argv[5]); else GETINT("Added angle:", ang) if (ang < 0 || ang >= 360) STOPMSG("invalid angle value") /* generate shaped pulse filename */ if (fname[0] == 'd') { ap = a0; bp = b0; sprintf(fname, "dumbo_%d+%d", cycles, ang); STOREPAR("SPNAM1", fname) STOREPAR("P 10", 32.0 * cycles) STOREPAR("ZGOPTNS", "-Ddumbo") } else { ap = a1; bp = b1; sprintf(fname, "edumbo22_%d+%d", cycles, ang); STOREPAR("SPNAM2", fname) STOREPAR("P 20", 32.0 * cycles); STOREPAR("ZGOPTNS", "-Ddumbo"); } if (getParfileDirForWrite(fname, SHAPE_DIRS, outputfile) < 0) { Proc_err(DEF_ERR_OPT, "%s: %s", fname, outputfile); return -1; } /* allocate memory buffer for amplitude and phase */ wp = wbuf = (double*)malloc((2 * cycles + 1) * steps * sizeof(double)); if (wbuf == 0) { Proc_err(DEF_ERR_OPT, "Not enough buffer space"); return -1; } /* calculate phase values for shape */ phi = wbuf + 2 * cycles * steps; scale = (4 * M_PI) / steps; for (j = 0; j < steps / 2; j++) { double y = j * scale; double x = ang; for (i = 0; i < (int)(sizeof(a0) / sizeof(a0[1])); i++) x += ap[i] * cos((i+1) * y) + bp[i] * sin((i+1) * y); while (x < 0) x += 360; while (x > 360) x -= 360; phi[j] = x; if (x > 180) x -= 180; else x += 180; phi[steps-1-j] = x; } for (j = 0; j < cycles * steps; j++) *wp++ = 100.0; for (j = 0; j < cycles; j++) for (i = 0; i < steps; i++) *wp++ = phi[i]; /* store phase values in shaped pulse file */ if (writeShapeC(outputfile, wbuf, cycles * steps, 1, 0, 0) == 0) return -1; free(wbuf); sprintf(outputfile, "%d points in waveform file stored!", cycles * steps); Show_status(outputfile); Show_meta(SM_PROCP); return 0; }