bUnwarpJ - loading mask from macro

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

bUnwarpJ - loading mask from macro

jamier
Hello All,

I am a novice using imageJ. At the moment I am working on a project whereby I wish to register bone scans to a target bone scan. I must load a mask prior to registration. This works successfully using the I/O menu of bUnwarpJ. Using the macro->record function of imageJ it appears the following command should load my saved mask file prior to registering:

run("bUnwarpJ", "load=/home/jamier/Fiji/BoneScans/Normals/Masks/N3_Ant_Mask.jpg source_image=[Source Anterior] target_image=[Target Anterior] registration=Accurate image_subsample_factor=0 initial_deformation=[Very Coarse] final_deformation=Fine divergence_weight=0 curl_weight=0 landmark_weight=0 image_weight=1 consistency_weight=10 stop_threshold=0.01");

I have written a short macro which opens the desired source image plus a dialogue for adjusting the various bUnwarpJ weights. However, this load source mask call does not work in my macro and the registration occurs without any mask and the corresponding registration is very poor. The section of my macro where bUnwarpJ is called is highlighted below. Is there a straightforward way to load a saved mask in bUnwarpJ using macros?

if (maskbool==1)
{
//run bUnwarpJ with source mask

 run("bUnwarpJ",
 " load =" + maskPath +
 " source_image=" + si + " target_image=" + ti + " registration=" + r + " image_subsample_factor="+ img_sub_factor + " initial_deformation=" + id + " final_deformation=" + fd + " divergence_weight=" + dw + " curl_weight=" + curlw + " landmark_weight="+ lw + " image_weight=" + iw + " consistency_weight=" + conw + " stop_threshold=" + st + " " + verbose + str);        
}

Reply | Threaded
Open this post in threaded view
|

Re: bUnwarpJ - loading mask from macro

Michael Schmid
Hi Jamier,

note that the macro syntax is rather strict. Don't put a blank  
between keyword and "=":
>   run("bUnwarpJ", " load =" + maskPath + ....
should become
    run("bUnwarpJ", " load=" + maskPath + ....

Also, don't forget to put square brackets around the path, in case it  
should contain spaces.

Michael
________________________________________________________________

On 13 Jun 2011, at 15:11, jamier wrote:

> Hello All,
>
> I am a novice using imageJ. At the moment I am working on a project  
> whereby
> I wish to register bone scans to a target bone scan. I must load a  
> mask
> prior to registration. This works successfully using the I/O menu of
> bUnwarpJ. Using the macro->record function of imageJ it appears the
> following command should load my saved mask file prior to registering:
>
> run("bUnwarpJ",
> "load=/home/jamier/Fiji/BoneScans/Normals/Masks/N3_Ant_Mask.jpg
> source_image=[Source Anterior] target_image=[Target Anterior]
> registration=Accurate image_subsample_factor=0 initial_deformation=
> [Very
> Coarse] final_deformation=Fine divergence_weight=0 curl_weight=0
> landmark_weight=0 image_weight=1 consistency_weight=10
> stop_threshold=0.01");
>
> I have written a short macro which opens the desired source image  
> plus a
> dialogue for adjusting the various bUnwarpJ weights. However, this  
> load
> source mask call does not work in my macro and the registration occurs
> without any mask and the corresponding registration is very poor. The
> section of my macro where bUnwarpJ is called is highlighted below.  
> Is there
> a straightforward way to load a saved mask in bUnwarpJ using macros?
>
> if (maskbool==1)
> {
> //run bUnwarpJ with source mask
>
>  run("bUnwarpJ",
>  " load =" + maskPath +
>  " source_image=" + si + " target_image=" + ti + " registration=" +  
> r + "
> image_subsample_factor="+ img_sub_factor + " initial_deformation="  
> + id + "
> final_deformation=" + fd + " divergence_weight=" + dw + "  
> curl_weight=" +
> curlw + " landmark_weight="+ lw + " image_weight=" + iw + "
> consistency_weight=" + conw + " stop_threshold=" + st + " " +  
> verbose +
> str);
> }
Reply | Threaded
Open this post in threaded view
|

Re: bUnwarpJ - loading mask from macro

jamier
Hello Michael,

Thank you for the advice, it is best to follow the correct macro syntax from the beginning. Unfortunately the macro seems to ignore the - load call. I have replaced load with a generic hello and the macro outputs the same result - a poor registration which ignores any masks called.

Thanks,
Jamie
Reply | Threaded
Open this post in threaded view
|

Re: bUnwarpJ - loading mask from macro

ctrueden
Hi Jamie,

The first thing I would try after recording the bUnwarpJ command using the
Macro Recorder is to play it back exactly as is with no changes. That is,
create a new macro from the recorder by clicking the "Create" button, close
out your image windows, then run the command and make sure it duplicates the
effects of bUnwarpJ as executed through the menus.

If the result is the same, then you know the bug was introduced by your
changes. If the result is different, then you know the problem has something
to do with bUnwarpJ being run as a macro. If the problem is with your
changes, then try making one small change at a time to isolate the point at
which things go wrong. If the problem is with bUnwarpJ, please submit a bug
using the Fiji bug reporter (Help > Report a Bug).

HTH,
Curtis

On Tue, Jun 14, 2011 at 12:37 PM, jamier <[hidden email]>wrote:

> Hello Michael,
>
> Thank you for the advice, it is best to follow the correct macro syntax
> from
> the beginning. Unfortunately the macro seems to ignore the - load call. I
> have replaced load with a generic hello and the macro outputs the same
> result - a poor registration which ignores any masks called.
>
> Thanks,
> Jamie
>
> --
> View this message in context:
> http://imagej.588099.n2.nabble.com/bUnwarpJ-loading-mask-from-macro-tp6470081p6473516.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: bUnwarpJ - loading mask from macro

jamier
Hi Curtis,

Thanks for the suggestion. It appears that the load call does not work when bUnwarpJ is run in a macro. I am unsure whether this is a bug as I have discovered an alternative route for loading masks within a macro (from the authors documentation no less ).

All that is required is to add a slice to the image I wish to register and copy a saved mask into the stack. When bUnwarpJ is loaded the mask is automatically included.

Thanks for the help,
Jamie
Reply | Threaded
Open this post in threaded view
|

Re: bUnwarpJ - loading mask from macro

Ignacio Arganda-Carreras
Hello everybody,

Sorry to answer so late. Jamie is right. The only way to load a mask from a
macro in bUnwarpJ is to add the mask image as a the second slice of the
source or target images.

If someone else is interested on doing it explicitly with a macro command, i
could add that code.

Cheers!

ignacio

On Wed, Jun 15, 2011 at 11:50 AM, jamier <[hidden email]>wrote:

> Hi Curtis,
>
> Thanks for the suggestion. It appears that the load call does not work when
> bUnwarpJ is run in a macro. I am unsure whether this is a bug as I have
> discovered an alternative route for loading masks within a macro (from the
> authors documentation no less ).
>
> All that is required is to add a slice to the image I wish to register and
> copy a saved mask into the stack. When bUnwarpJ is loaded the mask is
> automatically included.
>
> Thanks for the help,
> Jamie
>
> --
> View this message in context:
> http://imagej.588099.n2.nabble.com/bUnwarpJ-loading-mask-from-macro-tp6470081p6479417.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>



--
Ignacio Arganda-Carreras, Ph.D.
Seung's lab, 46-5065
Department of Brain and Cognitive Sciences
Massachusetts Institute of Technology
43 Vassar St.
Cambridge, MA 02139
USA

Phone: (001) 617-452-4976
Website: http://bioweb.cnb.csic.es/~iarganda/index_EN.html