Пример #1
0
    def createSequence():
        # Set shimming
        mri.iniSequence(expt, 20, shimming)
        
        for repeIndex in range(nRepetitions):
            # Initialize time
            tEx = 20e3+repetitionTime*repeIndex
            
            # Excitation pulse
            t0 = tEx-hw.blkTime-rfExTime/2
            mri.rfRecPulse(expt, t0, rfExTime, rfExAmp, 0)
            
#            # Rx gating
#            t0 = tEx+rfExTime/2+hw.deadTime
#            mri.rxGate(expt, t0, acqTime)
            
            # Crusher gradient
            t0 = tEx+echoTime/2-crusherTime/2-gradRiseTime-hw.gradDelay-43
            mri.gradTrap(expt, t0, gradRiseTime, crusherTime, 0.005, gSteps, axes[0], shimming)
            mri.gradTrap(expt, t0, gradRiseTime, crusherTime, 0.005, gSteps, axes[1], shimming)
            mri.gradTrap(expt, t0, gradRiseTime, crusherTime, 0.005, gSteps, axes[2], shimming)
            
            # Refocusing pulse
            t0 = tEx+echoTime/2-rfReTime/2-hw.blkTime
            mri.rfRecPulse(expt, t0, rfReTime, rfReAmp, np.pi/2)
            
            # Rx gating
            t0 = tEx+echoTime-acqTime/2
            mri.rxGate(expt, t0, acqTime)
        
        # End sequence
        mri.endSequence(expt, scanTime)
Пример #2
0
    def createSequence():
        # Set shimming
        mri.iniSequence(expt, 20, shimming)

        # Initialize time
        tEx = 20e3

        # Excitation pulse
        t0 = tEx - hw.blkTime - rfExTime[indexExTime] / 2
        if pulseShape == 'Rec':
            mri.rfRecPulse(expt, t0, rfExTime[indexExTime], rfExAmp,
                           rfExPhase * np.pi / 180)
        elif pulseShape == 'Sinc':
            mri.rfSincPulse(expt, t0, rfExTime[indexExTime], 7, rfExAmp,
                            rfExPhase * np.pi / 180)

        # First acquisition
        t0 = tEx + rfExTime[indexExTime] / 2 + deadTime
        mri.rxGate(expt, t0, tAcq)

        # Refocusing pulse
        t0 = tEx + tEcho / 2 - rfReTime[indexExTime] / 2 - hw.blkTime
        if pulseShape == 'Rec':
            mri.rfRecPulse(expt, t0, rfReTime[indexExTime], rfReAmp, np.pi / 2)
        elif pulseShape == 'Sinc':
            mri.rfSincPulse(expt, t0, rfReTime[indexExTime], 7, rfReAmp,
                            np.pi / 2)

        # Second acquisition
        t0 = tEx + tEcho - tAcq / 2
        mri.rxGate(expt, t0, tAcq)

        # End sequence
        mri.endSequence(expt, tRepetition)
Пример #3
0
 def createSequence(shimming):
     # Set shimming
     mri.iniSequence(expt, 20, shimming)
     
     # Initialize time
     tEx = 20e3
         
     # Excitation pulse
     t0 = tEx-hw.blkTime-rfExTime/2
     if pulseShape=='Rec':
         mri.rfRecPulse(expt, t0, rfExTime, rfExAmp, 0)
     elif pulseShape=='Sinc':
         mri.rfSincPulse(expt, t0, rfExTime, 7, rfExAmp, 0)
     
     # Refocusing pulse
     t0 = tEx+echoTime/2-rfReTime/2-hw.blkTime
     if pulseShape=='Rec':
         mri.rfRecPulse(expt, t0, rfReTime, rfReAmp, np.pi/2)
     elif pulseShape=='Sinc':
         mri.rfSincPulse(expt, t0, rfReTime, 7, rfReAmp, np.pi/2)
     
     # Acquisition window
     t0 = tEx+echoTime-acqTime/2
     mri.rxGate(expt, t0, acqTime)
     
     # End sequence
     mri.endSequence(expt, repetitionTime)
Пример #4
0
    def createSequence():
        # Set shimming
        mri.iniSequence(expt, 20, shimming)
        t0 = 20
        mri.rfRecPulse(expt, t0, rfExTime, rfExAmp, 0)

        # End sequence
        mri.endSequence(expt, rfExTime + 40)
