Scripting: Opening multiviewers

I was looking through old posts about the multiviewer, but haven’t found much easily accessible information.
https://groups.google.com/d/msg/qupath-users/4bwBr1FbiW0/aQqsB6E0BQAJ

Before I go digging into the code, does anyone have any suggestions as far as how to create a script to:

  1. Open 6 viewers in the multiviewer (2x3, or 3x2)
  2. Populate them with imageData from images with certain strings in their name

Two shouldn’t be all that bad, as the project entry list could be searched for that information. I am a bit lost as far as how to perform the first action.

Ideally, this would make things easier for someone going through 50 projects where they need to compare multiple brightfield images. They would still need to roughly align the images, but it would make things far less painful for the pathologists.

@Zbigniew_Mikulski

1 Like

These aren’t really intended to be scriptable at this time, and the code is being extensively refactored… however, for the second this should work

guiscript = true

def project = getProject()
def entries = project.getImageList()
def viewers = getQuPath().getViewers()

for (int i = 0; i < viewers.size(); i++) {
    def viewer = viewers[i]
    def imageData = entries[i].readImageData()
    viewer.setImageData(imageData)
}

For the first, I suggest just setting this up through the user interface in advance :slight_smile:

2 Likes

Thank you @Mike_Nelson and @petebankhead! Multiviewers are super helpful for this task, thanks for the quick reply, it works like a charm.

Really looking forward to seeing what you will come up with when it will stop working :grin:

1 Like

Yep, we will have to adjust that slightly since the images are in different orders in different projects, but should be workable. I suspect we will want the placement to be consistent for them.