Export Binary Mask With Image Region

I want to export the annotations as masks along with the respective image. I tried the following script but resulted in error. I am on version 0.2.0-m6

The error on this line:

ERROR: It looks like you have tried to import a class 'qupath.lib.roi.PathROIToolsAwt' that doesn't exist!

ERROR: Error at line 13: startup failed:
Script1.groovy: 14: unable to resolve class qupath.lib.roi.PathROIToolsAwt
 @ line 14, column 1.
   import qupath.lib.roi.PathROIToolsAwt

Script1.groovy: 15: unable to resolve class qupath.lib.scripting.QPEx
 @ line 15, column 1.
   import qupath.lib.scripting.QPEx

The script works fine with v0.1.2, does anyone have a working equivalent for v m6 ?

Here’s a revised version for v0.2.0-m6.


Works like a charm ! thanks @petebankhead