/**
***************************************************
* \page ug_example_nlg %Example 2: Position Encoding with Nonlinear Fields

This section provides an example on using nonlinear gradients with JEMRIS.

\n
First, create in Matlab a 1-D sample consisting of a repeated step function:

\code
nb=16;ns=32;a=ones(ns,1);b=zeros(ns,1);c=[];
for i=1:nb
	c=[c;a;b];
end
M0=c; T1=100*c; T2=100*c; T2s=T2; DB=0*c;
RES=1; OFFSET=[0 0 0];
save blocked1D M0 T1 T2 T2s DB RES OFFSET
\endcode

Then, load the mat-file "blocked1D" from the simulation GUI ("user defined sample").

Next, a simple 1D gradient echo imaging sequence looks like this:

\code
<?xml version="1.0" encoding="utf-8"?>
<Parameters FOVx="1024" FOVy="1" FOVz="1" Name="P" Nx="1024" Ny="1" Nz="1" TD="25" TE="5" TR="500">
   <ConcatSequence Name="C">
      <ATOMICSEQUENCE Name="A1">
         <HARDRFPULSE Axis="RF" Duration="0.1" FlipAngle="90" Name="P1" Observe="C,Counter/C,Repetitions/P,FOVx"/>
      </ATOMICSEQUENCE>
      <ATOMICSEQUENCE Name="A2">
         <TRAPGRADPULSE Axis="GX" FlatTopArea="-a1/2" FlatTopTime="4" Name="P2" Observe="P3,Area"/>
      </ATOMICSEQUENCE>
      <ATOMICSEQUENCE Name="A3">
         <TRAPGRADPULSE ADCs="a2" Axis="GX" FlatTopArea="2*a1" FlatTopTime="8" Name="P3" Observe="P,KMAXx/P,Nx"/>
      </ATOMICSEQUENCE>
   </ConcatSequence>
\endcode

Load this sequence into the simulation GUI and run it. The 1-D image shows the expected result.

Now open the sequence with the sequence GUI and change the "NLG_field" attribute for both gradient pulses (P2 and P3) to

\code
NLG_field="4*(G*X^3)/a2^2" 
\endcode

in order to perform cubic spatial encoding.

Alternatively, the formulas

\code
NLG_field="1.5*G*atan(2.5*X/a2)*a2/Pi" 
\endcode

uses the arctangent function, and

\code
NLG_field="a3*G*abs(X-a2/2)*exp(-abs(X-a2/2)/a4)" 
\endcode

a Rayleigh function (resembling the PATLOC approach).

Below the result for the arctangent is depicted. 
The 1-D image shows the higher resolution encoding in the middle of the sample where the arctangent function has the largest slope,
i.e. the strongest "gradient" encoding takes place.

\n

These simulations only need some seconds on a single CPU.

\image html pics/ex_nlg.jpg 
\image latex pics/ex_nlg.eps width=12cm

\n

***************************************************
*/

