Last active
October 28, 2019 08:02
-
-
Save lacan/82f88b67693ce22bbb61788cf585e11a to your computer and use it in GitHub Desktop.
[BigStitcher Flip Axes] Implements the Flip Axes Command from BigStitcher in a Macro Recordable Way #SPIM #BigStitcher #Fiji #Groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements the Flip Axes Command from BigStitcher | |
* | |
* Recommendation is to place this file in | |
* [FIJI Folder]/plugins/Scripts/Plugins/BigStitcher/Custom Scripts | |
* | |
* By Olivier Burri for Kai Schleicher, | |
* https://forum.image.sc/t/bigstitcher-flip-axes-in-headless-mode/30557?u=oburri | |
* BSD 3 License | |
* | |
*/ | |
import net.preibisch.mvrecon.fiji.plugin.queryXML.LoadParseQueryXML | |
import ij.gui.GenericDialog | |
import net.preibisch.stitcher.arrangement.FlipAxes | |
import net.preibisch.mvrecon.fiji.spimdata.SpimData2 | |
def result = new LoadParseQueryXML() | |
if ( !result.queryXML( "for Axes Flipping", true, true, true, true, true ) ) return | |
// Get the data | |
def spimData = result.getData(); | |
def dims = new HashMap<>() | |
def views = spimData.getSequenceDescription().getViewDescriptions().keySet().collect() | |
views.each{ v -> dims.put( v, spimData.getSequenceDescription().getViewDescriptions().get( v ).getViewSetup().getSize()) } | |
def flipAxes = new boolean[3] | |
GenericDialog gd = new GenericDialog( "Flip Parameters" ) | |
gd.addCheckbox( "Flip X", true ) | |
gd.addCheckbox( "Flip Y", false ) | |
gd.addCheckbox( "Flip Z", false ) | |
gd.showDialog(); | |
if (gd.wasCanceled()) | |
return; | |
flipAxes[0] = gd.getNextBoolean() | |
flipAxes[1] = gd.getNextBoolean() | |
flipAxes[2] = gd.getNextBoolean() | |
// Finally do the flip | |
FlipAxes.applyFlipToData( spimData.getViewRegistrations(), dims, views, flipAxes ) | |
// Save the XML file | |
SpimData2.saveXML( spimData, result.getXMLFileName(), result.getClusterExtension() ) | |
Hi @imagejan,
The reason was to keep the order of the operations the same as running any other BigStitcher batch command.
- Get the xml
- Show GenericDialogs specific to the batch task
I simply copied from:
https://github.com/PreibischLab/BigStitcher/blob/acb0ee1c68bc124e805a5e3a4c39d723965d520b/src/main/java/net/preibisch/stitcher/gui/popup/FlipAxesPopup.java#L54
If I used script parameters, it would first ask about the flipping axes and then request the XML file. Though I agree with you that Script Parameters would be the way to go.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lines 28 to 39 can be simplified by using script parameters:
Is there a specific reason why you prefer using GenericDialog?