It looks like lop$outInit needs to be initialized through the testing process among some voxels. Since in this case you don't have any meaningful voxels among those initial slices, add the following line
lop$outInit <- rep(0, NoBrick)
(replace NoBrick with the total number of sub-bricks in the output -- you can figure this out, right?)
before the following lines:
print(sprintf("Start to compute %s slices along Z axis. You can monitor the progress", dimz))
print("and estimate the total run time as shown below.")
print(format(Sys.time(), "%D %H:%M:%OS3"))
Good luck!
Gang