beginner macro question - window selection after BioFormats plug-in

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

beginner macro question - window selection after BioFormats plug-in

Cath Heyward
Hi all,

I'm trying to write my first macro to open 4-channel Olympus .oib files from a source directory into separate channels, subtract background and resave as separate channels.

So far I have

dir1 = getDirectory("Choose source directory"); // to select folder of files to work on
list = getFileList(dir1);
dir2 = getDirectory("Choose destination directory"); // where to put the saved files

for (i=0; i<list.length; i++){
        path = dir1+list[i];
        open(path);
        title1 = getTitle;
        if(matches(title1,".*C=0.*"))
        run("Subtract Background...", "rolling=10 sliding stack");
        run("8-bit");
        }

but it ignores my attempt to select the channel C=0, and instead processes the C=3 image which was opened last (the name of the file I am trying to select is actually "loc1.oib - C=0" after opening with BioFormats).
What am I doing wrong? Is it something to do with spaces in the filename?

Any help gratefully received. Or if there is a "beginners' common mistakes" thread somewhere then please put me onto it!

Thanks,

Cath
 
Reply | Threaded
Open this post in threaded view
|

Re: beginner macro question - window selection after BioFormats plug-in

Krs5
Dear Cath,

You have to select the window you want to work on. Something like:

selectWindow(title1+" - C=0"); instead of if(matches(title1,".*C=0.*"))

Best wishes

Kees


Dr Ir K.R. Straatman
Senior Experimental Officer
Centre for Core Biotechnology Services
University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Cath Heyward
Sent: 01 May 2014 12:03
To: [hidden email]
Subject: beginner macro question - window selection after BioFormats plug-in

Hi all,

I'm trying to write my first macro to open 4-channel Olympus .oib files from a source directory into separate channels, subtract background and resave as separate channels.

So far I have

dir1 = getDirectory("Choose source directory"); // to select folder of
files to work on
list = getFileList(dir1);
dir2 = getDirectory("Choose destination directory"); // where to put the
saved files

for (i=0; i<list.length; i++){
        path = dir1+list[i];
        open(path);
        title1 = getTitle;
        if(matches(title1,".*C=0.*"))
        run("Subtract Background...", "rolling=10 sliding stack");
        run("8-bit");
        }

but it ignores my attempt to select the channel C=0, and instead processes the C=3 image which was opened last (the name of the file I am trying to select is actually "loc1.oib - C=0" after opening with BioFormats).
What am I doing wrong? Is it something to do with spaces in the filename?

Any help gratefully received. Or if there is a "beginners' common mistakes"
thread somewhere then please put me onto it!

Thanks,

Cath
 



--
View this message in context: http://imagej.1557.x6.nabble.com/beginner-macro-question-window-selection-after-BioFormats-plug-in-tp5007534.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: beginner macro question - window selection after BioFormats plug-in

Cath Heyward
Thanks to all those who replied, on and off board. I have a lot to learn and will enjoy trying out all your suggestions!
Thanks,

Cath