1

I just recently started to work with ImageJ (and thus do not have much experience with macro programming) to analyze my microscopy pictures. In order to generate FRET pixel-by-pixel images that are corrected for spectral bleed through I am using the plug in: pixFRET. This plug in requires a stack of 3 images to work: FRET, Donor, Acceptor. So far, I have to open every picture myself and this is REALLY inconvenient for large time stacks (> 1000 images). I am looking for a way to loop the plug in or create some kind of macro to do this.

A short description of my Data structure: workfolder\filename_t001c1 (Channel 1 Image - Donor at time point 001), filename_t001c2 (Channel 2 Image - FRET at time point 001), ...t001c3 (can be neglected) ...t001c4 (Channel 4 Image - Acceptor at time point 001).

I would have to create a stack of C2/C1/C4 at each time point that is automatically analyzed by pixFRET (with set parameters) and the result should be saved in an output folder.

I am grateful for every suggestion as my biggest problem is the looping of this whole stack generation/pixFRET analysis (can only do this manual right now).

Thanks David

Jan Eglinger
  • 3,995
  • 1
  • 25
  • 51
David G
  • 21
  • 4

2 Answers2

1

I did not find a way to directly include the parameters and commands from the pixFRET PlugIn. However, here I show a work around that works with IJ_Robot to add these commands. I further included some stuff to perform a alignment of the camera channels based on the first images of the time series.

   // Macro for creating time resolved pixFRET images with a alignment of both cameras used
// a separate setting file is required for pixFRET -> put this into the same folder as the pixFRET plugin
// the background region has to be set manually in this macro
// IJ_robot uses cursor movements - DO NOT move the cursor while excuting the macro + adjust IJ_robot coordinates when changing the resolution/system.




dir = getDirectory("Select Directory");
list = getFileList(dir);

//single alignment
 run("Image Sequence...", "open=[dir] number=2 starting=1 increment=1 scale=100 file=[] or=[] sort");
rename(File.getName(dir));
WindowTitle=getTitle()
rename(WindowTitle+toString(" Main"))
MainWindow=getTitle()
NSlices=getSliceNumber()
xValue=getWidth()/2
yValue=getHeight()/2

//setTool("rectangle");
makeRectangle(0, 0, xValue, yValue);
run("Align slices in stack...", "method=5 windowsizex="+toString(xValue*2-20)+" windowsizey="+toString(yValue*2-20)+" x0=10 y0=10 swindow=0 ref.slice=1 show=true");
selectWindow("Results");

XShift=getResult("dX", 0);
YShift=getResult("dY", 0);


File.makeDirectory(toString(File.getParent(dir))+toString("\\")+"test"+" FRET");

for(i=0;i<list.length;i+=4){
open(dir+list[i+1]);
run("Translate...", "x=XShift y=YShift interpolation=None stack");

open(dir+list[i]);


open(dir+list[i+3]);
run("Translate...", "x=XShift y=YShift interpolation=None stack");

wait(1000);
run("Images to Stack", "name=Stack title=[] use");
selectWindow("Stack");
makeRectangle(15, 147, 82, 75); //background region
run("PixFRET...");
run("IJ Robot", "order=Left_Click x_point=886 y_point=321 delay=500 keypress=[]");
run("IJ Robot", "order=Left_Click x_point=874 y_point=557 delay=500 keypress=[]");
selectWindow("NFRET (x100) of Stack");

save(toString(File.getParent(dir))+toString("\\")+"test"+" FRET"+toString(i) +".tif");

selectWindow("Stack");
close();
selectWindow("FRET of Stack");
close();

selectWindow("NFRET (x100) of Stack");
close();
run("IJ Robot", "order=Left_Click x_point=941 y_point=57 delay=300 keypress=[]");
}

Thanks for your help Jan. If you can think of a way to call these pixFRET commands directly rather than using Ij_robot, please let me know.

David G
  • 21
  • 4
0

Take this tutorial from Fiji (is just ImageJ) as a starting point, and use the macro recorder (Plugins > Macros > Record...) to get the neccessary commands.

Your macro code could then look something like this:

function pixfret(path, commonfilename) {
    open(path + commonfilename + "c2");
    open(path + commonfilename + "c1");
    open(path + commonfilename + "c4");
    run("Images to Stack", "name=Stack title=[] use");
    run("PixFRET"); // please adjust this to your needs
}

setBatchMode(true); 
n_timepoints = 999;
dir = "/path/to/your/images/";
for (i = 0; i < n_timepoints; i++)
    pixfret(dir, "filename_t" + IJ.pad(i, 4));
setBatchMode(false);

Hope that helps.

Jan Eglinger
  • 3,995
  • 1
  • 25
  • 51
  • Hi, thanks for your reply. Do you have any idea, if it is possible to control the pixFRET plugin from this macro? I already tried to run pixFRET from a macro recorded with the macrorecorder but it stops with the open pixFRET windows. There is for example one button that has to be pressed called "Compute FRET" aswell as the selection of the background 3 buttons to be pressed with a predefined ROI: Reset/Get/Add . I will now try to use "IJ_Robot", but if there is any alternative/easier way to make this work let me know. Thanks David – David G Jun 04 '13 at 16:08