Running classifier with script and saving the annotations as image overlay

Hi all,
I am using QuPath Version 0.2.3.
I am trying to run a classifier with the help of a script so that I can detect the total tissue area. Since I have many files, I also want to include saving the annotations as image overlay, so that I can check all the tissue detections. Below is the script;

def viewer = getCurrentViewer()

//Define the image type
clearAllObjects();//Delete all objects

//This function changed between 0.1.2 and 0.2.0, in 0.2.0 use viewer.getImageDisplay().availableChannels()
def channels = viewer.getImageDisplay().availableChannels()
// Set the range for the first two channels

// Ensure the updates are visible

def minArea = 1000.0 // To change
def minHoleArea = 100.0 // To change
def classifierName = "DAPI_classifier" // To change

// Apply pixel classifier inside them
// Note: you can change this to createDetectionsFromPixelClassifier(..) if needed
createAnnotationsFromPixelClassifier(classifierName, minArea, minHoleArea)
print "Done!"

Below I am showing two tissue examples detected by the script. In first example, image intensity was set as described in the script.

Whereas in the the second image, intensities are not set as defined by the script and I am not able to see the image overlaid by annotations.

As this is resolved, I will work on including the script to save the image overlay.
Thanks for your help.

You are only ever looking at or working in the currentViewer, so your changes should only apply to the current viewer, even if you “Run for project.”

If you want to keep the current display settings as you change between images, you can do that by checking the box under Keep Settings in the Brightness and Contrast window.

Scripts that save the overlay will usually use the current image’s display settings for the export, not the display settings of the image you are exporting. Though there are scripts that allow you to bypass that all entirely, they are more involved.

Thanks @Research_Associate for your reply.
I keep the “Keep settings” option checked. One thing that I have noticed is even it is checked, when I open any image for the first time, the settings are not maintained and I have to adjust them.
So, coming back to my question, I will have to check each image by opening it in the qupath to confirm tissue-annotation overlay ?

That should not be the case, it sounds like either something else is going on, I am not understanding the issue. If your images are different intensities, keep settings is not the same as “auto adjust” for each image - it gives the same exact display ranges for the same exact channels.

Also, in the original script, that is an older way of adjusting fluorescence - it would probably be better to use:
Which references