Login  Register

"pattern cropping"

Posted by zezh1112 on Jul 28, 2011; 3:33am
URL: http://imagej.273.s1.nabble.com/pattern-cropping-tp3683610.html

Hi everyone,

This is my first time to try to write a ImageJ micro, so sorry for the easy question I will ask,

The situation is that I have a plate within which there are 8 wells (4 wells in one row, 2 rows together, in the attachment you can find one pic showing this pattern), one fruit fly is moving around in each well. I recorded these 8 flies at a certain frequency within observation time, so I got a bunch of images in the end (the only thing moving is flies) . I want to crop each well from the whole plate picture, then run the object tracking plugin to check locomotion of this fly. Since the pattern of 8 wells is constant, instead of manually cropping each well, I hope I can write a macro to "pattern crop" the 8 wells at the same time.

My main logic is by changing the x and y value of "makeRectangle" to crop consequential wells. (below is two trials hoping to crop the 4 wells in the first row, after success I would go on to add the second row)

I tried first the most straight-forward way, and it works:

run("Image Sequence...", "open=[C:\\Documents and Settings\\Wang Lab\\Desktop\\20110628D\\ZZ20100628D100] number=20 starting=1 increment=1 scale=100 file=[] or=[] sort");


makeRectangle(60+100*0, 120, 200, 200);

run("Duplicate...", "title=0 duplicate range=3-20");

saveAs("tiff", "C:\\Documents and Settings\\Wang Lab\\Desktop\\TRY ZZ\\0");

run("Close");

makeRectangle(60+100*1, 120, 200, 200);

run("Duplicate...", "title=1 duplicate range=3-20");

saveAs("tiff", "C:\\Documents and Settings\\Wang Lab\\Desktop\\TRY ZZ\\1");

run("Close");

makeRectangle(60+100*2, 120, 200, 200);

run("Duplicate...", "title=2 duplicate range=3-20");

saveAs("tiff", "C:\\Documents and Settings\\Wang Lab\\Desktop\\TRY ZZ\\2");

run("Close");

makeRectangle(60+100*3, 120, 200, 200);

run("Duplicate...", "title=3 duplicate range=3-20");

saveAs("tiff", "C:\\Documents and Settings\\Wang Lab\\Desktop\\TRY ZZ\\3");

run("Close");


Then I used "for" loop as follows:

run("Image Sequence...", "open=[C:\\Documents and Settings\\Wang Lab\\Desktop\\20110628D\\ZZ20100628D100] number=20 starting=1 increment=1 scale=100 file=[] or=[] sort");
for (i=0; i<4; i++) {
   makeRectangle(60+100*i, 120, 200, 200);
   run("Duplicate...", "title="+i+" duplicate range=3-20");
   saveAs("tiff", "C:\\Documents and Settings\\Wang Lab\\Desktop\\TRYZZ\\"+i+");
   run("close");
   }

After I run this macro, an error pop out:
")" expected in line 6
<run>("close");

How can I correct this? Anyone can help me? Thanks a lot in advance!

Zheng





ZZ20100703F115 .bmp (148K) Download Attachment