Macro has slowed down dramatically when run in background

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Macro has slowed down dramatically when run in background

nelssara
Up until this morning I was successfully running an image processing macro that I had written to analyze some microscopy data. I would get the macro started, and then move on to another window/program to do some other task while the macro ran.

However, as of today, once I click on another window/program the imagej slows to a halt at probably approx 1% of the speed it previously ran in.

Any hints as to how I can return to my formerly fast processing speeds?

Thanks for your help!

Sarah

Reply | Threaded
Open this post in threaded view
|

Re: Macro has slowed down dramatically when run in background

Brandon Hurr
This sounds like AppNap on a Mac. I have similar issues when running
macros. I believe you can disable it, but I haven't looked into it enough
to know how.

If it's a Mac could you be more specific on your conditions. If it's not a
Mac. Do the same.
On Mon, Jul 20, 2015 at 15:33 nelssara <[hidden email]> wrote:

> Up until this morning I was successfully running an image processing macro
> that I had written to analyze some microscopy data. I would get the macro
> started, and then move on to another window/program to do some other task
> while the macro ran.
>
> However, as of today, once I click on another window/program the imagej
> slows to a halt at probably approx 1% of the speed it previously ran in.
>
> Any hints as to how I can return to my formerly fast processing speeds?
>
> Thanks for your help!
>
> Sarah
>
>
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Macro-has-slowed-down-dramatically-when-run-in-background-tp5013659.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
|

Re: Macro has slowed down dramatically when run in background

nelssara
In reply to this post by nelssara
Also, here is the code for the macro I am running. I have the batchmode as false, because otherwise it throws an error (and I am working with two monitors, so I can just leave imagej up and flashing away while I do other things...).

dir = getDirectory("Choose a Directory to PROCESS");    
    list = getFileList(dir);                                                    
dir2 = getDirectory("Choose a Directory for SAVING the PLA Image");
dir3 = getDirectory("Choose a Directory for SAVING the speckled PLA Image");  
   


 setBatchMode(false);              
    for (f=0; f<list.length; f++) {
        path = dir+list[f];                      
print(path);                                    
        showProgress(f, list.length);    
        if (!endsWith(path,"/")) open(path);
if (nImages>=1) {                                        
  if (endsWith(path,"f")) {

   t=getTitle();                                      
   s=lastIndexOf(t, '.');                          
   ts=substring(t, 0,s);
 
 
  ts2= ts +' PLA';
  ts3= ts + ' speck';
  ts4= ts + ' mask';                                                                                      

//Split channels
        run("Split Channels");
        selectWindow(t + " (blue)");
        close();
        selectWindow(t + " (green)");
        close();
        selectWindow(t + " (red)");
        run("Subtract Background...", "rolling=50");
        run("Duplicate...", " ");
        selectWindow(t + " (red)-1");
        run("Gray Morphology", "radius=3.5 type=circle operator=erode");
        run("Gray Morphology", "radius=3.5 type=circle operator=dilate");
        imageCalculator("Subtract create", t + " (red)", t + " (red)-1");
        selectWindow("Result of " + t + " (red)");
        rename(ts3);                                      
    saveAs("Tiff",  dir3 + ts3);
    run("Duplicate...", " ");
    setAutoThreshold("Triangle dark");
    setOption("BlackBackground", false);
    run("Convert to Mask");
        run("Make Binary");
        run("Divide...", "value=255");
        saveAs("Tiff",  dir3 + ts4);
        setMinAndMax(0, 1);
        imageCalculator("multiply create", ts3 + ".tif", ts4 + ".tif");
        selectWindow("Result of " + ts3 +".tif");
        run("Brightness/Contrast...");
   run("32-bit");
   run("Divide...", "value=255");
   run("Brightness/Contrast...");
   setMinAndMax(0,1);
   run("Set Measurements...", "integrated limit display redirect=None decimal=1");
   run("Measure");
   rename(ts3);                                      
   saveAs("Tiff",  dir3 + ts3);
   selectWindow(t + " (red)");
   rename(ts2);
   saveAs("Tiff", dir2 + ts2);
   run("Close All");
               

       }                                
  }
}      

selectWindow("Results");
saveAs("results", dir2 + "PLA Intensity values 2.xls");
Reply | Threaded
Open this post in threaded view
|

Re: Macro has slowed down dramatically when run in background

