macro adjusting for batch analyses

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

macro adjusting for batch analyses

robijn
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: macro adjusting for different names

George Patterson-3
If the images have unique names, something like the edits included in your macro below should work.

However, I'm guessing that's not really what you need.  If you can give a little more information, we might be able to come up with a solution.

Are the images you wish to process located in separate directories and have identical names?
If so, are those directories located in the same place?
And from your code it looks like you wish to save the all of the results files in a single folder separate from the image folders?

George

On May 21, 2013, at 8:59 AM, robijn wrote:

> I have made a macro that runs the way i want it to, except that we want to
> evaluate a bigger batch of pictures and for each picture i now have to
> adjust the name and "the save as" location (as it would otherwise overscribe
> it). does anyone has suggestions as to how to solve this? see the lines in
> bold
>
>
>
> *LysosomeChannel="With_OxLDL.tif (green)"
> NucleusChannel="With_OxLDL.tif (blue)"*
> LysosomePic="lysosomes1"
> //
> selectWindow(LysosomeChannel);
LysosomeTitle=getTitle();// this will unfortunately have (green) and some spaces in the name
//Unless you need to process the images before running the macro, you might have a bit to split channels.  It'll make it easier to get the file name without the extra (green).
//Alternatively, you could parse that string and rid yourself of the (green)
> run("Properties...", "channels=1 slices=24 frames=1 unit=micron
> pixel_width=0.169 pixel_height=0.169 voxel_depth=0.169 frame=[0 sec]
> origin=0,0");
> selectWindow(NucleusChannel);
NucleusTitle=getTitle();
> run("Properties...", "channels=1 slices=24 frames=1 unit=micron
> pixel_width=0.169 pixel_height=0.169 voxel_depth=0.169 frame=[0 sec]
> origin=0,0");
> run("Object Counter3D", "threshold=25 slice=10 min=10 max=20971520
> new_results geometrical dot=3 numbers font=12 summary");
> selectWindow("Results from "+NucleusChannel);
> *saveAs("Results", "L:\lysosomal_measurements/results_nucleus1.xls");*
saveAs("Results","L:"+File.separator+"lysosomal_measurements"+File.separator+NucleusTitle+"_results_nucleus1.xls");

> run("Close")
> selectWindow("Geometrical Centres "+NucleusChannel);
> close();
> selectWindow(NucleusChannel);
> close();
> selectWindow(LysosomeChannel);
> run("Duplicate...", "title="+LysosomePic+" duplicate range=1-24");
> selectWindow(LysosomePic);
> run("Object Counter3D", "threshold=40 slice=10 min=10 max=20971520
> new_results geometrical dot=3 numbers font=12 summary");
> run("3D Watershed", "seeds_threshold=1 image_threshold=20
> image="+LysosomePic+" seeds=Geometrical radius=2");
> selectWindow("watershed");
> run("Properties...", "channels=1 slices=24 frames=1 unit=micron
> pixel_width=0.169 pixel_height=0.169 voxel_depth=0.169 frame=[0 sec]
> origin=0,0");
> run("3D Manager Options", "volume surface centroid_(pix) centroid_(unit)
> distance_between_centers=10 distance_max_contact=1.80");
> run("3D Manager");
> Ext.Manager3D_AddImage();
> selectWindow(LysosomePic);
> Ext.Manager3D_MultiSelect();
> Ext.Manager3D_SelectAll();
> Ext.Manager3D_Select(0);
> Ext.Manager3D_Measure();
> selectWindow("3D Measure");
> *saveAs("Results", "L:\lysosomal_measurements/results_lysosomes1.xls");*
saveAs("Results","L:"+File.separator+"lysosomal_measurements"+File.separator+LysosomeTitle+"_results_lysosomes1.xls");

> run("Close All");
> selectWindow("3D Measure");
> run("Close");
> selectWindow("Log");
> run("Close");
> selectWindow("Results from lysosomes1");
> run("Close");
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/macro-adjusting-for-different-names-tp5003067.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

George H. Patterson
Building 13 3E33
13 South Drive
Biophotonics Section
National Institute of Biomedical Imaging and Bioengineering
National Institutes of Health
Bethesda, MD 20892
Office: 301-443-0241
Fax: 301-496-6608
[hidden email]

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

Re: macro adjusting for different names

robijn
This post was updated on .
The files are going to be located in the same directory with names like this: exp17_1, Exp17_2 etc. I would like to have a specific excel file for each picture, thus that the excel file wil be named Exp17_1_nu and Exp17_1_ ly, exp17_2_nu and Exp17_2_ly or something alike. either in the same directory or in a different map.
Reply | Threaded
Open this post in threaded view
|

Re: macro adjusting for different names

Jean-François GILLES
In reply to this post by George Patterson-3
You need to specify your directory at the beginning of the macro, like
this :
dir = getDirectory("My directory");
list = getFileList(dir);
sep = File.separator;

Do a loop to open your images :

for (f=0; f<list.length; f++) {
     if (endsWith(list[f], "-green.tif")){//for example
         open(dir+sep+list[f]);
         print(list[f]);
         name = File.nameWithoutExtension;//The name of the last file
opened with the extension removed, it can help you.
         print(name);
     }
}

Your "save as" will be easier :
saveAs("Results", dir+sep+name+"-Results.xls");

Think about nSlices in your code if your images don't have the same
number of slices...

Jean-François GILLES

Le 21/05/2013 16:00, George Patterson a écrit :

> If the images have unique names, something like the edits included in your macro below should work.
>
> However, I'm guessing that's not really what you need.  If you can give a little more information, we might be able to come up with a solution.
>
> Are the images you wish to process located in separate directories and have identical names?
> If so, are those directories located in the same place?
> And from your code it looks like you wish to save the all of the results files in a single folder separate from the image folders?
>
> George
>
> On May 21, 2013, at 8:59 AM, robijn wrote:
>
>> I have made a macro that runs the way i want it to, except that we want to
>> evaluate a bigger batch of pictures and for each picture i now have to
>> adjust the name and "the save as" location (as it would otherwise overscribe
>> it). does anyone has suggestions as to how to solve this? see the lines in
>> bold
>>
>>
>>
>> *LysosomeChannel="With_OxLDL.tif (green)"
>> NucleusChannel="With_OxLDL.tif (blue)"*
>> LysosomePic="lysosomes1"
>> //
>> selectWindow(LysosomeChannel);
> LysosomeTitle=getTitle();// this will unfortunately have (green) and some spaces in the name
> //Unless you need to process the images before running the macro, you might have a bit to split channels.  It'll make it easier to get the file name without the extra (green).
> //Alternatively, you could parse that string and rid yourself of the (green)
>> run("Properties...", "channels=1 slices=24 frames=1 unit=micron
>> pixel_width=0.169 pixel_height=0.169 voxel_depth=0.169 frame=[0 sec]
>> origin=0,0");
>> selectWindow(NucleusChannel);
> NucleusTitle=getTitle();
>> run("Properties...", "channels=1 slices=24 frames=1 unit=micron
>> pixel_width=0.169 pixel_height=0.169 voxel_depth=0.169 frame=[0 sec]
>> origin=0,0");
>> run("Object Counter3D", "threshold=25 slice=10 min=10 max=20971520
>> new_results geometrical dot=3 numbers font=12 summary");
>> selectWindow("Results from "+NucleusChannel);
>> *saveAs("Results", "L:\lysosomal_measurements/results_nucleus1.xls");*
> saveAs("Results","L:"+File.separator+"lysosomal_measurements"+File.separator+NucleusTitle+"_results_nucleus1.xls");
>> run("Close")
>> selectWindow("Geometrical Centres "+NucleusChannel);
>> close();
>> selectWindow(NucleusChannel);
>> close();
>> selectWindow(LysosomeChannel);
>> run("Duplicate...", "title="+LysosomePic+" duplicate range=1-24");
>> selectWindow(LysosomePic);
>> run("Object Counter3D", "threshold=40 slice=10 min=10 max=20971520
>> new_results geometrical dot=3 numbers font=12 summary");
>> run("3D Watershed", "seeds_threshold=1 image_threshold=20
>> image="+LysosomePic+" seeds=Geometrical radius=2");
>> selectWindow("watershed");
>> run("Properties...", "channels=1 slices=24 frames=1 unit=micron
>> pixel_width=0.169 pixel_height=0.169 voxel_depth=0.169 frame=[0 sec]
>> origin=0,0");
>> run("3D Manager Options", "volume surface centroid_(pix) centroid_(unit)
>> distance_between_centers=10 distance_max_contact=1.80");
>> run("3D Manager");
>> Ext.Manager3D_AddImage();
>> selectWindow(LysosomePic);
>> Ext.Manager3D_MultiSelect();
>> Ext.Manager3D_SelectAll();
>> Ext.Manager3D_Select(0);
>> Ext.Manager3D_Measure();
>> selectWindow("3D Measure");
>> *saveAs("Results", "L:\lysosomal_measurements/results_lysosomes1.xls");*
> saveAs("Results","L:"+File.separator+"lysosomal_measurements"+File.separator+LysosomeTitle+"_results_lysosomes1.xls");
>> run("Close All");
>> selectWindow("3D Measure");
>> run("Close");
>> selectWindow("Log");
>> run("Close");
>> selectWindow("Results from lysosomes1");
>> run("Close");
>>
>>
>>
>>
>> --
>> View this message in context: http://imagej.1557.x6.nabble.com/macro-adjusting-for-different-names-tp5003067.html
>> Sent from the ImageJ mailing list archive at Nabble.com.
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> George H. Patterson
> Building 13 3E33
> 13 South Drive
> Biophotonics Section
> National Institute of Biomedical Imaging and Bioengineering
> National Institutes of Health
> Bethesda, MD 20892
> Office: 301-443-0241
> Fax: 301-496-6608
> [hidden email]
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>
>

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