Batch Stack Focusing

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

Batch Stack Focusing

AC17
This post was updated on .
Hi all,

This is my first time attempting to write a macro in image J. I would really appreciate your help with this…

I have a main directory with multiple subdirectories. Each subdirectory contains multiple images (z stacks). I would like to write a code which will take my main directory and open a subdirectory , open all the images in that subdirectory, stack the images, run the stack focusing plugin and then save the stack in the corresponding folder. I would like to loop this so that all the subdirectories within my main directory are processed.

This is what I have so far. This code runs for a few minutes but I then can’t find my saved stacks.

   dir = getDirectory("Choose Main Directory");
   setBatchMode(true);
   count = 0;
   countFiles(dir);
   n = 0;
   processFiles(dir);
   print(count+" files processed");
   
   function countFiles(dir) {
      list = getFileList(dir);
      for (i=0; i<list.length; i++) {
          if (endsWith(list[i], "/"))
              countFiles(""+dir+list[i]);
          else
              count++;
      }
  }

   function processFiles(dir) {
      list = getFileList(dir);
      for (i=0; i<list.length; i++) {
          if (endsWith(list[i], "/"))
              processFiles(""+dir+list[i]);
          else {
             showProgress(n++, count);
             path = dir+list[i];
             processFile(path);
          }
      }
  }

  function processFile(path) {
for (i=0; i<list.length; i++)
         open(path);}
         {
          run("Images to Stack", "name=Stack title=[] use");
          run("Stack Focuser ", "enter=11");
           saveAs("Tiff", "stack" );
           close();
      }

Many thanks for your help!

Amy
Reply | Threaded
Open this post in threaded view
|

Re: Batch Stack Focusing

Daan VAN DEN BRINK
Hello Amy,

I had a super quick look at your macro. Could it be that the closing
bracket of the for-loop in the 'processFile(path)' function is not
enclosing all the commands?
Also, all you files will be named "stack".

Hope that helps.

Daan

On 27/03/17 14:08, AC17 wrote:

> Hi all,
>
> This is my first time attempting to write a macro in image J. I would really
> appreciate your help with this…
>
> I have a main directory with multiple subdirectories. Each subdirectory
> contains multiple images (z stacks). I would like to write a code which will
> take my main directory and open a subdirectory , open all the images in that
> subdirectory, stack the images, run the stack focusing plugin and then save
> the stack in the corresponding folder. I would like to loop this so that all
> the subdirectories within my main directory are processed.
>
> This is what I have so far. This code runs for a few minutes but I then
> can’t find my saved stacks.
>
>     dir = getDirectory("Choose image sequence folder");
>     setBatchMode(true);
>     count = 0;
>     countFiles(dir);
>     n = 0;
>     processFiles(dir);
>     print(count+" files processed");
>    
>     function countFiles(dir) {
>        list = getFileList(dir);
>        for (i=0; i<list.length; i++) {
>            if (endsWith(list[i], "/"))
>                countFiles(""+dir+list[i]);
>            else
>                count++;
>        }
>    }
>
>     function processFiles(dir) {
>        list = getFileList(dir);
>        for (i=0; i<list.length; i++) {
>            if (endsWith(list[i], "/"))
>                processFiles(""+dir+list[i]);
>            else {
>               showProgress(n++, count);
>               path = dir+list[i];
>               processFile(path);
>            }
>        }
>    }
>
>    function processFile(path) {
> for (i=0; i<list.length; i++)
>            open(path);}
>            {
>            run("Images to Stack", "name=Stack title=[] use");
>            run("Stack Focuser ", "enter=11");
>             saveAs("Tiff", "stack" );
>             close();
>        }
>
> Many thanks for your help!
>
> Amy
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--

*Daan M. VAN DEN BRINK*

Laboratoire de Biologie et Modélisation de la Cellule (LBMC) - UMR 5239

  Team Mollereau

*ENS de Lyon* — Site MONOD - LR2

   46 allée d'Italie — 69364 LYON CEDEX 07, FRANCE

   Tel.: +33 (0)4.72.72.89.29


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

Re: Batch Stack Focusing

AC17

Hello Daan,


Thank you for your reply!


