예제 #1
0
def test_doptimal():
    """ Test D-optimal optimization method """
    params = opt.ASLParams(f=50.0 / 6000)
    att_dist = opt.ATTDist(0.2, 2.1, 0.001, 0.3)
    scan = opt.ASLScan('var_multi_pCASL', duration=300, npld=6, readout=0.5)
    lims = opt.Limits(0.1, 3.0, 0.025)
    optimizer = opt.DOptimal(params, scan, att_dist, lims)

    output = optimizer.optimize()
    assert np.allclose(output.plds, [0.2, 0.7, 0.725, 1.55, 1.875, 2.075])
예제 #2
0
def test_loptimal_att():
    """ Test L-optimal optimization method for ATT """
    params = opt.ASLParams(f=50.0 / 6000)
    att_dist = opt.ATTDist(0.2, 2.1, 0.001, 0.3)
    scan = opt.ASLScan('var_multi_pCASL', duration=300, npld=6, readout=0.5)
    lims = opt.Limits(0.1, 3.0, 0.025)
    optimizer = opt.LOptimal([[0, 0], [0, 1]], params, scan, att_dist, lims)

    output = optimizer.optimize()
    assert np.allclose(output.plds, [0.1, 0.475, 0.7, 1.025, 1.725, 2.1])
예제 #3
0
def test_loptimal_cbf_multislice():
    """ Test L-optimal optimization method for CBF with 2D readout """
    params = opt.ASLParams(f=50.0 / 6000)
    att_dist = opt.ATTDist(0.2, 2.1, 0.001, 0.3)
    scan = opt.ASLScan('var_multi_pCASL',
                       duration=300,
                       npld=6,
                       readout=0.5,
                       nslices=10,
                       slicedt=0.0452)
    lims = opt.Limits(0.1, 3.0, 0.025)
    optimizer = opt.LOptimal([[1, 0], [0, 0]], params, scan, att_dist, lims)

    output = optimizer.optimize()
    assert np.allclose(output.plds, [0.1, 1.025, 1.625, 1.8, 1.95, 2.1])
예제 #4
0
def test_doptimal_multislice():
    """ Test D-optimal optimization method with 2D readout """
    params = opt.ASLParams(f=50.0 / 6000)
    att_dist = opt.ATTDist(0.2, 2.1, 0.001, 0.3)
    scan = opt.ASLScan('var_multi_pCASL',
                       duration=300,
                       npld=6,
                       readout=0.5,
                       nslices=10,
                       slicedt=0.0452)
    lims = opt.Limits(0.1, 3.0, 0.025)
    optimizer = opt.DOptimal(params, scan, att_dist, lims)

    output = optimizer.optimize()
    assert np.allclose(output.plds, [0.1, 0.575, 0.725, 1.4, 1.75, 2.025])
예제 #5
0
def main():
    """
    Simple example of optimizing the PLDs of a standard pCASL acquisition
    as per Buxton et al. MRM 1998
    """
    # Define the ASL parameters
    params = opt.ASLParams(f=50.0/6000)

    # ATT (BAT) distribution
    att_dist = opt.ATTDist(0.2, 2.1, 0.001, 0.3)

    # Details of the desired scan to optimize for
    scan = opt.ASLScan(opt.VAR_MULTI_PCASL, duration=300, npld=6, readout=0.5, slices=3, slicedt=0.0452)

    # PLD limits and step size to search over
    lims = opt.Limits(0.1, 3.0, 0.025)

    # Type of optimisation
    # Note: the output best_min_variance is not comparable between D-optimal and L-optimal
    #opttype = opt.LOptimal([[1, 0],  [0, 0]])
    optimizer = opt.DOptimal(params, scan, att_dist, lims)

    # Run the optimisation
    output = optimizer.optimize()

    # Plot optimized protocol
    plt.subplot(1, 2, 1)
    plt.title("CBFSD")
    plt.ylabel('SD (ml/100g/min)')
    plt.xlabel("ATT (s)")
    plt.ylim(0, 9)
    for slice_idx in range(scan.slices):
        plt.plot(att, np.squeeze(np.sqrt(np.abs(output.cov_optimized[slice_idx, :, 0, 0]))),
                 label="Optimised Protocol - slice %i" % slice_idx)
    plt.legend()

    plt.subplot(1, 2, 2)
    plt.title("BATSD")
    plt.ylabel("SD (s)")
    plt.xlabel("ATT (s)")
    plt.ylim(0, 0.25)
    for slice_idx in range(scan.slices):
        plt.plot(att, np.squeeze(np.sqrt(np.abs(output.cov_optimized[slice_idx, :, 1, 1]))),
                 label="Optimised Protocol - slice %i" % slice_idx)
    plt.legend()

    plt.show()