nelssara
In reply to this post by Brandon Hurr
Thanks for your response Brandon! I'm not very good with computers, so I don't exactly know what you are referring to when you mean "conditions".
Reply | Threaded
Open this post in threaded view
|

Re: Macro has slowed down dramatically when run in background

Brandon Hurr
It is very helpful to supply a minimal reproducible example and your
working environment when asking for help on lists and forums.
Things that are key for ImageJ would be:
Version and type of OS (Windows, Mac, Linux, UNIX)
Version of Java
Version of ImageJ
Minimal reproducible code that causes your error or problem on your system
Can you provide those?
If you're on a Mac, look up how to disable AppNap for Java.

On Mon, Jul 20, 2015 at 15:49 nelssara <[hidden email]> wrote:

> Thanks for your response Brandon! I'm not very good with computers, so I
> don't exactly know what you are referring to when you mean "conditions".
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Macro-has-slowed-down-dramatically-when-run-in-background-tp5013659p5013662.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
|

Re: Macro has slowed down dramatically when run in background

nelssara

OK:


Mac OSX 10.10.4

I'm not sure which version of java I am using or how to find that out

I'm running FIJI with ImageJ version 2.0.0-rc-30/1.49u


And the code is posted above. I don't recieve an error it just runs VERY, VERY slow if I am actively using another program.


Thanks for your help!!





From: Brandon Hurr [via ImageJ] <ml-node+[hidden email]>
Sent: Monday, July 20, 2015 4:54 PM
To: Nelson, Sarah
Subject: Re: Macro has slowed down dramatically when run in background
 
It is very helpful to supply a minimal reproducible example and your
working environment when asking for help on lists and forums.
Things that are key for ImageJ would be:
Version and type of OS (Windows, Mac, Linux, UNIX)
Version of Java
Version of ImageJ
Minimal reproducible code that causes your error or problem on your system
Can you provide those?
If you're on a Mac, look up how to disable AppNap for Java.

On Mon, Jul 20, 2015 at 15:49 nelssara <[hidden email]> wrote:

> Thanks for your response Brandon! I'm not very good with computers, so I
> don't exactly know what you are referring to when you mean "conditions".
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Macro-has-slowed-down-dramatically-when-run-in-background-tp5013659p5013662.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



If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/Macro-has-slowed-down-dramatically-when-run-in-background-tp5013659p5013663.html
To unsubscribe from Macro has slowed down dramatically when run in background, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Macro has slowed down dramatically when run in background

Brandon Hurr
Try disabling AppNap entirely and run your program:
From:
http://hints.macworld.com/article.php?story=20140508050203105
Open Terminal (Applications/Utilities)
Copy and Paste:
defaults write NSGlobalDomain NSAppSleepDisabled -bool YES
If it doesn't slow down after this then it's AppNap. If it still does then
there is something else. You are supposed to be able to do this per
application, but I've not seen how to effectively do it for Java programs
like ImageJ/FIJI. Perhaps someone else can chime in.

On Mon, Jul 20, 2015 at 16:14 nelssara <[hidden email]> wrote:

> OK:
>
>
> Mac OSX 10.10.4
>
> I'm not sure which version of java I am using or how to find that out
>
> I'm running FIJI with ImageJ version 2.0.0-rc-30/1.49u
>
>
> And the code is posted above. I don't recieve an error it just runs VERY,
> VERY slow if I am actively using another program.
>
>
> Thanks for your help!!
>
>
>
> ________________________________
> From: Brandon Hurr [via ImageJ] <[hidden email]>
> Sent: Monday, July 20, 2015 4:54 PM
> To: Nelson, Sarah
> Subject: Re: Macro has slowed down dramatically when run in background
>
> It is very helpful to supply a minimal reproducible example and your
> working environment when asking for help on lists and forums.
> Things that are key for ImageJ would be:
> Version and type of OS (Windows, Mac, Linux, UNIX)
> Version of Java
> Version of ImageJ
> Minimal reproducible code that causes your error or problem on your system
> Can you provide those?
> If you're on a Mac, look up how to disable AppNap for Java.
>
> On Mon, Jul 20, 2015 at 15:49 nelssara <[hidden
> email]</user/SendEmail.jtp?type=node&node=5013663&i=0>> wrote:
>
> > Thanks for your response Brandon! I'm not very good with computers, so I
> > don't exactly know what you are referring to when you mean "conditions".
> >
> >
> >
> > --
> > View this message in context:
> >
> http://imagej.1557.x6.nabble.com/Macro-has-slowed-down-dramatically-when-run-in-background-tp5013659p5013662.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
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://imagej.1557.x6.nabble.com/Macro-has-slowed-down-dramatically-when-run-in-background-tp5013659p5013663.html
> To unsubscribe from Macro has slowed down dramatically when run in
> background, click here<
> >.
> NAML<
>
http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
>
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Macro-has-slowed-down-dramatically-when-run-in-background-tp5013659p5013664.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
|

