Login  Register

Re: passing path and filename to Analyze_Writer or Nifti_Writer

Posted by Wayne Rasband on Mar 31, 2008; 1:16am
URL: http://imagej.273.s1.nabble.com/passing-path-and-filename-to-Analyze-Writer-or-Nifti-Writer-tp3696746p3696747.html

> In my macros, I'd like to pass a path and filename to the
> analyze writer and nifti writer plugins.
>
> run("Analyze 7.5") opens a save dialog box, but I can't seem
> to pass path and filename arguments to it using the run()
> syntax.  A method that excludes the save dialog box would
> be fine too, since I'm pre-specifying the path and filename.
>
> I'm new to imagej macros and plugins, so feel free to point
> me to existing documentation if I've missed something obvious.

Save an image with the command recorder (Plugins>Macros>Record)  
running and it will generate a run() function with the correct  
syntax. Here is an example:

    run("Analyze 7.5", "save=/Users/wayne/bridge.img");

Use string concatenation to pass the path as a variable:

    path = "/Users/wayne/bridge.img";
    run("Analyze 7.5", "save="+path);

Enclose the path in square brackets if it could possibly contain spaces:

    run("Analyze 7.5", "save=["+path+"]");

-wayne