BigStitcher "Flip Axes" in headless mode?

Dear BigStitcher gurus (e.g. @StephanPreibisch @hoerldavid),

I am looking into scripting BigStitcher to stitch *.vsi files written by our Olympus SpinSR spinning disc acquired with the cellSens dimension software.

Thanks to the documentation for headless mode I found my way easily, but I did encounter a few hurdles.
There seems to be an issue with the metadata of my images. While defining the dataset using the automatic loader fails, it does work with the manual loader (using Bio-formats). The relative positions of the tiles to each other are read correctly as well, but unfortunately the tiles are flipped in both X and Y.
However, there is a convenient way to correct this using the BigStitcher GUI (Arrange Views > Flip Axes ).

Is the Flip X and Y functionality also available for the headless / scripting mode, or would you know another way of how to correct this during scripting, e.g. by reading from my own TileConfiguration file?
Thank you for your help!

I don’t know if/how you can do this in BigStitcher, but how about inverting the coordinate values in your TileConfiguration.txt file? It should accept negative values without problems…

Wouldn’t Flip Axes be the equivalent of appending a transform to each tile of

[ -1  0  0  0
   0 -1  0  0
   0  0  1  0  ]

If so, then I would imagine that (takes deep breath) Plugins > Multiview Reconstruction > Batch Processing > Tools > Apply Transformations should do the trick?


EDIT: Seems that this is what they do

Although I think they flip in Z as well

Hi @oburri and @imagejan,
thanks for your suggestions!
I tried the transformation that Oli mentioned using Plugins > Multiview Reconstruction > Batch Processing > Tools > Apply Transformations:

run("Apply Transformations", "select=V:/imcf_olympus/20x_2regions/imcf-group-split_2D/left/dataset.xml apply_to_angle=[All angles] apply_to_channel=[All channels] apply_to_illumination=[All illuminations] apply_to_tile=[All tiles] apply_to_timepoint=[All Timepoints] transformation=Affine apply=[Current view transformations (appends to current transforms)] same_transformation_for_all_channels same_transformation_for_all_tiles timepoint_0_all_channels_illumination_0_angle_0=[-1,0,0,0,0,-1,0,0,0,0,1,0  ]");

The log confims that the transormation was done and that the .xml was updated. When opend in the BigStitcher GUI, the individual coordinates of the tiles are now listed with the oposite sign, i.e. what Jan was suggesting.

However, the orientation of the tiles did not change. The correct orientation can be seen using Arrange Views > Flip Axes > X & Y in the BigStitcher GUI.

So I probably still miss / did not fully understand something :sweat_smile:

Please feel free to have a look for yourself onmy example dataset (already hdf5/xml, but no transformations applied).

Hello hello @CellKai @imagejan,

So my first thing was obviously very wrong so I decided to have anopther look and use the FlipAxes command instead.

Here is a first version of it on Gist.

Now that I have seen through it, I would like some help from @StephanPreibisch et al. if there is a way to grab the current instance of BigStitcher instead of using the XML file. Something like BigStitcher.getOpenInstances()?
I am hoping to make this command either work on the currently open BigStitcher or on the XML file if it is not. that would be nice :slight_smile:

PS: @CellKai I’ll be looking forward to a beer next time we meet :kissing:

@ctrueden I notice that when I try to record this script, the recorder outputs

run("script:C:\Fiji\plugins\Scripts\Plugins\BigStitcher\Custom Scripts\BigStitcher_Flip_Axes.groovy", "browse=C:/Users/oburri/Desktop/dataset.xml select=C:/Users/oburri/Desktop//dataset.xml process_angle=[All angles] process_channel=[All channels] process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints] flip flip_0 flip_1");

Which returns an error:

Error:		Unrecognized command: "script:C:FijipluginsScriptsPluginsBigStitcherCustom ScriptsBigStitcher_Flip_Axes.groovy" in line 1:
		var ; initializeSciJavaParameters ( ) ; run ( "script:C:FijipluginsScriptsPluginsBigStitcherCustom ScriptsBigStitcher_F...

But changing it to

run("BigStitcher Flip Axes", "browse=C:\\Users\\oburri\\Desktop\\dataset.xml select=C:\\Users\\oburri\\Desktop\\dataset.xml process_angle=[All angles] process_channel=[All channels] process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints] flip flip_0 flip_1");

Works beautifully :heart:

I tried changing all the \ to / or to \\ but the error remained. I also checked if the whitespace in the folder name had any influence and it did not.

Quite frankly I am amazed that it works at all with the tweak, so giant kudos to that. Now it it would just spit out the right thing from the recorder that would be the cherry on top…


Thanks for the report, @oburri. Issues filed:

1 Like

indeed it does! thank you very much @oburri!

make that two :smiley:
Thanks again!

Hey everyone,

I meant to do macro-scriptable version of that for some time, sorry it took so long!
I finally got around to doing it and just saw that you beat me to it, @oburri :sweat_smile:
Now I feel kinda bad that you had to do all the work, but thanks a lot anyway!!!

I’ve added flipping (and skewing) as macro-scriptable Commands with the following commit, it will be part of the next release: