Band math expression using snappy

Hi there,

Currently trying to perform Band Maths on a image using snappy.

I want to build the expression using this threshold:
thres=m-std**2

Is there a way to use this external value inside the expression?

result.getBand('B8')
BandDescriptor = jpy.get_type('org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor')
targetBand1 = BandDescriptor()
targetBand1.name = 'B8'
targetBand1.type = 'float32'
targetBand1.expression = 'if B8 <', **thres**, 'then 1 else 0'
targetBands = jpy.array('org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor', 1)
targetBands[0] = targetBand1
parameters = HashMap()
parameters.put('targetBands', targetBands)
result_bof = GPF.createProduct('BandMaths', parameters, result)

Thanks in advance