Hello again,

now that I have my wonderfull cell detections, I wondered how to script a complex phenotyping (to earn precious time).

So I rewritted a script “double positive classifier”:

```
// Get cells & reset all the classifications
def cells = getCellObjects()
resetDetectionClassifications()
cells.each {it.setPathClass(getPathClass('Negative'))}
// Get channel 1 & 2 positives
def ch1Pos = cells.findAll {measurement(it, "CD38: Cytoplasm: Median") > 83.5}
ch1Pos.each {it.setPathClass(getPathClass('CD38+'))}
def ch2Pos = cells.findAll {measurement(it, "CD8: Cytoplasm: Median") > 37.5}
ch2Pos.each {it.setPathClass(getPathClass('CD8+'))}
def ch3Pos = cells.findAll {measurement(it, "BDAC2: Cytoplasm: Median") > 35.5}
ch3Pos.each {it.setPathClass(getPathClass('BDCA2+'))}
def ch4Pos = cells.findAll {measurement(it, "CD20: Cytoplasm: Median") > 65.5}
ch4Pos.each {it.setPathClass(getPathClass('CD20+'))}
def ch5Pos = cells.findAll {measurement(it, "CD3: Cell: Median") > 25.5}
ch5Pos.each {it.setPathClass(getPathClass('CD3+'))}
// Overwrite classifications for double positives/ triple ...
def ch1ch2Pos = ch1Pos.intersect(ch2Pos)
ch1ch2Pos.each {it.setPathClass(getPathClass('CD38+CD8+'))}
def ch1ch3Pos = ch1Pos.intersect(ch3Pos)
ch1ch3Pos.each {it.setPathClass(getPathClass('CD38+BDCA2+'))}
def ch1ch4Pos = ch1Pos.intersect(ch4Pos)
ch1ch4Pos.each {it.setPathClass(getPathClass('CD38+CD20+'))}
def ch1ch5Pos = ch1Pos.intersect(ch5Pos)
ch1ch5Pos.each {it.setPathClass(getPathClass('CD38+CD3+'))}
def ch2ch3Pos = ch2Pos.intersect(ch3Pos)
ch2ch3Pos.each {it.setPathClass(getPathClass('CD8+BDCA2+'))}
def ch2ch4Pos = ch2Pos.intersect(ch4Pos)
ch2ch4Pos.each {it.setPathClass(getPathClass('CD8+CD20+'))}
def ch2ch5Pos = ch2Pos.intersect(ch5Pos)
ch2ch5Pos.each {it.setPathClass(getPathClass('CD8+CD3+'))}
def ch3ch4Pos = ch3Pos.intersect(ch4Pos)
ch3ch4Pos.each {it.setPathClass(getPathClass('BDCA2+CD20+'))}
def ch3ch5Pos = ch3Pos.intersect(ch5Pos)
ch3ch5Pos.each {it.setPathClass(getPathClass('BDCA2+CD3+'))}
def ch4ch5Pos = ch4Pos.intersect(ch5Pos)
ch4ch5Pos.each {it.setPathClass(getPathClass('CD20+CD3+'))}
def ch1ch2ch3Pos = ch1ch2Pos.intersect(ch2ch3Pos)
ch1ch2ch3Pos.each {it.setPathClass(getPathClass('CD38+CD8+BDCA2+'))}
def ch1ch2ch4Pos = ch1ch2Pos.intersect(ch2ch4Pos)
ch1ch2ch4Pos.each {it.setPathClass(getPathClass('CD38+CD8+CD20+'))}
def ch1ch2ch5Pos = ch1ch2Pos.intersect(ch2ch5Pos)
ch1ch2ch5Pos.each {it.setPathClass(getPathClass('CD38+CD8+CD3+'))}
def ch1ch3ch4Pos = ch1ch3Pos.intersect(ch3ch4Pos)
ch1ch3ch4Pos.each {it.setPathClass(getPathClass('CD38+BDCA2+CD20+'))}
def ch1ch3ch5Pos = ch1ch3Pos.intersect(ch3ch5Pos)
ch1ch3ch5Pos.each {it.setPathClass(getPathClass('CD38+BDCA2+CD3+'))}
def ch1ch4ch5Pos = ch1ch4Pos.intersect(ch4ch5Pos)
ch1ch4ch5Pos.each {it.setPathClass(getPathClass('CD38+CD20+CD3+'))}
def ch2ch3ch4Pos = ch2ch3Pos.intersect(ch3ch4Pos)
ch2ch3ch4Pos.each {it.setPathClass(getPathClass('CD8+BDCA2+CD20+'))}
def ch2ch3ch5Pos = ch2ch3Pos.intersect(ch3ch5Pos)
ch2ch3ch5Pos.each {it.setPathClass(getPathClass('CD8+BDCA2+CD3+'))}
def ch2ch4ch5Pos = ch2ch4Pos.intersect(ch4ch5Pos)
ch2ch4ch5Pos.each {it.setPathClass(getPathClass('CD8+CD20+CD3+'))}
def ch3ch4ch5Pos = ch3ch4Pos.intersect(ch4ch5Pos)
ch3ch4ch5Pos.each {it.setPathClass(getPathClass('BDCA2+CD20+CD3+'))}
def ch1ch4ch5ch2Pos = ch2ch4ch5Pos.intersect(ch1ch4ch5Pos)
ch1ch4ch5ch2Pos.each {it.setPathClass(getPathClass('CD38+CD20+CD3+CD8+'))}
fireHierarchyUpdate()
println 'Done!'
```

It works fine.

My question is about my strategie of overwriting, because I don’t know exaclty how it works and I am afraid to loose some information.

Do my overwritting seem fine? For example when I write “def ch1ch2ch4Pos = ch1ch2Pos.intersect(ch2ch4Pos)”, wouldn’t be better to write: “def ch1ch2ch4Pos = ch1ch2Pos.intersect(ch4Pos)”.

Or there is an other way to write it?

Thank you.