I changed my code based on your recommendations but it still doesn't seem to be working. Some processing is happening and I don't receive any error messages but I don't see any files saved. Can you suggest anything else I could try?


Many thanks,


Amy




From: Daan VAN DEN BRINK [via ImageJ] <ml-node+[hidden email]>
Sent: 28 March 2017 16:03
To: AC17
Subject: Re: Batch Stack Focusing
 
Hello Amy,

I had a super quick look at your macro. Could it be that the closing
bracket of the for-loop in the 'processFile(path)' function is not
enclosing all the commands?
Also, all you files will be named "stack".

Hope that helps.

Daan

On 27/03/17 14:08, AC17 wrote:

> Hi all,
>
> This is my first time attempting to write a macro in image J. I would really
> appreciate your help with this…
>
> I have a main directory with multiple subdirectories. Each subdirectory
> contains multiple images (z stacks). I would like to write a code which will
> take my main directory and open a subdirectory , open all the images in that
> subdirectory, stack the images, run the stack focusing plugin and then save
> the stack in the corresponding folder. I would like to loop this so that all
> the subdirectories within my main directory are processed.
>
> This is what I have so far. This code runs for a few minutes but I then
> can’t find my saved stacks.
>
>     dir = getDirectory("Choose image sequence folder");
>     setBatchMode(true);
>     count = 0;
>     countFiles(dir);
>     n = 0;
>     processFiles(dir);
>     print(count+" files processed");
>    
>     function countFiles(dir) {
>        list = getFileList(dir);
>        for (i=0; i<list.length; i++) {
>            if (endsWith(list[i], "/"))
>                countFiles(""+dir+list[i]);
>            else
>                count++;
>        }
>    }
>
>     function processFiles(dir) {
>        list = getFileList(dir);
>        for (i=0; i<list.length; i++) {
>            if (endsWith(list[i], "/"))
>                processFiles(""+dir+list[i]);
>            else {
>               showProgress(n++, count);
>               path = dir+list[i];
>               processFile(path);
>            }
>        }
>    }
>
>    function processFile(path) {
> for (i=0; i<list.length; i++)
>            open(path);}
>            {
>            run("Images to Stack", "name=Stack title=[] use");
>            run("Stack Focuser ", "enter=11");
>             saveAs("Tiff", "stack" );
>             close();
>        }
>
> Many thanks for your help!
>
> Amy
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376.html


> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html


--

*Daan M. VAN DEN BRINK*

Laboratoire de Biologie et Modélisation de la Cellule (LBMC) - UMR 5239

  Team Mollereau

*ENS de Lyon* — Site MONOD - LR2

   46 allée d'Italie — 69364 LYON CEDEX 07, FRANCE

   Tel.: +33 (0)4.72.72.89.29


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





If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376p5018407.html

To unsubscribe from Batch Stack Focusing, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Batch Stack Focusing

Krs5
Dear Amy,

You don't give a directory where to save the files. Your " saveAs("Tiff", "stack" );" should read something like ' saveAs("Tiff", dir2+"stack" );' After the line " dir = getDirectory("Choose image sequence folder");" you can add a line  'dir 2= getDirectory("Choose folder to save results");' and of course you have to give the argument dir2 also to the correct function.

If you want to save the results in the original directory you can just use saveAs("Tiff", dir+"stack" );

Best wishes

Kees

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

ImageJ workhops 1 and 2 June: http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF/workshops/imagej-workshops-June-2017



-----Original Message-----
From: AC17 [mailto:[hidden email]]
Sent: 31 March 2017 17:27
To: [hidden email]
Subject: Re: Batch Stack Focusing

Hello Daan,


Thank you for your reply!


I changed my code based on your recommendations but it still doesn't seem to be working. Some processing is happening and I don't receive any error messages but I don't see any files saved. Can you suggest anything else I could try?


Many thanks,


Amy


________________________________
From: Daan VAN DEN BRINK [via ImageJ] <[hidden email]>
Sent: 28 March 2017 16:03
To: AC17
Subject: Re: Batch Stack Focusing

Hello Amy,

I had a super quick look at your macro. Could it be that the closing bracket of the for-loop in the 'processFile(path)' function is not enclosing all the commands?
Also, all you files will be named "stack".

Hope that helps.

Daan

