Problem with batch duplicate and Z projection

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

Problem with batch duplicate and Z projection

ziqing liu
Hi everyone,

I'm totally a beginner of ImageJ. I have a huge amount of live cell imaging data and I want to write a macro to batch process them.
These data are lsm files with 3 channels (Red, Green and DIC), 13 Z stacks. I want to:
1. Duplicate to get Red & Green channel only
2. Z projection of the red&green only stack
3. Duplicate to get one slice of DIC channel (the most focused slice) for each stack

Here is what I wrote based on sample macros I found online:

dir1 = getDirectory("Choose Source Directory ");
  dir2 = getDirectory("Choose Destination Directory for R&G ");
   dir3 = getDirectory("Choose Destination Directory for DIC");
   list = getFileList(dir1);
   setBatchMode(true);
   for (i=0; i<list.length; i++) {
      showProgress(i+1, list.length);
      open(dir1+list[i]);
      filename = getInfo("image.filename");
      run ("Duplicate...", "title= R&G" + filename, "duplicate channels=1-2, slices=1-13");
      run("Z Project...", "start=1 stop=13 projection=[Max Intensity]");
      save(dir2+list[i]);
      close();
      selectWindow(filename);
      run("Duplicate...", "title=DIC" + filename, " duplicate channels=3 slices=7");
      save(dir3+list[i]);
      close();
  }

But then when I run it, it pops out the following messages:

java.lang.NullPointerException
        at org.imagearchive.lsm.reader.Reader.open(Reader.java:62)
        at LSM_Reader.run(LSM_Reader.java:46)
        at ij.IJ.runUserPlugIn(IJ.java:183)
        at ij.IJ.runPlugIn(IJ.java:150)
        at ij.IJ.runPlugIn(IJ.java:139)
        at HandleExtraFileTypes.tryPlugIn(HandleExtraFileTypes.java:278)
        at HandleExtraFileTypes.tryOpen(HandleExtraFileTypes.java:152)
        at HandleExtraFileTypes.openImage(HandleExtraFileTypes.java:242)
        at HandleExtraFileTypes.run(HandleExtraFileTypes.java:37)
        at ij.IJ.runUserPlugIn(IJ.java:183)
        at ij.IJ.runPlugIn(IJ.java:150)
        at ij.IJ.runPlugIn(IJ.java:139)
        at ij.io.Opener.openWithHandleExtraFileTypes(Opener.java:410)
        at ij.io.Opener.openImage(Opener.java:287)
        at ij.io.Opener.openImage(Opener.java:306)
        at ij.io.Opener.open(Opener.java:137)
        at ij.IJ.open(IJ.java:1429)
        at ij.macro.Functions.open(Functions.java:2288)
        at ij.macro.Functions.doFunction(Functions.java:141)
        at ij.macro.Interpreter.doStatement(Interpreter.java:203)
        at ij.macro.Interpreter.doBlock(Interpreter.java:526)
        at ij.macro.Interpreter.doStatement(Interpreter.java:239)
        at ij.macro.Interpreter.doFor(Interpreter.java:472)
        at ij.macro.Interpreter.doStatement(Interpreter.java:221)
        at ij.macro.Interpreter.doStatements(Interpreter.java:191)
        at ij.macro.Interpreter.runMacro(Interpreter.java:128)
        at ij.macro.MacroRunner.run(MacroRunner.java:143)
        at java.lang.Thread.run(Unknown Source)

It seems that my lsm files could not be opened. Why is that happening and how do I fix that? Is there any other obvious mistake/bug in the macro I wrote?

 Thank you very much for your help!

Ziqing