http://imagej.273.s1.nabble.com/Problem-with-split-channels-tp5009703p5009714.html
it looks as if it is a kind of race condition. ImageJ uses threads to
execute them in parallel or at least nearly in parallel. The outcome of
on the routines and how they can be executed. Displaying images is time
consuming and, as Wayne has pointed out, is handled in a separate thread...
clumsy or slow and even may lead to other problems.
I'm sure you will find a way to interrupt batchmode.
> Hi wayne,
>
> I disabled batch mode to troubleshoot the overlays issue i posted
> previously and in doing so solved that issue but then created the
> split channels problem. The macro code you posted demonstrated the
> issue and when that is ran in batch mode it always selects the right
> image post split channels. However in my actual macro code it still
> activates the wrong image. Below is a selection of the code where
> the error occurs, i might add that batch mode is enabled prior to
> this segment but i then have to exit to allow the user to add ROI's
> to an image. I still don't understand where the issue lies, the
> image "merge" is definitely the image to be split because the print
> function suggests so, but then when i query the active image post
> split, the wrong image is active. Is it a problem to enable/disable
> batch mode multiple times? I know the recommendation is only to use
> it once, but here i need access to the image.
>
> Thanks,
>
> Matt
>
>
> run("Z Project...", "projection=[Max Intensity]"); run("Specify...",
> "width=30 height=30 x=148 y=116 slice=1 oval"); run("ROI
> Manager..."); setTool("oval"); setBatchMode("exit and display");
> waitForUser("Add spots", "Move ROI over spots\n"+"Press t to add to
> ROI Manager"); setBatchMode(true); close();//close the projection
> image selectImage(merge); what1=getTitle; print(what1); run("Split
> Channels"); what=getTitle; print(what); ch3=getImageID(); ch2=ch3+1;
> ch1=ch3+2; print(ch3); print(ch2); print(ch1); ch3 is DAPI channel
> selectImage(ch3); close(); selectImage(ch2);
>
> On 22 Sep 2014, at 16:24, "Rasband, Wayne (NIH/NIMH) [E]"
> <
[hidden email]> wrote:
>
>> On Sep 21, 2014, at 9:41 AM, Matt Pearson wrote:
>>
>>> Hi all,
>>>
>>> I also have a problem with split channels. I'm using it within a
>>> macro and i have two images, one is a single 16bit image the
>>> other is a 3 colour composite. I'm using the print function to
>>> troubleshoot. Basically i want the merged image to be split into
>>> its RGB components. Firstly i use selectImage to activate the
>>> composite image to be split. The print command confirms that the
>>> composite image is being activated prior to split. The image is
>>> split and produces the 3 component images. I then have a
>>> getTitle function to see which image is active post split
>>> channels and its the 16bit image that i mentioned earlier, not
>>> the last component image of the composite.
>>>
>>> Perhaps this is normally behaviour that the last newly created
>>> window when using split channels does not automatically become
>>> activated? I've just never had an issue with this before and
>>> i've used split channels in a macro many times.
>>
>> Are you using batch mode? These types of problems are less likely
>> in batch mode because images are not displayed and activated on a
>> separate thread. For example, the following macro always outputs
>> "C3-Composite" when run in batch mode but it sometimes displays
>> "Overlays" when not run it batch mode. The macro also runs *much*
>> faster in batch mode.
>>
>> setBatchMode(true); newImage("Overlays", "16-bit black", 400, 400,
>> 1); newImage("Composite", "RGB random", 400, 400, 1); run("Make
>> Composite"); run("Split Channels"); print(getTitle);
>>
>> -wayne
>>
>> -- ImageJ mailing list:
http://imagej.nih.gov/ij/list.html