On 27/03/17 14:08, AC17 wrote:

> Hi all,
>
> This is my first time attempting to write a macro in image J. I would
> really appreciate your help with this…
>
> I have a main directory with multiple subdirectories. Each
> subdirectory contains multiple images (z stacks). I would like to
> write a code which will take my main directory and open a subdirectory
> , open all the images in that subdirectory, stack the images, run the
> stack focusing plugin and then save the stack in the corresponding
> folder. I would like to loop this so that all the subdirectories within my main directory are processed.
>
> This is what I have so far. This code runs for a few minutes but I
> then can’t find my saved stacks.
>
>     dir = getDirectory("Choose image sequence folder");
>     setBatchMode(true);
>     count = 0;
>     countFiles(dir);
>     n = 0;
>     processFiles(dir);
>     print(count+" files processed");
>
>     function countFiles(dir) {
>        list = getFileList(dir);
>        for (i=0; i<list.length; i++) {
>            if (endsWith(list[i], "/"))
>                countFiles(""+dir+list[i]);
>            else
>                count++;
>        }
>    }
>
>     function processFiles(dir) {
>        list = getFileList(dir);
>        for (i=0; i<list.length; i++) {
>            if (endsWith(list[i], "/"))
>                processFiles(""+dir+list[i]);
>            else {
>               showProgress(n++, count);
>               path = dir+list[i];
>               processFile(path);
>            }
>        }
>    }
>
>    function processFile(path) {
> for (i=0; i<list.length; i++)
>            open(path);}
>            {
>            run("Images to Stack", "name=Stack title=[] use");
>            run("Stack Focuser ", "enter=11");
>             saveAs("Tiff", "stack" );
>             close();
>        }
>
> Many thanks for your help!
>
> Amy
>
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376.html
ImageJ - Batch Stack Focusing<http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376.html>
imagej.1557.x6.nabble.com
Batch Stack Focusing. Hi all, This is my first time attempting to write a macro in image J. I would really appreciate your help with this… I have a main directory with multiple subdirectories....



> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
ImageJ Mailing List - National Institutes of Health<http://imagej.nih.gov/ij/list.html>
imagej.nih.gov
home | news | docs | download | plugins | resources | list | links. ImageJ Mailing List The ImageJ mailing list is a discussion group for ImageJ users and developers.



--

*Daan M. VAN DEN BRINK*

Laboratoire de Biologie et Modélisation de la Cellule (LBMC) - UMR 5239

  Team Mollereau

*ENS de Lyon* — Site MONOD - LR2

   46 allée d'Italie — 69364 LYON CEDEX 07, FRANCE

   Tel.: +33 (0)4.72.72.89.29


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
ImageJ Mailing List - National Institutes of Health<http://imagej.nih.gov/ij/list.html>
imagej.nih.gov
home | news | docs | download | plugins | resources | list | links. ImageJ Mailing List The ImageJ mailing list is a discussion group for ImageJ users and developers.





________________________________
If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376p5018407.html
ImageJ - Batch Stack Focusing<http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376p5018407.html>
imagej.1557.x6.nabble.com
Batch Stack Focusing. Hi all, This is my first time attempting to write a macro in image J. I would really appreciate your help with this… I have a main directory with multiple subdirectories....


To unsubscribe from Batch Stack Focusing, click here<
NAML<
http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376p5018427.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: Batch Stack Focusing

AC17

Dear Kees,


Many thanks for your help! I have edited my code according to your suggestion but I still don't see any stacked images being saved. 


When I supplement the processfile(path) function to subtract the background of all the images, it does not that no problem. Perhaps the issue relates to the fact I'm trying to process each sequence of images within a single subfolder and not all the images at once?


Any other suggestions would be greatly appreciated!


Kind regards,


Amy




From: Straatman, Kees (Dr.) [via ImageJ] <ml-node+[hidden email]>
Sent: 01 April 2017 12:58
To: AC17
Subject: Re: Batch Stack Focusing
 
Dear Amy,

You don't give a directory where to save the files. Your " saveAs("Tiff", "stack" );" should read something like ' saveAs("Tiff", dir2+"stack" );' After the line " dir = getDirectory("Choose image sequence folder");" you can add a line  'dir 2= getDirectory("Choose folder to save results");' and of course you have to give the argument dir2 also to the correct function.

