Apply bUnwarpJ in macro

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

Apply bUnwarpJ in macro

nellypledge
Hi all,
Does anybody know how to apply the transformation created using bUnwarpJ.  I saved the transform txt files, both forward and backward, but I'm a little lost on how to apply this to other images in a macro.

Thanks in advance for your time.
Neil
Reply | Threaded
Open this post in threaded view
|

Re: Apply bUnwarpJ in macro

ctrueden
Hi Neil,

> Does anybody know how to apply the transformation created using
> bUnwarpJ.  I saved the transform txt files, both forward and backward,
> but I'm a little lost on how to apply this to other images in a macro.

According to the documentation at
http://imagej.net/BUnwarpJ#Macro_call

    if we want to apply an elastic deformation stored in the file
    A_direct_transf.txt to the source image A.jpg with target image
    B.jpg and save the result in output.tif, we call:

        call( "bunwarpj.bUnwarpJ_.elasticTransformImageMacro",
"My_path/A.jpg",
              "My_path/B.jpg", "My_path/A_direct_transf.txt",
"My_path/output.tif" );

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - http://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Mon, May 9, 2016 at 3:10 PM, nellypledge <[hidden email]> wrote:

> Hi all,
> Does anybody know how to apply the transformation created using bUnwarpJ.
> I
> saved the transform txt files, both forward and backward, but I'm a little
> lost on how to apply this to other images in a macro.
>
> Thanks in advance for your time.
> Neil
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Apply-bUnwarpJ-in-macro-tp5016374.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: Apply bUnwarpJ in macro

CARL Philippe (LBP)
Dear Neil and curtis,
If you launch: run("UnwarpJ ", "-help");
Within a macro you will be able to display the help file.
And you can run the macro using a previously generated transformed file with:
run("UnwarpJ ", "-transform target.jpg source.jpg transformation.txt output.tif");
target.jpg, source.jpg, transformation.txt and output.tif being the complete paths of the source pictures, transformation file and output file on the HD.
For the applications of a colleague who needed to apply the plugin to large stacks of images I extended the plugin so it can be applied on pictures loaded on memory through:
run("UnwarpJ ", " -transformMemory target.jpg source.jpg transformation.txt output.tif"); with target.jpg and source.jpg being pictures loaded within the memory, the transformation.txt file being from the HD and the output.tif created as well within the memory.
In the case you are interested by this extended version of the plugin, you will be able to download it under: http://punias.free.fr/Unwarp/ UnwarpJ_.jar
My best regards,
Philippe

Philippe CARL
Laboratoire de Biophotonique et Pharmacologie
UMR 7213 CNRS - Université de Strasbourg
Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

-----Message d'origine-----
De : ImageJ Interest Group [mailto:[hidden email]] De la part de Curtis Rueden
Envoyé : lundi 9 mai 2016 23:20
À : [hidden email]
Objet : Re: Apply bUnwarpJ in macro

Hi Neil,

> Does anybody know how to apply the transformation created using
> bUnwarpJ.  I saved the transform txt files, both forward and backward,
> but I'm a little lost on how to apply this to other images in a macro.

According to the documentation at
http://imagej.net/BUnwarpJ#Macro_call

    if we want to apply an elastic deformation stored in the file
    A_direct_transf.txt to the source image A.jpg with target image
    B.jpg and save the result in output.tif, we call:

        call( "bunwarpj.bUnwarpJ_.elasticTransformImageMacro",
"My_path/A.jpg",
              "My_path/B.jpg", "My_path/A_direct_transf.txt", "My_path/output.tif" );

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - http://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden Did you know ImageJ has a forum? http://forum.imagej.net/


On Mon, May 9, 2016 at 3:10 PM, nellypledge <[hidden email]> wrote:

> Hi all,
> Does anybody know how to apply the transformation created using bUnwarpJ.
> I
> saved the transform txt files, both forward and backward, but I'm a
> little lost on how to apply this to other images in a macro.
>
> Thanks in advance for your time.
> Neil
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Apply-bUnwarpJ-in-macro-tp5016374.htm
> l 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

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

Re: Apply bUnwarpJ in macro

Jan Eglinger
In reply to this post by ctrueden
Dear Philippe,

