How is the temporal derivative of global signal (fMRI timeseries) calculated?

To provide you with some context— there is an option in nilearn to regress away the global signal and its temporal derivative, so, i’m trying to do the same in R.

IIRC we do not explicitly GSR in Nilearn, nor do we compute the corresponding time derivative. We import these data from fmriprep output.
Nevertheless, you can simply take the finite difference
diff[t] = gs[t] - gs[t-1],
with diff[0] = 0
HTH,
Bertrand