If you want to save the results in the original directory you can just use saveAs("Tiff", dir+"stack" );

Best wishes

Kees

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

ImageJ workhops 1 and 2 June: http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF/workshops/imagej-workshops-June-2017





-----Original Message-----
From: AC17 [mailto:[hidden email]]
Sent: 31 March 2017 17:27
To: [hidden email]
Subject: Re: Batch Stack Focusing

Hello Daan,


Thank you for your reply!


I changed my code based on your recommendations but it still doesn't seem to be working. Some processing is happening and I don't receive any error messages but I don't see any files saved. Can you suggest anything else I could try?


Many thanks,


Amy


________________________________
From: Daan VAN DEN BRINK [via ImageJ] <[hidden email]>
Sent: 28 March 2017 16:03
To: AC17
Subject: Re: Batch Stack Focusing

Hello Amy,

I had a super quick look at your macro. Could it be that the closing bracket of the for-loop in the 'processFile(path)' function is not enclosing all the commands?
Also, all you files will be named "stack".

Hope that helps.

Daan

On 27/03/17 14:08, AC17 wrote:

> Hi all,
>
> This is my first time attempting to write a macro in image J. I would
> really appreciate your help with this…
>
> I have a main directory with multiple subdirectories. Each
> subdirectory contains multiple images (z stacks). I would like to
> write a code which will take my main directory and open a subdirectory
> , open all the images in that subdirectory, stack the images, run the
> stack focusing plugin and then save the stack in the corresponding
> folder. I would like to loop this so that all the subdirectories within my main directory are processed.
>
> This is what I have so far. This code runs for a few minutes but I
> then can’t find my saved stacks.
>
>     dir = getDirectory("Choose image sequence folder");
>     setBatchMode(true);
>     count = 0;
>     countFiles(dir);
>     n = 0;
>     processFiles(dir);
>     print(count+" files processed");
>
>     function countFiles(dir) {
>        list = getFileList(dir);
>        for (i=0; i<list.length; i++) {
>            if (endsWith(list[i], "/"))
>                countFiles(""+dir+list[i]);
>            else
>                count++;
>        }
>    }
>
>     function processFiles(dir) {
>        list = getFileList(dir);
>        for (i=0; i<list.length; i++) {
>            if (endsWith(list[i], "/"))
>                processFiles(""+dir+list[i]);
>            else {
>               showProgress(n++, count);
>               path = dir+list[i];
>               processFile(path);
>            }
>        }
>    }
>
>    function processFile(path) {
> for (i=0; i<list.length; i++)
>            open(path);}
>            {
>            run("Images to Stack", "name=Stack title=[] use");
>            run("Stack Focuser ", "enter=11");
>             saveAs("Tiff", "stack" );
>             close();
>        }
>
> Many thanks for your help!
>
> Amy
>
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376.html
ImageJ - Batch Stack Focusing<http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376.html>
imagej.1557.x6.nabble.com
Batch Stack Focusing. Hi all, This is my first time attempting to write a macro in image J. I would really appreciate your help with this… I have a main directory with multiple subdirectories....



> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
ImageJ Mailing List - National Institutes of Health<http://imagej.nih.gov/ij/list.html>
imagej.nih.gov
home | news | docs | download | plugins | resources | list | links. ImageJ Mailing List The ImageJ mailing list is a discussion group for ImageJ users and developers.



--

*Daan M. VAN DEN BRINK*

Laboratoire de Biologie et Modélisation de la Cellule (LBMC) - UMR 5239

  Team Mollereau

*ENS de Lyon* — Site MONOD - LR2

   46 allée d'Italie — 69364 LYON CEDEX 07, FRANCE

   Tel.: +33 (0)4.72.72.89.29


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
ImageJ Mailing List - National Institutes of Health<http://imagej.nih.gov/ij/list.html>
imagej.nih.gov
home | news | docs | download | plugins | resources | list | links. ImageJ Mailing List The ImageJ mailing list is a discussion group for ImageJ users and developers.





________________________________
If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376p5018407.html
ImageJ - Batch Stack Focusing<http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376p5018407.html>
imagej.1557.x6.nabble.com
Batch Stack Focusing. Hi all, This is my first time attempting to write a macro in image J. I would really appreciate your help with this… I have a main directory with multiple subdirectories....


