DICOM

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

DICOM

Tom Pot
Hi together!

I do have problems in opening DICOM-stacks and saving them to Analyze .img format. All my DICOM-stacks consist of 100 files and the first one has the description F0000000. They are stored in subfolders, I already have a small macro searching them:

requires("1.33s");
   dir = getDirectory("Select Subjects 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) {
       if (endsWith(path, "F0000000")) {
           run("Image Sequence...", "open=path number=100 starting=1 increment=1 scale=100 file=[] or=[] sort");
           rename("MR2 : 100 images");
           run("Analyze... ", "save=path.img");
           save(path);
           close();
      }
  }

The problem is the processFile- function, where I always get the following error:
"The save() macro function requires a file name extension."
Can anybody help with the syntax?!

Thanks in advance, TomP

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

Re: DICOM

ctrueden
Hi TomP,

> run("Analyze... ", "save=path.img");
> save(path);

Try:
run("Analyze... ", "save=[" + path + ".img]");

The 'run("Analyze... ", ...)' calls the File>Save As>Analyze... routine, so
you do not also need the call to the 'save' function.

Regards,
Curtis

On Wed, Mar 4, 2015 at 3:57 AM, Tom Pot <[hidden email]> wrote:

> Hi together!
>
> I do have problems in opening DICOM-stacks and saving them to Analyze .img
> format. All my DICOM-stacks consist of 100 files and the first one has the
> description F0000000. They are stored in subfolders, I already have a small
> macro searching them:
>
> requires("1.33s");
>    dir = getDirectory("Select Subjects 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) {
>        if (endsWith(path, "F0000000")) {
>            run("Image Sequence...", "open=path number=100 starting=1
> increment=1 scale=100 file=[] or=[] sort");
>            rename("MR2 : 100 images");
>            run("Analyze... ", "save=path.img");
>            save(path);
>            close();
>       }
>   }
>
> The problem is the processFile- function, where I always get the following
> error:
> "The save() macro function requires a file name extension."
> Can anybody help with the syntax?!
>
> Thanks in advance, TomP
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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