Hmm, that is a bit of a different beast. In this case, you want to take each ROI mask and splice it into two parts-- a posterior and an anterior one? Based on what information?
Well, you can do something like the following, but note that this doesn't follow anatomical lines-- that kind of subtley would take different info.
Thinking in (x,y,z) coordinates, the anterior-posterior axis is the 'y' variable, and if your data is in RAI coordinates, then "A" is lower/negative values, and "P" is higher/positive values. Let's say you want to define the the posterior region to be everything with y>5, and the anterior to be the complement of that. Then you could use the fact that 3dcalc expressions can recognize special letters as coordinates (x, y, z, and t) and as indexes (i, j, k, and n). See the "COORDINATES and PREDEFINED VALUES" section in 3dcalc, as well as usage example 7 there. You just have to think of y>5 being the same as y-5>0, and then you can use the ispositive() function in 3dcalc expression, or the equivalent step() one.
For the aforementioned case of anterior/posterior division, you could therefore run the following to take all the values in DSET and multiply them by a binary mask based on coordinate location, zeroing out those regions that are not 'true' with the step() or ispositive() function:
3dcalc -a DSET -expr 'a*ispositive(y-5)' -prefix DSET_ANT
3dcalc -a DSET -expr 'a*not(ispositive(y-5))' -prefix DSET_POST
Note that this pair could be written in other ways; using the not() around the ispositive() function in the second case just made it easy to get the complement of the first condition.
Just note the subtleties of the y>5 being either anterior or posterior, depending on the orientation of your dataset (3dinfo -orient DSET). You can try a couple examples and see what works.
--pt