Re: Macro has slowed down dramatically when run in background

Brandon Hurr
I'd like to come back to this email. I am starting to see similar issues
with my machine. When running the macro in the foreground it is
significantly faster than if I switch to my browser, document, texteditor,
or even Activity Monitor and let FIJI run in the background.

I have disabled AppNap as below and it makes no difference.

It seems that people are starting to see this in other programs too,
including Matlab.

https://apple.stackexchange.com/questions/108897/might-mavericks-interfere-with-long-computations
https://discussions.apple.com/thread/6050740?start=0&tstart=0
http://compgroups.net/comp.soft-sys.matlab/matlab-and-app-nap-on-osx-mavericks/2127523

I'm not sure if the Matlab guy actually figured it out or if figure(h) is
related to how images are drawn on OSX in ImageJ.

Does anyone else have any ideas or a way to more rigorously test the
difference and understand what's going on?

Like Sarah, I expect ImageJ to run full tilt until it's finished, not run
at 50% of speed because I'm looking at a text file trying to fix another
macro.

Thanks,
Brandon

On Mon, Jul 20, 2015 at 4:26 PM, Brandon Hurr <[hidden email]>
wrote:

> Try disabling AppNap entirely and run your program:
> From:
> http://hints.macworld.com/article.php?story=20140508050203105
> Open Terminal (Applications/Utilities)
> Copy and Paste:
> defaults write NSGlobalDomain NSAppSleepDisabled -bool YES
> If it doesn't slow down after this then it's AppNap. If it still does then
> there is something else. You are supposed to be able to do this per
> application, but I've not seen how to effectively do it for Java programs
> like ImageJ/FIJI. Perhaps someone else can chime in.
>
> On Mon, Jul 20, 2015 at 16:14 nelssara <[hidden email]> wrote:
>
>> OK:
>>
>>
>> Mac OSX 10.10.4
>>
>> I'm not sure which version of java I am using or how to find that out
>>
>> I'm running FIJI with ImageJ version 2.0.0-rc-30/1.49u
>>
>>
>> And the code is posted above. I don't recieve an error it just runs VERY,
>> VERY slow if I am actively using another program.
>>
>>
>> Thanks for your help!!
>>
>>
>>
>> ________________________________
>> From: Brandon Hurr [via ImageJ] <[hidden email]>
>> Sent: Monday, July 20, 2015 4:54 PM
>> To: Nelson, Sarah
>> Subject: Re: Macro has slowed down dramatically when run in background
>>
>> It is very helpful to supply a minimal reproducible example and your
>> working environment when asking for help on lists and forums.
>> Things that are key for ImageJ would be:
>> Version and type of OS (Windows, Mac, Linux, UNIX)
>> Version of Java
>> Version of ImageJ
>> Minimal reproducible code that causes your error or problem on your system
>> Can you provide those?
>> If you're on a Mac, look up how to disable AppNap for Java.
>>
>> On Mon, Jul 20, 2015 at 15:49 nelssara <[hidden
>> email]</user/SendEmail.jtp?type=node&node=5013663&i=0>> wrote:
>>
>> > Thanks for your response Brandon! I'm not very good with computers, so I
>> > don't exactly know what you are referring to when you mean "conditions".
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> >
>> http://imagej.1557.x6.nabble.com/Macro-has-slowed-down-dramatically-when-run-in-background-tp5013659p5013662.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
>>
>>
>> ________________________________
>> If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://imagej.1557.x6.nabble.com/Macro-has-slowed-down-dramatically-when-run-in-background-tp5013659p5013663.html
>> To unsubscribe from Macro has slowed down dramatically when run in
>> background, click here<
>> >.
>> NAML<
>>
http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
>> >
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://imagej.1557.x6.nabble.com/Macro-has-slowed-down-dramatically-when-run-in-background-tp5013659p5013664.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