Пример #5
0
    def createSequence():
        # Set shimming
        mri.iniSequence(expt, 20, shimming)

        for repeIndex in range(nRepetitions):
            # Initialize time
            tEx = 20e3 + np.max(tSat) + repetitionTime * repeIndex

            # Inversion time for current iteration
            inversionTime = tSat[repeIndex]

            # Crusher gradient for inversion rf pulse
            #            t0 = tEx-inversionTime-crusherTime/2-gradRiseTime-hw.gradDelay-50
            #            mri.gradTrap(expt, t0, gradRiseTime, crusherTime, 0.005, gSteps, axes[0], shimming)
            #            mri.gradTrap(expt, t0, gradRiseTime, crusherTime, 0.005, gSteps, axes[1], shimming)
            #            mri.gradTrap(expt, t0, gradRiseTime, crusherTime, 0.005, gSteps, axes[2], shimming)

            # Saturation pulse
            t0 = tEx - inversionTime - hw.blkTime - rfReTime / 2
            mri.rfRecPulse(expt, t0, rfReTime, rfReAmp, 0)

            # Spoiler gradients to destroy residual transversal signal detected for ultrashort inversion times
            #            mri.gradTrap(expt, t0+hw.blkTime+rfReTime, gradRiseTime, inversionTime*0.5, 0.005, gSteps, axes[0], shimming)
            #            mri.gradTrap(expt, t0+hw.blkTime+rfReTime, gradRiseTime, inversionTime*0.5, 0.005, gSteps, axes[1], shimming)
            #            mri.gradTrap(expt, t0+hw.blkTime+rfReTime, gradRiseTime, inversionTime*0.5, 0.005, gSteps, axes[2], shimming)

            # Excitation pulse
            t0 = tEx - hw.blkTime - rfExTime / 2
            mri.rfRecPulse(expt, t0, rfExTime, rfExAmp, 0)

            #            # Rx gating
            #            t0 = tEx+rfExTime/2+hw.deadTime
            #            mri.rxGate(expt, t0, acqTime)

            # Crusher gradient
            t0 = tEx + echoTime / 2 - crusherTime / 2 - gradRiseTime - hw.gradDelay - 50
            mri.gradTrap(expt, t0, gradRiseTime, crusherTime, 0.005, gSteps,
                         axes[0], shimming)
            mri.gradTrap(expt, t0, gradRiseTime, crusherTime, 0.005, gSteps,
                         axes[1], shimming)
            mri.gradTrap(expt, t0, gradRiseTime, crusherTime, 0.005, gSteps,
                         axes[2], shimming)

            # Refocusing pulse
            t0 = tEx + echoTime / 2 - rfReTime / 2 - hw.blkTime
            mri.rfRecPulse(expt, t0, rfReTime, rfReAmp, np.pi / 2)

            # Rx gating
            t0 = tEx + echoTime - acqTime / 2
            mri.rxGate(expt, t0, acqTime)

        # End sequence
        mri.endSequence(expt, scanTime)
