Login  Register

Command to see whats happening in my macro?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Command to see whats happening in my macro?

Rose Wilson
Hi
I wrote a macro a while ago using the macro recorder and some additional lines of code. Its been great but I now need to write a description complete with pictures of the various steps.

When I made the macro initially I also used a command that showed on the screen the progress of the macro, ie the individual steps but I have now forgotten what it was!

Can anyone help?
Hope this makes sense, and thanks in advance for your help,
Rose
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Command to see whats happening in my macro?

Pariksheet Nanda
On Thu, Oct 25, 2012 at 11:29 AM, Rose Wilson <[hidden email]> wrote:
> When I made the macro initially I also used a command that showed on the
> screen the progress of the macro, ie the individual steps but I have now
> forgotten what it was!
>

Perhaps you were using IJ.log() or showProgress()


> Rose

Pariksheet

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Command to see whats happening in my macro?

Krs5
In reply to this post by Rose Wilson
Dear Rose,

Maybe you are looking for Plugins > Utilities > monitor events

Best wishes

Kees

________________________________________
From: ImageJ Interest Group [[hidden email]] On Behalf Of Rose Wilson [[hidden email]]
Sent: 25 October 2012 16:29
To: [hidden email]
Subject: Command to see whats happening in my macro?

Hi
I wrote a macro a while ago using the macro recorder and some additional
lines of code. Its been great but I now need to write a description complete
with pictures of the various steps.

When I made the macro initially I also used a command that showed on the
screen the progress of the macro, ie the individual steps but I have now
forgotten what it was!

Can anyone help?
Hope this makes sense, and thanks in advance for your help,
Rose



--
View this message in context: http://imagej.1557.n6.nabble.com/Command-to-see-whats-happening-in-my-macro-tp5000523.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Command to see whats happening in my macro?

Rose Wilson
Hi Kees

thanks for the suggestion but I don't have that option under utilities...

Rose
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Command to see whats happening in my macro?

Rose Wilson
In reply to this post by Pariksheet Nanda
Hi Pariksheet,
I have tried both of these, but it comes up with the error;
'Number or numeric function expected in line 10'

Is there a certain place it should go? I tried both at the top (as below) with the other general bits, but I did also try it before and after the run(Find Maxima .....) command too.

Do you have any suggestions?
Many thanks,Rose

// Ask user for source and destination directories
dir = getDirectory("Roses Source Directory");
dest1 = getDirectory("Roses Destination Directory");
dest2 = getDirectory("Roses Destination2 Directory");

list = getFileList(dir);
setBatchMode(true);
IJ.log()