it would be great to see improvements to UnwarpJ and related plugins on
their source code repositories as well. Would you mind submitting a pull
request to:

     https://github.com/fiji/UnwarpJ/pulls
or
     https://github.com/fiji/bUnwarpJ/pulls

This way, the changes would eventually end up in every standard Fiji
installation.

Cheers
Jan


On 10.05.2016 11:12, Philippe CARL wrote:

> Dear Neil and curtis,
> If you launch: run("UnwarpJ ", "-help");
> Within a macro you will be able to display the help file.
> And you can run the macro using a previously generated transformed file with:
> run("UnwarpJ ", "-transform target.jpg source.jpg transformation.txt output.tif");
> target.jpg, source.jpg, transformation.txt and output.tif being the complete paths of the source pictures, transformation file and output file on the HD.
> For the applications of a colleague who needed to apply the plugin to large stacks of images I extended the plugin so it can be applied on pictures loaded on memory through:
> run("UnwarpJ ", " -transformMemory target.jpg source.jpg transformation.txt output.tif"); with target.jpg and source.jpg being pictures loaded within the memory, the transformation.txt file being from the HD and the output.tif created as well within the memory.
> In the case you are interested by this extended version of the plugin, you will be able to download it under: http://punias.free.fr/Unwarp/ UnwarpJ_.jar
> My best regards,
> Philippe
>
> Philippe CARL
> Laboratoire de Biophotonique et Pharmacologie
> UMR 7213 CNRS - Université de Strasbourg
> Faculté de Pharmacie
> 74 route du Rhin
> 67401 ILLKIRCH
> Tel : +33(0)3 68 85 41 84
>
> -----Message d'origine-----
> De : ImageJ Interest Group [mailto:[hidden email]] De la part de Curtis Rueden
> Envoyé : lundi 9 mai 2016 23:20
> À : [hidden email]
> Objet : Re: Apply bUnwarpJ in macro
>
> Hi Neil,
>
>> Does anybody know how to apply the transformation created using
>> bUnwarpJ.  I saved the transform txt files, both forward and backward,
>> but I'm a little lost on how to apply this to other images in a macro.
>
> According to the documentation at
> http://imagej.net/BUnwarpJ#Macro_call
>
>     if we want to apply an elastic deformation stored in the file
>     A_direct_transf.txt to the source image A.jpg with target image
>     B.jpg and save the result in output.tif, we call:
>
>         call( "bunwarpj.bUnwarpJ_.elasticTransformImageMacro",
> "My_path/A.jpg",
>               "My_path/B.jpg", "My_path/A_direct_transf.txt", "My_path/output.tif" );
>
> Regards,
> Curtis
>
> --
> Curtis Rueden
> LOCI software architect - http://loci.wisc.edu/software
> ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden Did you know ImageJ has a forum? http://forum.imagej.net/
>
>
> On Mon, May 9, 2016 at 3:10 PM, nellypledge <[hidden email]> wrote:
>
>> Hi all,
>> Does anybody know how to apply the transformation created using bUnwarpJ.
>> I
>> saved the transform txt files, both forward and backward, but I'm a
>> little lost on how to apply this to other images in a macro.
>>
>> Thanks in advance for your time.
>> Neil
>>
>>
>>
>> --
>> View this message in context:
>> http://imagej.1557.x6.nabble.com/Apply-bUnwarpJ-in-macro-tp5016374.htm
>> l 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
>
> --
> 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: Apply bUnwarpJ in macro

nellypledge
Hi Guys, thanks for the feedback.

The one things that keeps throwing me is the fact you need the target and source repeatedly.  Surely once I've created a transform file I can apply it to one image (I'm assuming that I'd apply a forward transform to a source image, right?).  Why don't we just have the source, transform and output?

Maybe I'm missing something...  For your reference I want to use this plugin to map my green channel camera image back to the red channel.  I acquired images with a full field of mutlicolor beads to create the transform.  Using the target, source, transform and output, how would that look?  Would the target and source be the bead image of red and green respectively, and then the transform acts on the output file?

I would be applying this to potentially large zstacks and would probable need the memory adapted version.  I'm happy to work with github to keep things current.  Philippe, if you plan to update the repository, I'll wait for you, but if you foresee potential time delays, I'm happy to figure that out and update things.

