fiji / register_virtual_stack_slices

Fiji package for registering and transforming arbitrarily large sequences of images
https://imagej.net/Register_Virtual_Stack_Slices
GNU General Public License v3.0
18 stars 12 forks source link

macro for saving the transformation file #16

Open pedriniedoardo opened 4 months ago

pedriniedoardo commented 4 months ago

Hello, I was trying to automate the registration of some images. I have identified the sets of parameters that seem to be working for my case. I have registered the macro commands and was trying to save the core of the registration step so it can be looped across the different sets of images. I need to save the transformation files, but when I run the macro, it keeps prompting me for the directory where to save them. Here is the sample macro:

//set the parameters
dir_in = "path/to/inputImages"
dir_out = "path/to/outputImages"

setBatchMode(true);

// registration
run("Register Virtual Stack Slices", "source="+ dir_in+" output="+ dir_out +" feature=Affine registration=[Moving least squares -- maximal warping                     ] advanced shrinkage save initial_gaussian_blur=1.60 steps_per_scale_octave=3 minimum_image_size=64 maximum_image_size=1024 feature_descriptor_size=8 feature_descriptor_orientation_bins=8 closest/next_closest_ratio=0.92 maximal_alignment_error=25 inlier_ratio=0.05 feature_extraction_model=Affine registration_model=[Moving least squares -- maximal warping                     ] interpolate shear=0.1 scale=0.1 isotropy=0.95");

// make the stack as an hyperstack to evaluate the registration output
run("Stack to Hyperstack...", "order=xyczt(default) channels=3 slices=1 frames=1 display=Composite");
saveAs("Tiff", dir_out + "/StackComposite_04-055_ROI_1_C00.tif");

showMessage(" macro finished");

When I run it, it pops up the dialogue to select the destination folder of the transfromations. image After specifying the destination directory, it all works as expected.

Can you suggest a way to save the transformation files programmatically? Is there a specific parameter I need to pass to the call of `run("Register Virtual Stack Slices")?

I am using the latest version of the plugin image

Also the lates version of ImageJ image

Thank you

iarganda commented 4 months ago

Hi! From macro, the plugin is still interactive. Have a look at this conversation in the forum:

https://forum.image.sc/t/how-to-run-register-virtual-stack-slices-as-a-macro-without-user-interaction/2659

You can use a script though and avoid the problem:

https://imagej.net/plugins/register-virtual-stack-slices#scripting--plugin