I am procesing ASL data on multi-echo.
We want to compare different ways to get CBF out of the data.
I know we can do a simple substraction, but I would like to keep the number of BRIKS/TR as it is (time resolution).

How can we perform surround substracting in AFNI ?
Do I need to multiply by a [-1, 1, -1, 1 … 1] vector after surround substraction ?

The “a” dataset is the original; the “b” is a version of “a” that is shifted positively one time point, and “c” is the version of “a” shifted negatively one time point. The (-1)**(l+1) is there to provide the sign flip that appears to be present, as well; for each time point “centered” at an even index, there appeared to be a sign flip in the difference formula.

Note that in the above shifting rule, when you shift rightwardward, the leftmost point is a duplicate of the original zeroth entry, and analogously with shifting the other way. So, I am not sure if this formula makes sense for behavior at the endpoints themselves—I think those would have to be chopped away. Or, you could recalculate those as just simple differences from their nearest neighbors to the one side that they have.

Hello Peter,
thank you so much for the answer.
I was looking for exactly this info.
I had the math done in matlab but wanted to keep the header, so this is perfect.
Also, this could be helpfull for others.
Thank you so much.

This part “*(-1)**(l+1)” is the -1 +1 alternation right ?

Indeed, keeping the header information is often a strong reason for doing these kinds of calcs with preexisting tools.

And yes, the (-1)**(l+1) is the sign alteration here: in 3dcalc, l has a special interpretation as the index of time (similarly, i, j, and k will be treated as spatial indices, if not used as other input variable labels). Therefore, this acts as the sign flipping as l increases.