Thanks
Neil

Reply | Threaded
Open this post in threaded view
|

Re: Apply bUnwarpJ in macro

CARL Philippe (LBP)
Dear Nelly,
You will find under the following link:
http://punias.free.fr/Unwarp/Stack.tif
an example stack obtained from an image acquired with an image splitter
device (type Gemini or Optosplit II).
For which I created the following macro:
http://punias.free.fr/Unwarp/Macro_UnwarpJ_Stack.ijm
that is working with this plugin:
http://punias.free.fr/Unwarp/UnwarpJ_.jar
what the macro does is, for each picture within the stack, to split the
picture as the red and green channel, applies the transformation using the
transformation file generated previously and stored on the HD and output the
transformed picture for which I create a stack of the corrected pictures at
the end.
Concerning your question, you can find its answer under the following link:
http://bigwww.epfl.ch/thevenaz/UnwarpJ/
namelly "The source image is the one to which the transformation will be
applied. The target image is used to know the dimension of the output image
and must be the same image that was used during the alignment step since the
deformation is computed for its specific size."
And indeed (and I completely agree with you, with the fact that) the plugin
could be really simplified if the "dimension of the output image" would
simply be saved within the transformation file and thus there would only be
the need of an input picture and transformation file as input for launching
the plugin.
Even more, and I really don't want to hurt the authors of this plugin which
mathematically is really over my level of understanding, the architecture of
the plugin is extremely complicated and should be rethought and rewritten.
As an example, the plugin is not using the GenericDialog class but
recreating the wheel using other classes.
BUT, I don't know this, maybe had the first version of this plugin been
written before the creation of these classes.
The issue is that the reformatting I'm talking about would require way more
time and investment than the 1-2 hours of small updates I added to the code
(respecting its philosophy and formatting as it was) for the applications of
a colleague (who needed this for the day before yesterday).
As for the request of Jan of pulling a request on the update I'm not against
it, but the code I started from (found @
http://bigwww.epfl.ch/thevenaz/UnwarpJ/) seems quite different than the one
within the Fiji version of the algorithm.
Nevertheless I left the source code of my updates within the jar file @
http://punias.free.fr/Unwarp/UnwarpJ_.jar for whoever to look at it and copy
it.
I hope I helped you to move further.
My best regards,
Philippe

Philippe CARL
Laboratoire de Biophotonique et Pharmacologie
UMR 7213 CNRS - Université de Strasbourg
Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84


-----Message d'origine-----
De : ImageJ Interest Group [mailto:[hidden email]] De la part de
nellypledge
Envoyé : mardi 10 mai 2016 13:45
À : [hidden email]
Objet : Re: Apply bUnwarpJ in macro

Hi Guys, thanks for the feedback.

The one things that keeps throwing me is the fact you need the target and
source repeatedly.  Surely once I've created a transform file I can apply it
to one image (I'm assuming that I'd apply a forward transform to a source
image, right?).  Why don't we just have the source, transform and output?

Maybe I'm missing something...  For your reference I want to use this plugin
to map my green channel camera image back to the red channel.  I acquired
images with a full field of mutlicolor beads to create the transform.  Using
the target, source, transform and output, how would that look?  Would the
target and source be the bead image of red and green respectively, and then
the transform acts on the output file?

I would be applying this to potentially large zstacks and would probable
need the memory adapted version.  I'm happy to work with github to keep
things current.  Philippe, if you plan to update the repository, I'll wait
for you, but if you foresee potential time delays, I'm happy to figure that
out and update things.

Thanks
Neil





--
View this message in context:
http://imagej.1557.x6.nabble.com/Apply-bUnwarpJ-in-macro-tp5016374p5016383.h
tml
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: Apply bUnwarpJ in macro

nellypledge
Hi Philippe, thanks for all your time taken to help me out on this.

Alas, I don't seem to be able to get your adapted plugin to work...  I downloaded your jar file and moved it to the plugins folder of my Fiji folder.  I didn't receive any errors on start, which I was a little surprised by as there is another plugin with the name UnwarpJ_-v2.0.0.  When I attempted to apply the marco line to a simple test pair of images it didn't appear to do anything...


I then renamed the v2.0.0 plugin to have extension .jar.tmp and restarted.  I then got errors regarding my path to the transform text file.  It turns out that if I locate it in a folder and name without spaces it doesn't error and it provides the text out in the results window as follows:
Target image           : trg.tif
Source image          : src.tif
Transformation file  : R://Code//transf.txt
Output                     : output

If I then overlay the trg and output image I see that the transform was not performed...?  The beads are not overlapping as they should be.  When I manually create the transform the beads shown in the first two channels of the UnwarpJ output do overlap.

Sorry to take up your time, but could you please look at the below to make sure I'm not mixed up with my macro steps?

Thanks
Neil

Test Macro:
selectWindow("20160509_Tetx60_2_MMStack_Pos0.ome.tif");
run("Duplicate...", "title=dup duplicate slices=1");
run("Split Channels");
selectWindow("C1-dup");
rename("src.tif");
selectWindow("C2-dup");
rename("trg.tif");

trans = "R://Code//transf.txt";
run("UnwarpJ ", "-transformMemory trg.tif src.tif " + trans + " output");
selectWindow("output");
run("16-bit");
run("Merge Channels...", "c1=trg.tif c2=output create keep ignore");



Reply | Threaded
Open this post in threaded view
|

Re: Apply bUnwarpJ in macro

CARL Philippe (LBP)
Dear Neil,
You will indeed get some conflict issues when installing "my adapted plugin" within Fiji (which won’t be the case when using the "vanilla" ImageJ).
And the bad thing is that when you are not using "my adapted plugin" but another version and launch: run("UnwarpJ ", "-transformMemory…., you will even not get an error message displayed but just nothing will happen without letting you know the issue.
Thus in the case you want to check whether you are using "my adapted plugin" or another one, just launch:
run("UnwarpJ ", "arf");
or of you prefer
run("UnwarpJ ", "whatever");
and you will see an error message displayed and nothing for the other versions.
I understand as well your space issue within the path to the transform text file. Indeed in the case you have spaces within the path, the plugin is interpreting this as being a new (= next) element within the args. Thus in the case you want to have spaces within your folder you should rather use underscores.
For the other issues you are describing, I don’t see the origin as well as within your macro.
Were you correctly able to launch the macro:
http://punias.free.fr/Unwarp/Macro_UnwarpJ_Stack.ijm
with the picture:
http://punias.free.fr/Unwarp/Stack.tif
and transformation file
http://punias.free.fr/Unwarp/AVG_-1_transf.txt
My best regards,
Philippe

Le Mardi 10 Mai 2016 19:07 CEST, nellypledge <[hidden email]> a écrit:

> Hi Philippe, thanks for all your time taken to help me out on this.
>
> Alas, I don't seem to be able to get your adapted plugin to work...  I
> downloaded your jar file and moved it to the plugins folder of my Fiji
> folder.  I didn't receive any errors on start, which I was a little
> surprised by as there is another plugin with the name UnwarpJ_-v2.0.0.  When
> I attempted to apply the marco line to a simple test pair of images it
> didn't appear to do anything...
>
>
> I then renamed the v2.0.0 plugin to have extension .jar.tmp and restarted.
> I then got errors regarding my path to the transform text file.  It turns
> out that if I locate it in a folder and name without spaces it doesn't error
> and it provides the text out in the results window as follows:
> Target image           : trg.tif
> Source image          : src.tif
> Transformation file  : R://Code//transf.txt
> Output                     : output
>
> If I then overlay the trg and output image I see that the transform was not
> performed...?  The beads are not overlapping as they should be.  When I
> manually create the transform the beads shown in the first two channels of
> the UnwarpJ output do overlap.
>
> Sorry to take up your time, but could you please look at the below to make
> sure I'm not mixed up with my macro steps?
>
> Thanks
> Neil
>
> Test Macro:
> selectWindow("20160509_Tetx60_2_MMStack_Pos0.ome.tif");
> run("Duplicate...", "title=dup duplicate slices=1");
> run("Split Channels");
> selectWindow("C1-dup");
> rename("src.tif");
> selectWindow("C2-dup");
> rename("trg.tif");
>
> trans = "R://Code//transf.txt";
> run("UnwarpJ ", "-transformMemory trg.tif src.tif " + trans + " output");
> selectWindow("output");
> run("16-bit");
> run("Merge Channels...", "c1=trg.tif c2=output create keep ignore");
>
>
>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Apply-bUnwarpJ-in-macro-tp5016374p5016388.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: Apply bUnwarpJ in macro

nellypledge
Thank you Philippe for your speedy response.

I did run your tif stack using the macro and it appeared to work.  When I tried to run the plugin with a random argument I got the follow:
The used arguments could not be recognized, please use "-help" to display the arguments description

Given that I'm running your plugin and it's outputting the four lines of text as it does on your tif stack I feel that it's a least going into the UnwarpJ code.  I wonder if I have something wrong with my transf file...

Is there a way to manually run the transform using the original plugin?

Failing that I guess I could get your plugin source code into Netbeans and step through to see what's happening...

Thanks for all your help.

Neil
Reply | Threaded
Open this post in threaded view
|

Re: Apply bUnwarpJ in macro

CARL Philippe (LBP)
Dear Neil,
In the case you get the error message "The used arguments could not be recognized, please use "-help" to display the arguments description" when using a random argument, then you are indeed running the plugin I newly updated.
Unfortunately there is no way (other than through a macro) within the plugin to launch an already generated transformation file.
Actually my first idea was to add such an option (i.e. to make a transformation) within the GUI of the plugin. But when I saw the needed work I changed my mind and went back to only limit the update to a new macro command addition.
For your issue, given that the code I sent you is working for you and there are only 3 inputs, you just need to play alternatively with one of them to figure out when the code isn’t running correctly anymore.
Nevertheless I agree that the issue may very probably come from your transformation file.
Also did you generate it with the same Unwarp plugin version than the one you are using?
In the case I want to compare the content of two files in order to see differences, I use the >File->Compare_By_Contect… feature of the Total commander software which is often useful.
Have a good night,
Philippe

Le Mardi 10 Mai 2016 22:31 CEST, nellypledge <[hidden email]> a écrit:

> Thank you Philippe for your speedy response.
>
> I did run your tif stack using the macro and it appeared to work.  When I
> tried to run the plugin with a random argument I got the follow:
> The used arguments could not be recognized, please use "-help" to display
> the arguments description
>
> Given that I'm running your plugin and it's outputting the four lines of
> text as it does on your tif stack I feel that it's a least going into the
> UnwarpJ code.  I wonder if I have something wrong with my transf file...
>
> Is there a way to manually run the transform using the original plugin?
>
> Failing that I guess I could get your plugin source code into Netbeans and
> step through to see what's happening...
>
> Thanks for all your help.
>
> Neil
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Apply-bUnwarpJ-in-macro-tp5016374p5016393.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: Apply bUnwarpJ in macro

nellypledge
In reply to this post by Jan Eglinger
Hi Jan,
Can I please ask for any tips you might have on setting up a new pull into Netbeans?  In Netbeans I created a new Maven application and then fetched the fork I created in git hub, nranthony/bUnwarpJ.

Is this the correct route.  I'm new to version control, but not coding.

Thanks
Neil
Reply | Threaded
Open this post in threaded view
|

Re: Apply bUnwarpJ in macro

ctrueden
Hi Neil,

> Can I please ask for any tips you might have on setting up a new pull into
> Netbeans?

This guide should hopefully help you:

http://imagej.net/How_to_contribute_to_an_existing_plugin_or_library

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - http://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Tue, May 10, 2016 at 4:46 PM, nellypledge <[hidden email]> wrote:

> Hi Jan,
> Can I please ask for any tips you might have on setting up a new pull into
> Netbeans?  In Netbeans I created a new Maven application and then fetched
> the fork I created in git hub, nranthony/bUnwarpJ.
>
> Is this the correct route.  I'm new to version control, but not coding.
>
> Thanks
> Neil
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Apply-bUnwarpJ-in-macro-tp5016374p5016395.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: Apply bUnwarpJ in macro

nellypledge
Thanks Curtis, that works a charm.  Clone was the thing I wanted to get started ;)

Neil