passing arguments that have escape characters in them?

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

passing arguments that have escape characters in them?

Aleks Spurmanis
Dear list:

I'm trying to set up a macro that will do a color sep on a multi-color LSM
z-stack and then pass the separated channels as arguments to the MetroloJ
plug-in for co-registration analysis (
http://imagejdocu.tudor.lu/doku.php?id=plugin:analysis:metroloj:start ).
 It looks like I'm generating the variables correctly but they don't get
passed to the MetroloJ function correctly and the macro just hangs without
generating the report.  It seems to me that what could be missing are the
proper escape characters for the file paths (e.g., instead of inputting
D:\Coreg\blahblahblah.pdf it should be D:\\Coreg\\blahblahblah.pdf).  I
tried using the replace command to substitute "\\"s for "\" in my string
variables but this generates a regex error.  It seems like it should be
simple to do but I can't seem to figure it out.  I've included my sample
code below for reference.  Can somebody tell me what I'm missing here?

Thanks,

Aleks Spurmanis
Microscopy Specialist
McGill University Life Sciences Complex Imaging Facility


<code>
// Adding automated image color separation to feed into MetroloJ plug-in


//User is prompted to select multichannel z-stack of tetra-speck bead
//Image MUST BE CROPPED to contain only one bead
  path = File.openDialog("Select a File");
  open(path); // open the file
  dir = File.getParent(path)+"\\";
  name = File.getName(path);
  trunc=substring(name,0,indexOf(name,".tif")); // creates variable with
TIF extension from the filename removed
  rept=trunc+".pdf"; // creates variable with PDF extension added to
generate the report name
  ReptPath=dir+rept; // creates variable to assign the report path


//The image is separated into multiple channels (up to 4 possible channels
can be used)
  run("Split Channels");
  violet="C1-"+name; // creates variable for violet (405nm) channel
  blue="C2-"+name; // creates variable for blue (488 nm) channel
  green="C3-"+name; // creates variable for green (543 nm) channel
  red="C4-"+name; // creates variable for red (633 nm) channel

// Optional echoes to verify correct assignment of variables (can be
removed or commented out)
  print("Path:", path);
  print("Name:", name);
  print("Directory:", dir);
  print("Reportname:", rept);
  print("Report path:", ReptPath);
  print("violet channel:", violet);
  print("blue channel:", blue);
  print("green channel:", green);
  print("red channel:", red);


//Passing variables to MetroloJ plug-in
run("Generate co-alignement report", "title_of_report=&name stack_1=&red
stack_2=&green stack_3=&blue microscope=Confocal wavelength_1=633
wavelength_2=543 wavelength_3=488 na=1.40 pinhole=1 text1=[Sample infos]
text2=Comments save=&rept");
run("Close All");   //closes all open images
</code>
Reply | Threaded
Open this post in threaded view
|

Re: passing arguments that have escape characters in them?

BenTupper
Hi,

You might try changing...

> dir = File.getParent(path)+"\\";

... to this ...

dir = File.getParent(path) + File.separator;

See http://rsb.info.nih.gov/ij/developer/macro/functions.html#F 

Cheers,
Ben


On Feb 26, 2012, at 5:12 PM, Aleks Spurmanis wrote:

> Dear list:
>
> I'm trying to set up a macro that will do a color sep on a multi-color LSM
> z-stack and then pass the separated channels as arguments to the MetroloJ
> plug-in for co-registration analysis (
> http://imagejdocu.tudor.lu/doku.php?id=plugin:analysis:metroloj:start ).
> It looks like I'm generating the variables correctly but they don't get
> passed to the MetroloJ function correctly and the macro just hangs without
> generating the report.  It seems to me that what could be missing are the
> proper escape characters for the file paths (e.g., instead of inputting
> D:\Coreg\blahblahblah.pdf it should be D:\\Coreg\\blahblahblah.pdf).  I
> tried using the replace command to substitute "\\"s for "\" in my string
> variables but this generates a regex error.  It seems like it should be
> simple to do but I can't seem to figure it out.  I've included my sample
> code below for reference.  Can somebody tell me what I'm missing here?
>
> Thanks,
>
> Aleks Spurmanis
> Microscopy Specialist
> McGill University Life Sciences Complex Imaging Facility
>
>
> <code>
> // Adding automated image color separation to feed into MetroloJ plug-in
>
>
> //User is prompted to select multichannel z-stack of tetra-speck bead
> //Image MUST BE CROPPED to contain only one bead
>  path = File.openDialog("Select a File");
>  open(path); // open the file
>  dir = File.getParent(path)+"\\";
>  name = File.getName(path);
>  trunc=substring(name,0,indexOf(name,".tif")); // creates variable with
> TIF extension from the filename removed
>  rept=trunc+".pdf"; // creates variable with PDF extension added to
> generate the report name
>  ReptPath=dir+rept; // creates variable to assign the report path
>
>
> //The image is separated into multiple channels (up to 4 possible channels
> can be used)
>  run("Split Channels");
>  violet="C1-"+name; // creates variable for violet (405nm) channel
>  blue="C2-"+name; // creates variable for blue (488 nm) channel
>  green="C3-"+name; // creates variable for green (543 nm) channel
>  red="C4-"+name; // creates variable for red (633 nm) channel
>
> // Optional echoes to verify correct assignment of variables (can be
> removed or commented out)
>  print("Path:", path);
>  print("Name:", name);
>  print("Directory:", dir);
>  print("Reportname:", rept);
>  print("Report path:", ReptPath);
>  print("violet channel:", violet);
>  print("blue channel:", blue);
>  print("green channel:", green);
>  print("red channel:", red);
>
>
> //Passing variables to MetroloJ plug-in
> run("Generate co-alignement report", "title_of_report=&name stack_1=&red
> stack_2=&green stack_3=&blue microscope=Confocal wavelength_1=633
> wavelength_2=543 wavelength_3=488 na=1.40 pinhole=1 text1=[Sample infos]
> text2=Comments save=&rept");
> run("Close All");   //closes all open images
> </code>