To unsubscribe from Batch Stack Focusing, click here<
NAML<
http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376p5018427.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



If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376p5018430.html
To unsubscribe from Batch Stack Focusing, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Batch Stack Focusing

Krs5
Dear Amy,

A few changes given as text // behind the lines. It might help to leave the Batchmode off till your macro works. Put // in front of the second line of code. You can then see what the macro actually is doing, or in your cased did not do, opening your files, and once that was solved opening your files multiple times. See if these changes solve the problem.


dir = getDirectory("Choose image sequence folder");
   setBatchMode(true);
      count = 0;
      countFiles(dir);
      n = 0;
      processFiles(dir);
      print(count+" files processed");
 
function countFiles(dir) {
        list = getFileList(dir);
        for (i=0; i<list.length; i++) {
                if (endsWith(list[i], "/"))
                        countFiles(""+dir+list[i]);
                else
                        count++;
        }
}
 
function processFiles(dir) {
        list = getFileList(dir);
        for (i=0; i<list.length; i++) {
                if (endsWith(list[i], "/"))
                        processFiles(dir+list[i]);
                else {
                        showProgress(n++, count);
                        path = dir+list[i];
                        processFile(path);
                        i = list.length; // This line takes care that all images in a directory are only analysed once
                }
        }
}
 
function processFile(path) {
        for (i=0; i<list.length; i++)
                open(path); // Removed a } what closed the function at this point
           
        run("Images to Stack", "name=Stack title=[] use");
        run("Stack Focuser ", "enter=11");
        saveAs("Tiff", dir+"stack");
        run("Close All"); // Take care that all images are closed
}


Best wishes

Kees


-----Original Message-----
From: AC17 [mailto:[hidden email]]
Sent: 03 April 2017 11:29
To: [hidden email]
Subject: Re: Batch Stack Focusing

Dear Kees,


Many thanks for your help! I have edited my code according to your suggestion but I still don't see any stacked images being saved.


When I supplement the processfile(path) function to subtract the background of all the images, it does not that no problem. Perhaps the issue relates to the fact I'm trying to process each sequence of images within a single subfolder and not all the images at once?


Any other suggestions would be greatly appreciated!


Kind regards,


Amy


________________________________
From: Straatman, Kees (Dr.) [via ImageJ] <[hidden email]>
Sent: 01 April 2017 12:58
To: AC17
Subject: Re: Batch Stack Focusing

Dear Amy,

You don't give a directory where to save the files. Your " saveAs("Tiff", "stack" );" should read something like ' saveAs("Tiff", dir2+"stack" );' After the line " dir = getDirectory("Choose image sequence folder");" you can add a line  'dir 2= getDirectory("Choose folder to save results");' and of course you have to give the argument dir2 also to the correct function.

If you want to save the results in the original directory you can just use saveAs("Tiff", dir+"stack" );

Best wishes

Kees

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

ImageJ workhops 1 and 2 June: http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF/workshops/imagej-workshops-June-2017
[http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF/aif-images/workshops/imagej-header/@@images/1742acb8-6a9a-406c-ad11-afd345bbea1a.jpeg]<http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF/workshops/imagej-workshops-June-2017>

ImageJ workshops — University of Leicester<http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF/workshops/imagej-workshops-June-2017>
www2.le.ac.uk
ImageJ workshops 'Introduction to ImageJ/Fiji' 1 st of June and 'Writing macros in ImageJ' 2 nd of June 2017. Registration form. ImageJ is a public domain image ...






-----Original Message-----
From: AC17 [mailto:[hidden email]</user/SendEmail.jtp?type=node&node=5018430&i=0>]
Sent: 31 March 2017 17:27
To: [hidden email]</user/SendEmail.jtp?type=node&node=5018430&i=1>
Subject: Re: Batch Stack Focusing

Hello Daan,


Thank you for your reply!


I changed my code based on your recommendations but it still doesn't seem to be working. Some processing is happening and I don't receive any error messages but I don't see any files saved. Can you suggest anything else I could try?


Many thanks,


Amy


