Is there a simple nice way to do surround substracting on ASL data

Hello folks,

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 ?

Thanks for any help


I am not very familiar with ASL, but I am looking at the description preceding Eq. 3 in:
A signal processing model for arterial spin labeling functional MRI, by Liu and Wong (2005) A signal processing model for arterial spin labeling functional MRI - PubMed

How about:

3dcalc                                   \
     -a DSET_INPUT                       \
     -b 'a[0,0,0,1]'                     \
     -c 'a[0,0,0,-1]'                    \
     -expr '(a-0.5*(b+c))*(-1)**(l+1)'   \
     -prefix DSET_OUTPUT

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.


1 Like

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.


Nice, thanks.

Sorry about calling Peter, Paul, both names of my uncles ^^.

Thanks you so much

Totally fine about the name, and glad the processing command works well.


1 Like