Display the working image in batch mode

I am moving forward in learning how to work with macros in imagej, but sometimes, when i feel i am getting the angst of it, really simple macro take me back to the basics. haha

So, i was creating a macro to simply crop some images that lately i will analyse with CellProfiler, but for every image the position of my sample is different. This means that i have to move the specified cropping area for each image manually. Only problem, i cannot display the image i am working on in batch mode.

I assure you that as usual i searched everywhere for an answer before asking, but i am probably missing something.

macro "crop"{
     file1= getDirectory("Choose a Directory FOR Channel");
    list1= getFileList(file1); 
     file2= getDirectory("Choose a Directory FOR Output");
    list2= getFileList(file2); 
      fileNamewe = File.nameWithoutExtension;
      nameew = fileNamewe;
      run("Enhance Contrast", "saturated=0.35");
      run("Specify...", "width=960 height=1280 x=1080 y=1140");
      window = getImageID();
      waitForUser("Select larvae");
      saveAs("tiff", file2+nameew);

So, i resorted to ask all of you. Sorry if my question is stupid.

Ah, maybe i can use this post to ask something else too. The microscope we use for this kind of easy scanning is an evos fl auto2, that acquire the area and stitch it, but in the stitched images there are some intensity between the tiles. Potentially not a huge problem, but i wonder if there are methods to ameliorate or remove this difference…

Thank you all for helping a little noob!

Question I:
Simply delete or comment out the


setBatchMode is used to speed up macro processing by NOT displaying images.

If you NEED to display the image then don’t use setBatchMode(true).

Question II:
Either use homogeneous illumination
or correct your image backgound.

1 Like

Question I:
ok, i am an idiot. I learned how to use that command line in some tutorial and i believed it was a default command to run a batch. As i said, i am a at the firsts attempt, so thank you a lot for answering.

Question II:
I tried to correct the back ground, but the result was not so good, so i will try with homogeneous illumination.

Thank you again!

Not sure how you created these recordings (no experience with the setup). Your background varies but is rather constant in a tile. Did you set illumination, exposure time to ‘automatic’ or did you set them to constants? The former might explain the differences and can be easily solved by locking these settings somehow while tile scanning. Of course, make sure you first set optimal conditions for the object you want to image. When zooming in and measuring part of the larvae is overexposed (=>=255). Maybe you have an option to use monochrome16-bit recording…
And don’t use jpg, use tiff instead.

From proper images it would be easy/easier to find the larvae automatically by macro, removing the need for user interaction. Try to get the image symmetrical wrt. the petri dish (? the circle).

1 Like

We used an evos fl auto 2 in autoscan mode. Usually i acquire in manual mode, but considering the nature of the screening i decided to attempt the auto mode. This machine was created for cell colture screening, so is really not adaptable to my setup. Biggest difference is that in manual mode i have access to settings such as light, exposure and gain, while in auto i have single parameter called lightening, that i tried to adjust as much as possible. Furthermore, in manual i can save in 16bit tif, while here i am forced in png. I am diving in the user manual to see if it’s possible to change this.

The larvae are in a 24 well plate and i was thinking about using the matching template macro built by acquifer (machine born for doing what we want and that we aim to acquire), but for this time would have been overkill. I will attempt to use it for when we will switch to 48 or 96 well plate.

Thank you a lot for the feedback!

I noticed that of each tile the top left has a different amount of light than the bottom right. You might want to get that one corrected too; maybe it is a matter of centring the lamp and centring the objective and matching the three lenses.
And while you are at it, maybe record a ‘flat field’ image, where no object is in the path of light (or an empty well), so you can divide the images by the flat field image to do some shading correction too.