________________________________
From: Daan VAN DEN BRINK [via ImageJ] <[hidden email]</user/SendEmail.jtp?type=node&node=5018430&i=2>>
Sent: 28 March 2017 16:03
To: AC17
Subject: Re: Batch Stack Focusing

Hello Amy,

I had a super quick look at your macro. Could it be that the closing bracket of the for-loop in the 'processFile(path)' function is not enclosing all the commands?
Also, all you files will be named "stack".

Hope that helps.

Daan

On 27/03/17 14:08, AC17 wrote:

> Hi all,
>
> This is my first time attempting to write a macro in image J. I would
> really appreciate your help with this…
>
> I have a main directory with multiple subdirectories. Each
> subdirectory contains multiple images (z stacks). I would like to
> write a code which will take my main directory and open a subdirectory
> , open all the images in that subdirectory, stack the images, run the
> stack focusing plugin and then save the stack in the corresponding
> folder. I would like to loop this so that all the subdirectories within my main directory are processed.
>
> This is what I have so far. This code runs for a few minutes but I
> then can’t find my saved stacks.
>
>     dir = getDirectory("Choose image sequence folder");
>     setBatchMode(true);
>     count = 0;
>     countFiles(dir);
>     n = 0;
>     processFiles(dir);
>     print(count+" files processed");
>
>     function countFiles(dir) {
>        list = getFileList(dir);
>        for (i=0; i<list.length; i++) {
>            if (endsWith(list[i], "/"))
>                countFiles(""+dir+list[i]);
>            else
>                count++;
>        }
>    }
>
>     function processFiles(dir) {
>        list = getFileList(dir);
>        for (i=0; i<list.length; i++) {
>            if (endsWith(list[i], "/"))
>                processFiles(""+dir+list[i]);
>            else {
>               showProgress(n++, count);
>               path = dir+list[i];
>               processFile(path);
>            }
>        }
>    }
>
>    function processFile(path) {
> for (i=0; i<list.length; i++)
>            open(path);}
>            {
>            run("Images to Stack", "name=Stack title=[] use");
>            run("Stack Focuser ", "enter=11");
>             saveAs("Tiff", "stack" );
>             close();
>        }
>
> Many thanks for your help!
>
> Amy
>
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376.html
ImageJ - Batch Stack Focusing<http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376.html>
imagej.1557.x6.nabble.com
Batch Stack Focusing. Hi all, This is my first time attempting to write a macro in image J. I would really appreciate your help with this… I have a main directory with multiple subdirectories....



> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
ImageJ Mailing List - National Institutes of Health<http://imagej.nih.gov/ij/list.html>
imagej.nih.gov
home | news | docs | download | plugins | resources | list | links. ImageJ Mailing List The ImageJ mailing list is a discussion group for ImageJ users and developers.



--

*Daan M. VAN DEN BRINK*

Laboratoire de Biologie et Modélisation de la Cellule (LBMC) - UMR 5239

  Team Mollereau

*ENS de Lyon* — Site MONOD - LR2

   46 allée d'Italie — 69364 LYON CEDEX 07, FRANCE

   Tel.: +33 (0)4.72.72.89.29


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
ImageJ Mailing List - National Institutes of Health<http://imagej.nih.gov/ij/list.html>
imagej.nih.gov
home | news | docs | download | plugins | resources | list | links. ImageJ Mailing List The ImageJ mailing list is a discussion group for ImageJ users and developers.





________________________________
If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376p5018407.html
ImageJ - Batch Stack Focusing<http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376p5018407.html>
imagej.1557.x6.nabble.com
Batch Stack Focusing. Hi all, This is my first time attempting to write a macro in image J. I would really appreciate your help with this… I have a main directory with multiple subdirectories....


To unsubscribe from Batch Stack Focusing, click here< NAML<http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376p5018427.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


________________________________
If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376p5018430.html
To unsubscribe from Batch Stack Focusing, click here<
NAML<
http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://imagej.1557.x6.nabble.com/Batch-Stack-Focusing-tp5018376p5018438.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: Batch Stack Focusing

AC17
Dear Kees,

Apologies for the late reply. I just tested your code and it works perfectly.

Thank you for your help, I really appreciate it! You have saved me a lot of time!

Kind regards,

Amy