Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automate saving of transformation matrices file #11

Closed
tischi opened this issue Sep 21, 2018 · 5 comments
Closed

automate saving of transformation matrices file #11

tischi opened this issue Sep 21, 2018 · 5 comments

Comments

@tischi
Copy link

tischi commented Sep 21, 2018

@miura

Would it be possible to automate saving of the transformation matrices?
Right now, the macro recorder only records "save" without the path...
For automation it would be great if that could be recorded such that no UI will pop up and one can reload the transformation file automatically as well.

run("MultiStackReg", "stack_1=C2-input action_1=Align file_1=[] stack_2=None action_2=Ignore file_2=[] transformation=[Rigid Body] save");
@tischi
Copy link
Author

tischi commented Sep 21, 2018

Just to clarify what my workflow would be (the issue is that I cannot know the transformationPath):

//
// Correct rotational jitter in a multi-channel image, based on registration of one of the channels
// Author: Christian Tischer (EMBL, CBA)
// Christian.Tischer@EMBL.DE 
//


//
// USER INPUT (could be modified)
//

referenceChannelId = 2;

//
// CODE (do not modify)
//
title = getTitle();
getDimensions(w, h, channels, slices, frames);

rename("input");
run("Split Channels");

run("MultiStackReg", "stack_1=C"+referenceChannelId+"-input action_1=Align file_1=[] stack_2=None action_2=Ignore file_2=[] transformation=[Rigid Body] save");

transformationPath = "/Users/tischer/Documents/isabelle-schneider-3d-rotational-jitter-correction/data/TransformationMatrices.txt";

for (i = 1; i < channels; i++) 
{
	if ( i != referenceChannelId )
	{
		run("MultiStackReg", "stack_1=C"+i+"-input action_1=Align file_1=["+transformationPath+"] stack_2=None action_2=Ignore file_2=[] transformation=[Rigid Body]");
	}
}

run("Merge Channels...", "c1=C1-input c2=C2-input c3=C3-input create");

rename( title );

@tischi
Copy link
Author

tischi commented Sep 21, 2018

I realize another option might be to add the multi-channel logic into the java code.
The functionality would be that one can select one reference channel and all channels get aligned accordingly.

I could do this however I am not sure how to handle it such that the UI does not get super complex...

@miura
Copy link
Owner

miura commented Sep 21, 2018

Hi @tischi

I don't have time to do this now, but I think the easiest way is below line 217 of MultiStackReg_.java something like

gd.addStringField("Path","",20);

That the path manually set in the string field will become the destination of the output. The aim is to have the path be recorded in the command recorder. Path then can be modified within the macro.

Then add a line below line 246

savepath = gd.getNextString();

presuming that you will also add savepath as a static field value.

savepath can then be integrated within the scope of if (saveTransform){ from line 314.

@tischi
Copy link
Author

tischi commented Sep 21, 2018

Sounds perfect! I'll do it and submit a PR :)

@tischi
Copy link
Author

tischi commented Sep 22, 2018

While looking into the code in order to add the changes I figured out that it actually works already, like this:

run("MultiStackReg", "stack_1=moving-dot.tif action_1=Align file_1=/Users/tischer/Desktop/tmp01/transformations.txt stack_2=None action_2=Ignore file_2=[] transformation=[Rigid Body]");

In this case file_1 is considered the saving path of the transformations.

@tischi tischi closed this as completed Sep 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants