Make custom depth show through specific objects?

Im using custom depth to make an xray. I want this xray to only show through certain objects. I found an explanation on how to do this:

“It’s much like the outline effect that filters based on stencil index. You can for example use an if-node to check for corrct index or normlize your x-ray index so it becomes a 0-1 range so you may use it as a multiplication when figuring out if we should show x-ray or not.”

How would I make it so that an object would only see a certain stencil #?