Пример #6
0
    def createSequence():
        phIndex = 0
        nRepetitions = int(nPH / etl + dummyPulses)
        scanTime = 20e3 + nRepetitions * repetitionTime
        rawData['batchTime'] = scanTime * 1e-6
        if rdGradTime == 0:  # Check if readout gradient is dc or pulsed
            dc = True
        else:
            dc = False
        # Set shimming
        mri.iniSequence(expt, 20, shimming)
        for repeIndex in range(nRepetitions):
            # Initialize time
            tEx = 20e3 + repetitionTime * repeIndex + inversionTime + preExTime

            # First I do a noise measurement.
            if repeIndex == 0:
                t0 = tEx - preExTime - inversionTime - 4 * acqTime
                mri.rxGate(expt, t0, acqTime + 2 * addRdPoints / BW)

            # Pre-excitation pulse
            if repeIndex >= dummyPulses and preExTime != 0:
                t0 = tEx - preExTime - inversionTime - rfExTime / 2 - hw.blkTime
                mri.rfRecPulse(expt, t0, rfExTime, rfExAmp / 90 * 90, 0)
                mri.gradTrap(expt, t0 + hw.blkTime + rfReTime, gradRiseTime,
                             preExTime * 0.5, -0.005, gSteps, axes[0],
                             shimming)
                mri.gradTrap(expt, t0 + hw.blkTime + rfReTime, gradRiseTime,
                             preExTime * 0.5, -0.005, gSteps, axes[1],
                             shimming)
                mri.gradTrap(expt, t0 + hw.blkTime + rfReTime, gradRiseTime,
                             preExTime * 0.5, -0.005, gSteps, axes[2],
                             shimming)

            # Inversion pulse
            if repeIndex >= dummyPulses and inversionTime != 0:
                t0 = tEx - inversionTime - rfReTime / 2 - hw.blkTime
                mri.rfRecPulse(expt, t0, rfReTime, rfReAmp / 180 * 180, 0)
                mri.gradTrap(expt, t0 + hw.blkTime + rfReTime, gradRiseTime,
                             inversionTime * 0.5, 0.005, gSteps, axes[0],
                             shimming)
                mri.gradTrap(expt, t0 + hw.blkTime + rfReTime, gradRiseTime,
                             inversionTime * 0.5, 0.005, gSteps, axes[1],
                             shimming)
                mri.gradTrap(expt, t0 + hw.blkTime + rfReTime, gradRiseTime,
                             inversionTime * 0.5, 0.005, gSteps, axes[2],
                             shimming)

            # DC gradient if desired
            if (repeIndex == 0 or repeIndex >= dummyPulses) and dc == True:
                t0 = tEx - 10e3
                mri.gradTrap(expt, t0, gradRiseTime,
                             10e3 + echoSpacing * (etl + 1), rdGradAmplitude,
                             gSteps, axes[0], shimming)

            # Excitation pulse
            t0 = tEx - hw.blkTime - rfExTime / 2
            mri.rfRecPulse(expt, t0, rfExTime, rfExAmp, drfPhase)

            # Dephasing readout
            t0 = tEx + rfExTime / 2 - hw.gradDelay
            if (repeIndex == 0 or repeIndex >= dummyPulses) and dc == False:
                mri.gradTrap(expt, t0, gradRiseTime, rdDephTime,
                             rdDephAmplitude * rdPreemphasis, gSteps, axes[0],
                             shimming)

            # Echo train
            for echoIndex in range(etl):
                tEcho = tEx + echoSpacing * (echoIndex + 1)

                # Refocusing pulse
                t0 = tEcho - echoSpacing / 2 - rfReTime / 2 - hw.blkTime
                mri.rfRecPulse(expt, t0, rfReTime, rfReAmp,
                               drfPhase + np.pi / 2)

                # Dephasing phase and slice gradients
                if repeIndex >= dummyPulses:  # This is to account for dummy pulses
                    t0 = tEcho - echoSpacing / 2 + rfReTime / 2 - hw.gradDelay
                    mri.gradTrap(expt, t0, gradRiseTime, phGradTime,
                                 phGradients[phIndex], gSteps, axes[1],
                                 shimming)
                    mri.gradTrap(expt, t0, gradRiseTime, phGradTime,
                                 slGradients[slIndex], gSteps, axes[2],
                                 shimming)

                # Readout gradient
                if (repeIndex == 0 or repeIndex >= dummyPulses
                    ) and dc == False:  # This is to account for dummy pulses
                    t0 = tEcho - rdGradTime / 2 - gradRiseTime - hw.gradDelay
                    mri.gradTrap(expt, t0, gradRiseTime, rdGradTime,
                                 rdGradAmplitude, gSteps, axes[0], shimming)

                # Rx gate
                if (repeIndex == 0 or repeIndex >= dummyPulses):
                    t0 = tEcho - acqTime / 2 - addRdPoints / BW
                    mri.rxGate(expt, t0, acqTime + 2 * addRdPoints / BW)

                # Rephasing phase and slice gradients
                t0 = tEcho + acqTime / 2 + addRdPoints / BW - hw.gradDelay
                if (echoIndex < etl - 1 and repeIndex >= dummyPulses):
                    mri.gradTrap(expt, t0, gradRiseTime, phGradTime,
                                 -phGradients[phIndex], gSteps, axes[1],
                                 shimming)
                    mri.gradTrap(expt, t0, gradRiseTime, phGradTime,
                                 -slGradients[slIndex], gSteps, axes[2],
                                 shimming)
                elif (echoIndex == etl - 1 and repeIndex >= dummyPulses):
                    mri.gradTrap(expt, t0, gradRiseTime, phGradTime,
                                 +phGradients[phIndex], gSteps, axes[1],
                                 shimming)
                    mri.gradTrap(expt, t0, gradRiseTime, phGradTime,
                                 +slGradients[slIndex], gSteps, axes[2],
                                 shimming)

                # Update the phase and slice gradient
                if repeIndex >= dummyPulses:
                    phIndex += 1

            if repeIndex == nRepetitions - 1:
                mri.endSequence(expt, scanTime)