for (i=0; i<list.length; i++) {
         name = list[i];
         path = dir + name;

        // Open image
        open(path);
// Macro
run("Find Maxima...", "noise=55 output=[Maxima Within Tolerance]");
run("Close-");
//run("Threshold...");
setThreshold(255, 255);
run("Convert to Mask");
run("Analyze Particles...", "size=3000-Infinity pixel circularity=0.00-1.00 show=Outlines display exclude");
// 
saveAs("Tiff", dest1+name);
close();
close();

Rosemary Wilson
Department of Biology,
University of York,
Heslington,
York,
YO10 5YW
Tel: +44 (0)1904 328569
Email: [hidden email]

EMAIL DISCLAIMER http://www.york.ac.uk/docs/disclaimer/email.htm




On 26 Oct 2012, at 12:45, Pariksheet Nanda [via ImageJ] wrote:

On Thu, Oct 25, 2012 at 11:29 AM, Rose Wilson <<a href="x-msg://28/user/SendEmail.jtp?type=node&amp;node=5000543&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]> wrote:
> When I made the macro initially I also used a command that showed on the
> screen the progress of the macro, ie the individual steps but I have now
> forgotten what it was!
>

Perhaps you were using IJ.log() or showProgress()


> Rose

Pariksheet

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html



If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.n6.nabble.com/Command-to-see-whats-happening-in-my-macro-tp5000523p5000543.html
To unsubscribe from Command to see whats happening in my macro?, click here.
NAML

Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Command to see whats happening in my macro?

Michael Schmid
Hi Rose,

ImageJ text windows have a 'Debug' menu, where you can select 'Debug
macro' and then step through the macro with ctrl-E (command-E on Macs). On
Macs, you need to have the text window in the foreground; otherwise the
menu is gone.

In your case, the IJ.log() statement without any argument causes an error;
to output a blank line, use IJ.log("");

Michael
_______________________________________________________________________

On Fri, October 26, 2012 15:03, Rose Wilson wrote:

> Hi Pariksheet,
> I have tried both of these, but it comes up with the error;
> 'Number or numeric function expected in line 10'
>
> Is there a certain place it should go? I tried both at the top (as below)
> with the other general bits, but I did also try it before and after the
> run(Find Maxima .....) command too.
>
> Do you have any suggestions?
> Many thanks,Rose
>
> // Ask user for source and destination directories
> dir = getDirectory("Roses Source Directory");
> dest1 = getDirectory("Roses Destination Directory");
> dest2 = getDirectory("Roses Destination2 Directory");
>
> list = getFileList(dir);
> setBatchMode(true);
> IJ.log()
>
> for (i=0; i<list.length; i++) {
>          name = list[i];
>          path = dir + name;
>
>         // Open image
>         open(path);
> // Macro
> run("Find Maxima...", "noise=55 output=[Maxima Within Tolerance]");
> run("Close-");
> //run("Threshold...");
> setThreshold(255, 255);
> run("Convert to Mask");
> run("Analyze Particles...", "size=3000-Infinity pixel
> circularity=0.00-1.00 show=Outlines display exclude");
> //
> saveAs("Tiff", dest1+name);
> close();
> close();
>
> Rosemary Wilson
> Department of Biology,
> University of York,
> Heslington,
> York,
> YO10 5YW
> Tel: +44 (0)1904 328569
> Email: [hidden email]
>
> EMAIL DISCLAIMER http://www.york.ac.uk/docs/disclaimer/email.htm
>
>
>
>
> On 26 Oct 2012, at 12:45, Pariksheet Nanda [via ImageJ] wrote:
>
>> On Thu, Oct 25, 2012 at 11:29 AM, Rose Wilson <[hidden email]> wrote:
>> > When I made the macro initially I also used a command that showed on
>> the
>> > screen the progress of the macro, ie the individual steps but I have
>> now
>> > forgotten what it was!
>> >
>>
>> Perhaps you were using IJ.log() or showProgress()
>>
>>
>> > Rose
>>
>> Pariksheet
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>>
>> If you reply to this email, your message will be added to the discussion
>> below:
>> http://imagej.1557.n6.nabble.com/Command-to-see-whats-happening-in-my-macro-tp5000523p5000543.html
>> To unsubscribe from Command to see whats happening in my macro?, click
>> here.
>> NAML
>
>
>
>
>
> --
> View this message in context:
> http://imagej.1557.n6.nabble.com/Command-to-see-whats-happening-in-my-macro-tp5000523p5000545.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Command to see whats happening in my macro?

Pariksheet Nanda
In reply to this post by Rose Wilson
On Fri, Oct 26, 2012 at 9:03 AM, Rose Wilson <[hidden email]> wrote:
> I have tried both of these, but it comes up with the error
>

As Michael explained, I neglected to point out that both the functions
need a parameter.
The macro function documentation page explains that IJ.log(string)
needs a string, and showProgress(progress) uses a number between 0 and
1:
http://imagej.nih.gov/ij/developer/macro/functions.html


> Is there a certain place it should go?
>

You could put the progress indicator as the first statement in your "for" loop.
To use showProgress you could add this 1 line right after the "for"
statement (I'm redundantly including 1 statement before and after for
context):

for (i=0; i<list.length; i++) {
         showProgress((i+1) / list.length);
         name = list[i];

...or if commands you are running in the loop are using their own
progress bar clouding the progress of your macro, you could add this 1
line instead:

         IJ.log("Processing file " + i+1 + " of " + list.length);


> Many thanks,Rose

Pariksheet

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Command to see whats happening in my macro?

Rose Wilson
Hi Pariksheet and Michael,

Thanks both for your help with this, its much appreciated. I'm not really a computer person so none of this is obvious for me!

The IJ.log("Processing file " + i+1 + " of " + list.length); worked to show progress but I realise I have asked the wrong question!

The piece of code I'm looking for is one which shows the pictures generated by the macro at each step, ie  open image, find maxima, set threshold, etc as the macro progresses (like you would see if you were doing it manually) rather than it doing it in the background. Does that make sense?

I need to check that my manual description is correct so I need to check the images that are generated at each step are the same.

Thanks again for your help,
Rose
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Command to see whats happening in my macro?

ctrueden
Hi Rose,

> The piece of code I'm looking for is one which shows the pictures
> generated by the macro at each step, ie  open image, find maxima, set
> threshold, etc as the macro progresses (like you would see if you were
> doing it manually) rather than it doing it in the background.

Did you try removing the line:
   setBatchMode(true);

With batch mode off, images will pop up, etc., as though you were
performing the commands manually. Once you are certain the macro works the
way you expect, you can put the setBatchMode command back to make it run
faster.

Regards,
Curtis


On Tue, Oct 30, 2012 at 6:55 AM, Rose Wilson <[hidden email]> wrote:

> Hi Pariksheet and Michael,
>
> Thanks both for your help with this, its much appreciated. I'm not really a
> computer person so none of this is obvious for me!
>
> The IJ.log("Processing file " + i+1 + " of " + list.length); worked to show
> progress but I realise I have asked the wrong question!
>
> The piece of code I'm looking for is one which shows the pictures generated
> by the macro at each step, ie  open image, find maxima, set threshold, etc
> as the macro progresses (like you would see if you were doing it manually)
> rather than it doing it in the background. Does that make sense?
>
> I need to check that my manual description is correct so I need to check
> the
> images that are generated at each step are the same.
>
> Thanks again for your help,
> Rose
>
>
>
> --
> View this message in context:
> http://imagej.1557.n6.nabble.com/Command-to-see-whats-happening-in-my-macro-tp5000523p5000584.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Command to see whats happening in my macro?

Rose Wilson
Hi Curtis,

thats it! It does exactly what I wanted and works fine.

Thank you very much, much appreciated!
Rose