Trying to get ratio of nucleus channel 1 mean / cytoplasm channel 1 mean via coding in qupath

Hello Everyone,
I was wondering how can I call the measurements in the script. I wanna get the ratio of nucleus channel 1 mean/cytoplasm channel 1 mean in my IF detected cells. Can you just suggest some examples or how i can do it? Thank you so much.

I keep a collection of scripts gathered from various sources on that topic here.

Same warnings as my post here (see the first paragraph, or first two images or so) on cytoplasmic mean measurements apply though, so your cytoplasmic means may not be terribly accurate.

If you are doing measurements anyway, I would recommend doing mean*area to get the total intensity of one region versus the other. It would probably come out something like:

getCellObjects().each { it.getMeasurementList().putMeasurement("Ratio", (measurement(it,"Nucleus: Channel 1 mean")*measurement(it, "Nucleus: Area"))/(measurement(it, "Cytoplasm: Channel 1 mean")*(measurement(it, "Cell: Area")-measurement(it, "Nucleus: Area"))))}

*Edit: one typo and several missing parentheses at the end, and now the code works.