Пример #7
0
    def createSequence():
        nRepetitions = int(1 + dummyPulses)
        scanTime = 20e3 + nRepetitions * repetitionTime
        rawData['scanTime'] = scanTime * 1e-6
        print('Scan Time = ', (scanTime * 1e-6), 's')
        if rdGradTime == 0:  # Check if readout gradient is dc or pulsed
            dc = True
        else:
            dc = False

        # Set shimming
        mri.iniSequence(expt, 20, shimming)
        for repeIndex in range(nRepetitions):
            # Initialize time
            tEx = 20e3 + repetitionTime * repeIndex + inversionTime

            # Inversion pulse
            if repeIndex >= dummyPulses and inversionTime != 0:
                t0 = tEx - inversionTime - rfReTime / 2 - hw.blkTime
                mri.rfRecPulse(expt, t0, rfReTime, rfReAmp / 180 * 180, 0)
                mri.gradTrap(expt, t0 + hw.blkTime + rfReTime, gradRiseTime,
                             inversionTime * 0.5, 0.005, gSteps, axes[0],
                             shimming)
                mri.gradTrap(expt, t0 + hw.blkTime + rfReTime, gradRiseTime,
                             inversionTime * 0.5, 0.005, gSteps, axes[1],
                             shimming)
                mri.gradTrap(expt, t0 + hw.blkTime + rfReTime, gradRiseTime,
                             inversionTime * 0.5, 0.005, gSteps, axes[2],
                             shimming)

            # DC radout gradient if desired
            if (repeIndex == 0 or repeIndex >= dummyPulses) and dc == True:
                t0 = tEx - rfExTime / 2 - gradRiseTime - hw.gradDelay
                mri.gradTrap(expt, t0, echoSpacing * (nPH + 1),
                             rdGradAmplitude, axes[0])

            # Slice selection gradient dephasing
            if (slThickness != 0 and repeIndex >= dummyPulses):
                t0 = tEx - rfExTime / 2 - gradRiseTime - hw.gradDelay
                mri.gradTrap(expt, t0, gradRiseTime, rfExTime, ssGradAmplitude,
                             gSteps, axes[2], shimming)

            # Excitation pulse
            t0 = tEx - hw.blkTime - rfExTime / 2
            if rfEnvelope == 'Rec':
                mri.rfRecPulse(expt, t0, rfExTime, rfExAmp,
                               drfPhase * np.pi / 180)
            elif rfEnvelope == 'Sinc':
                mri.rfSincPulse(expt, t0, rfExTime, rfSincLobes, rfExAmp,
                                drfPhase * np.pi / 180)

            # Slice selection gradient rephasing
            if (slThickness != 0 and repeIndex >= dummyPulses):
                t0 = tEx + rfExTime / 2 + gradRiseTime - hw.gradDelay
                if rfEnvelope == 'Rec':
                    mri.gradTrap(expt, t0, gradRiseTime, 0.,
                                 -ssGradAmplitude * ssPreemphasis, gSteps,
                                 axes[2], shimming)
                elif rfEnvelope == 'Sinc':
                    mri.gradTrap(expt, t0, gradRiseTime, ssDephGradTime,
                                 -ssGradAmplitude * ssPreemphasis, gSteps,
                                 axes[2], shimming)

            # Dephasing readout
            t0 = tEx + rfExTime / 2 - hw.gradDelay
            if (repeIndex == 0 or repeIndex >= dummyPulses) and dc == False:
                mri.gradTrap(expt, t0, gradRiseTime, rdDephTime,
                             rdDephAmplitude * rdPreemphasis, gSteps, axes[0],
                             shimming)

            # Echo train
            for echoIndex in range(nPH):
                tEcho = tEx + echoSpacing * (echoIndex + 1)

                # Crusher gradient
                if repeIndex >= dummyPulses:
                    t0 = tEcho - echoSpacing / 2 - rfReTime / 2 - gradRiseTime - hw.gradDelay - crusherDelay
                    mri.gradTrap(expt, t0, gradRiseTime,
                                 rfReTime + 2 * crusherDelay, ssGradAmplitude,
                                 gSteps, axes[2], shimming)

                # Refocusing pulse
                t0 = tEcho - echoSpacing / 2 - rfReTime / 2 - hw.blkTime
                if rfEnvelope == 'Rec':
                    mri.rfRecPulse(expt, t0, rfReTime, rfReAmp,
                                   np.pi / 2 + drfPhase * np.pi / 180)
                if rfEnvelope == 'Sinc':
                    mri.rfSincPulse(expt, t0, rfReTime, rfSincLobes, rfReAmp,
                                    np.pi / 2 + drfPhase * np.pi / 180)

                # Dephasing phase gradient
                t0 = tEcho - echoSpacing / 2 + rfReTime / 2 - hw.gradDelay
                if repeIndex >= dummyPulses:  # This is to account for dummy pulses
                    mri.gradTrap(expt, t0, gradRiseTime, phGradTime,
                                 phGradients[echoIndex], gSteps, axes[1],
                                 shimming)

                # Readout gradient
                t0 = tEcho - rdGradTime / 2 - gradRiseTime - hw.gradDelay
                if (repeIndex == 0 or repeIndex >= dummyPulses
                    ) and dc == False:  # This is to account for dummy pulses
                    mri.gradTrap(expt, t0, gradRiseTime, rdGradTime,
                                 rdGradAmplitude, gSteps, axes[0], shimming)

                # Rx gate
                if (repeIndex == 0 or repeIndex >= dummyPulses):
                    t0 = tEcho - acqTime / 2 - addRdPoints / BW
                    mri.rxGate(expt, t0, acqTime + 2 * addRdPoints / BW)

                # Rephasing phase and slice gradients
                t0 = tEcho + acqTime / 2 + addRdPoints / BW - hw.gradDelay
                if (echoIndex < nPH - 1 and repeIndex >= dummyPulses):
                    mri.gradTrap(expt, t0, gradRiseTime, phGradTime,
                                 -phGradients[echoIndex], gSteps, axes[1],
                                 shimming)
                elif (echoIndex == nPH - 1 and repeIndex >= dummyPulses):
                    mri.gradTrap(expt, t0, gradRiseTime, phGradTime,
                                 +phGradients[echoIndex], gSteps, axes[1],
                                 shimming)

            if repeIndex == nRepetitions - 1:
                mri.endSequence(expt, scanTime)
    def createSequence(phIndex=0, slIndex=0, repeIndexGlobal=0, rewrite=True):
        repeIndex = 0
        if rdGradTime == 0:  # Check if readout gradient is dc or pulsed
            dc = True
        else:
            dc = False
        acqPoints = 0
        orders = 0
        # Check in case of dummy pulse fill the cache
        if (dummyPulses > 0 and etl * nRD * 2 > hw.maxRdPoints) or (
                dummyPulses == 0 and etl * nRD > hw.maxRdPoints):
            print('ERROR: Too many acquired points.')
            return ()
        # Set shimming
        mri.iniSequence(expt, 20, shimming, rewrite=rewrite)
        while acqPoints + etl * nRD <= hw.maxRdPoints and orders <= hw.maxOrders and repeIndexGlobal < nRepetitions:
            # Initialize time
            tEx = 20e3 + repetitionTime * repeIndex + inversionTime + preExTime

            # First I do a noise measurement.
            if repeIndex == 0:
                t0 = tEx - preExTime - inversionTime - 4 * acqTime
                mri.rxGate(expt, t0, acqTime + 2 * addRdPoints / BW)

            # Pre-excitation pulse
            if repeIndex >= dummyPulses and preExTime != 0:
                t0 = tEx - preExTime - inversionTime - rfExTime / 2 - hw.blkTime
                mri.rfRecPulse(expt, t0, rfExTime, rfExAmp / 90 * 90, 0)
                mri.gradTrapAmplitude(expt, t0 + hw.blkTime + rfReTime, -0.005,
                                      preExTime * 0.5, axes[0], shimming,
                                      orders)
                mri.gradTrapAmplitude(expt, t0 + hw.blkTime + rfReTime, -0.005,
                                      preExTime * 0.5, axes[1], shimming,
                                      orders)
                mri.gradTrapAmplitude(expt, t0 + hw.blkTime + rfReTime, -0.005,
                                      preExTime * 0.5, axes[2], shimming,
                                      orders)

            # Inversion pulse
            if repeIndex >= dummyPulses and inversionTime != 0:
                t0 = tEx - inversionTime - rfReTime / 2 - hw.blkTime
                mri.rfPulse(expt, t0, rfReTime, rfReAmp / 180 * 180, 0)
                mri.gradTrapAmplitude(expt, t0 + hw.blkTime + rfReTime, 0.005,
                                      inversionTime * 0.5, axes[0], shimming,
                                      orders)
                mri.gradTrapAmplitude(expt, t0 + hw.blkTime + rfReTime, 0.005,
                                      inversionTime * 0.5, axes[1], shimming,
                                      orders)
                mri.gradTrapAmplitude(expt, t0 + hw.blkTime + rfReTime, 0.005,
                                      inversionTime * 0.5, axes[2], shimming,
                                      orders)

            # DC gradient if desired
            if (repeIndex == 0 or repeIndex >= dummyPulses) and dc == True:
                t0 = tEx - 10e3
                mri.gradTrapAmplitude(expt, t0, rdGradAmplitude,
                                      10e3 + echoSpacing * (etl + 1), axes[0],
                                      shimming, orders)

            # Excitation pulse
            t0 = tEx - hw.blkTime - rfExTime / 2

            mri.rfRecPulse(expt, t0, rfExTime, rfExAmp, drfPhase)

            # Dephasing readout
            if (repeIndex == 0 or repeIndex >= dummyPulses) and dc == False:
                t0 = tEx + rfExTime / 2 - hw.gradDelay
                mri.gradTrapAmplitude(expt, t0,
                                      rdDephAmplitude * rdPreemphasis,
                                      rdDephTime, axes[0], shimming, orders)

            # Echo train
            for echoIndex in range(etl):
                tEcho = tEx + echoSpacing * (echoIndex + 1)

                # Refocusing pulse
                t0 = tEcho - echoSpacing / 2 - rfReTime / 2 - hw.blkTime
                mri.rfRecPulse(expt, t0, rfReTime, rfReAmp,
                               drfPhase + np.pi / 2)

                # Dephasing phase and slice gradients
                if repeIndex >= dummyPulses:  # This is to account for dummy pulses
                    t0 = tEcho - echoSpacing / 2 + rfReTime / 2 - hw.gradDelay
                    mri.gradTrapAmplitude(expt, t0, phGradients[phIndex],
                                          phGradTime, axes[1], shimming,
                                          orders)
                    mri.gradTrapAmplitude(expt, t0, slGradients[slIndex],
                                          phGradTime, axes[2], shimming,
                                          orders)

                # Readout gradient
                if (repeIndex == 0 or repeIndex >= dummyPulses
                    ) and dc == False:  # This is to account for dummy pulses
                    t0 = tEcho - rdGradTime / 2 - gRiseTimeRd - hw.gradDelay
                    mri.gradTrapAmplitude(expt, t0, rdGradAmplitude,
                                          rdGradTime + 2 * gRiseTimeRd,
                                          axes[0], shimming, orders)

                # Rx gate
                if (repeIndex == 0 or repeIndex >= dummyPulses):
                    t0 = tEcho - acqTime / 2 - addRdPoints / BW
                    mri.rxGate(expt, t0, acqTime + 2 * addRdPoints / BW)
                    acqPoints += nRD

                # Rephasing phase and slice gradients
                t0 = tEcho + acqTime / 2 + addRdPoints / BW - hw.gradDelay
                if (echoIndex < etl - 1 and repeIndex >= dummyPulses):
                    mri.gradTrapAmplitude(expt, t0, -phGradients[phIndex],
                                          phGradTime, axes[1], shimming,
                                          orders)
                    mri.gradTrapAmplitude(expt, t0, -slGradients[slIndex],
                                          phGradTime, axes[2], shimming,
                                          orders)
                elif (echoIndex == etl - 1 and repeIndex >= dummyPulses):
                    mri.gradTrapAmplitude(expt, t0, phGradients[phIndex],
                                          phGradTime, axes[1], shimming,
                                          orders)
                    mri.gradTrapAmplitude(expt, t0, slGradients[slIndex],
                                          phGradTime, axes[2], shimming,
                                          orders)

                # Update the phase and slice gradient
                if repeIndex >= dummyPulses:
                    if phIndex == nPH - 1:
                        phIndex = 0
                        slIndex += 1
                    else:
                        phIndex += 1
            if repeIndex >= dummyPulses:
                repeIndexGlobal += 1  # Update the global repeIndex
            repeIndex += 1  # Update the repeIndex after the ETL

        # Turn off the gradients after the end of the batch
        mri.endSequence(expt, repeIndex * repetitionTime)

        # Return the output variables
        return (phIndex, slIndex, repeIndexGlobal)
