Manipulate the material of a VOI on a DICOM imported geometry

I have been exploring the extended/medical/DICOM example in order to import a CT of a phantom into my Geant4 geometry.
But my goal is to manipulate the imported DICOM geometry, by changing the material or density of a certain volume of interest. I thought of using the partial phantom option, but at a first glance it seems quite difficult to perfectly localize and overlap my voxels in the VOI with the G4 volume I would create. I also thought of manipulating the .g4dcm files myself and changing the voxels of the VOI to the material and density I am interested in, but I don’t fully understand the content of the .g4dcm files, especially the lines corresponding to the density values. How could I identify the voxels belonging to my VOI?
Perhaps there is a more direct solution. I’m looking forward to any input or suggestion you can give me, or at least shed some light on the density lines of the .g4dcm files.

Pinging @ivana and @arce as the maintainers of this example for their input.

You can see in DicomHandler::StoreData( that columns are written before rows:
for(G4int ww = 0; ww < fRows ;ww += fCompression ) {
for(G4int xx = 0; xx < fColumns ;xx +=fCompression ) {

But to get which voxels belong to VOI you need to write an algorithm to identify if a voxel is inside the VOI (center is inside the VOI? > 50% of voxel is inside the VOI, …), and Geant4 example does not do that. You would have to write the code or use one of the medical physics frameworks. I cannot tell you which one is better, but if you still prefer to use bare Geant4, I can point you to the code that one of these frameworks uses privately (pedro.arce@ciemat.es)