I have an ROI that I want to bootstrap a confidence interval for my result by randomly moving it and recalculating the result, e.g. move 1 cm frontally and 1 cm up. Does anyone have any idea how to approach this?

Its not THAT easy. Specially if you have surfaces, which, are manifolds and do not have 1-up 1-left coordinates.

This being said, if you are working with Freesurfer, you have the sphere-inflated representation of the surface, and you could move your ROI along that sphere (i.e polar coordinates displacement!).

There are some implementations that grounded on this idea, generate null models of (spatially auto-correlated) maps. Maybe you can dig in into the code and get some ideas on how to do the polar rotation of your ROI.

Here is a python implementation of such â€śspinâ€ť rotation:

brainspace.null_models.spin â€” BrainSpace 0.1.3 documentation

+1 to @slieped 's answer. For a deep dive on this topic, I recommend you to look into the UV mapping literature of computer graphics.

How about generating a mask of the entire area you are interested in, then perform a boolean `and`

with a cube or sphere that you move about the space?

Wait, what about define a mask of the entire ROI, then randomly select voxels from within?

I am working in workbench, is that possible to intersect with the cortical ribbon?

Yeah, my plan if I canâ€™t figure this out is to dilate the ROI and then do something like that, however, I thought an approaching shifting the COG would be more interpretable.

Randomly moving it 1cm front and 1 cm up doesnâ€™t really sound â€śrandomâ€ť.

Would you mind expanding on where this ROI comes from and what you want to achieve? Confidence interval for what stat?

You can also imagine that depending where your ROI is, moving it around may be meaningless (like moving it outside the brain or into the ventricle). It seems to me there must be a better model for you to sample from.