Пример #9
0
    def createSequence(phIndex=0, slIndex=0, repeIndexGlobal=0, rewrite=True):
        repeIndex = 0
        acqPoints = 0
        orders = 0

        # check in case of dummy pulse filling the cache
        if (dummyPulses > 0 and nRD * 3 > hw.maxRdPoints) or (
                dummyPulses == 0 and nRD * 2 > hw.maxRdPoints):
            print(
                'ERROR: Too many acquired points or orders to the red pitaya.')
            return ()

        # Set shimming
        mri.iniSequence(expt, 20, shimming, rewrite=rewrite)

        # Run sequence batch
        while acqPoints + nRD <= hw.maxRdPoints and orders <= hw.maxOrders and repeIndexGlobal < nRepetitions:
            # Initialize time
            tEx = 20e3 + repetitionTime * repeIndex

            # First I do a noise measurement
            if repeIndex == 0:
                t0 = tEx - 4 * acqTime
                mri.rxGate(expt, t0, acqTime + 2 * addRdPoints / BW)
                acqPoints += nRD

            # Excitation pulse
            t0 = tEx - hw.blkTime - rfExTime / 2
            mri.rfRecPulse(expt, t0, rfExTime, rfExAmp, 0.)

            # Dephasing readout, phase and slice
            if (repeIndex == 0 or repeIndex >= dummyPulses):
                t0 = tEx + rfExTime / 2 - hw.gradDelay
                mri.gradTrap(expt, t0, gradRiseTime, dephGradTime,
                             rdDephAmplitude, gSteps, axes[0], shimming)
                orders = orders + gSteps * 2
            if repeIndex >= dummyPulses:
                t0 = tEx + rfExTime / 2 - hw.gradDelay
                mri.gradTrap(expt, t0, gradRiseTime, dephGradTime,
                             phGradients[phIndex], gSteps, axes[1], shimming)
                mri.gradTrap(expt, t0, gradRiseTime, dephGradTime,
                             slGradients[slIndex], gSteps, axes[2], shimming)
                orders = orders + gSteps * 4

            # Rephasing readout gradient
            if (repeIndex == 0 or repeIndex >= dummyPulses):
                t0 = tEx + echoTime - rdGradTime / 2 - gradRiseTime - hw.gradDelay
                mri.gradTrap(expt, t0, gradRiseTime, rdGradTime,
                             rdGradAmplitude, gSteps, axes[0], shimming)
                orders = orders + gSteps * 2

            # Rx gate
            if (repeIndex == 0 or repeIndex >= dummyPulses):
                t0 = tEx + echoTime - acqTime / 2 - addRdPoints / BW
                mri.rxGate(expt, t0, acqTime + 2 * addRdPoints / BW)
                acqPoints += nRD

            # Spoiler
            if spoiler:
                t0 = tEx + echoTime + rdGradTime / 2 + gradRiseTime - hw.gradDelay
                mri.gradTrap(expt, t0, gradRiseTime, dephGradTime,
                             -rdDephAmplitude, gSteps, axes[0], shimming)
                orders = orders + gSteps * 2

            # Update the phase and slice gradient
            if repeIndex >= dummyPulses:
                if phIndex == nPH - 1:
                    phIndex = 0
                    slIndex += 1
                else:
                    phIndex += 1

            if repeIndex >= dummyPulses:
                repeIndexGlobal += 1  # Update the global repeIndex
            repeIndex += 1  # Update the repeIndex after the ETL

        # Turn off the gradients after the end of the batch
        mri.endSequence(expt, repeIndex * repetitionTime)

        # Return the output variables
        return (phIndex, slIndex, repeIndexGlobal, acqPoints)