Big stitcher newbie need some help

Hello, I’m new to Fiji and bigstitcher to a point where I don’t even know how to ask this question.
I have time-course images with 4 fields that I’m trying to stitch but the bigstitcher is not working well. When I run a small subset of files with the Big data viewer open, the stitching works great. But when I move to the batch analysis with a macro I generated, with the same parameters (I think), the stitching results in images with too much overlap. I have no idea where things are going wrong and therefore don’t know what I can change to troubleshoot.

Could someone help how to navigate through this situation?
attaching my macro below.
Thanks!

dir1 = getDirectory("Choose Source Directory");
filename = "test.xml"
position = "2"

run("Define dataset ...", 
    "define_dataset=[Manual Loader (Bioformats based)] " +
    "project_filename="+ filename +
    " multiple_timepoints=[YES (one file per time-point)] " +
    "multiple_channels=[YES (one file per channel)] multiple_illumination_directions=[NO (one illumination direction)] " +
    "multiple_angles=[NO (one angle)] multiple_tiles=[YES (one file per tile)] " + 
    "image_file_directory="+dir1+ " image_file_pattern=Position"+position+"_C{c}_#{x}000{t}.tif " +
    "timepoints_=0-2 channels_=0-1 tiles_=1-4 calibration_type=[Same voxel-size for all views] " + 
    "calibration_definition=[Load voxel-size(s) from file(s) and display for verification] " +
    "move_tiles_to_grid_(per_angle)?=[Move Tile to Grid (Macro-scriptable)] grid_type=[Snake: Right & Down] " +
    "tiles_x=2 tiles_y=2 tiles_z=1 overlap_x_(%)=5 overlap_y_(%)=10 overlap_z_(%)=0 " + 
    "imglib2_data_container=[ArrayImg (faster)] " + 
    "pixel_distance_x=0.55000 pixel_distance_y=0.55000 pixel_distance_z=1.00000 pixel_unit=um");

run("As HDF5 ...", 
	"select="+dir1+filename+
	" resave_angle=[All angles] resave_channel=[All channels] resave_illumination=[All illuminations] "+
	"resave_tile=[All tiles] resave_timepoint=[All Timepoints] "+
	"use_deflate_compression export_path="+dir1+filename);

run("Calculate pairwise shifts ...", 
	"select="+dir1+filename +
	" process_angle=[All angles] process_channel=[All channels] process_illumination=[All illuminations] " + 
	"process_tile=[All tiles] process_timepoint=[All Timepoints] method=[Phase Correlation] channels =[use Channel 0] downsample_in_x=2 downsample_in_y=2");

run("Filter pairwise shifts ...",
    "select="+dir1+filename +" filter_by_link_quality min_r=0.7 max_r=1 ");	

run("Optimize globally and apply shifts ...",
    "select="+dir1+filename +" process_angle=[All angles] process_channel=[All channels] " +
    "process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints]" +
    " relative=2.500 absolute=3.500 global_optimization_strategy=" +
    "[Simple One-Round] ");

 run("Fuse dataset ...",
    "select="+dir1+filename +" process_angle=[All angles] process_channel=[All channels] " +
    "process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints]" + 
    " bounding_box=[All Views] downsampling=1 pixel_type=[16-bit unsigned integer] interpolation=[Linear Interpolation]" +
    " image=[Precompute Image] blend produce=[Each timepoint & channel] fused_image=[Save as (compressed) TIFF stacks] " +
    "output_file_directory=" +dir1);

Hi @ss5866,

Welcome to the forum.

Some follow up questions:

  • Is this true if you use exactly the same images as when you stitch manually (without the macro)?
  • About how much overlap do you expect?

Could you post a screenshot of your result? It might give us some ideas.

John

1 Like

Hi @bogovicj !
Thanks for responding. To answer your questions,

  1. Yes, I am using exactly the same images
  2. I expect a 5% overlap
  3. I am attaching the result here. The left side is manual, and the right side is with macro.

Screen Shot 2020-02-06 at 3.26.15 PM|690x371

2 Likes

Hi @ss5866,

is the overlap supposed to be 5% in both x and y? From the code you posted it seems unequal:

could you try with overlap_y_(%)=5 and see if this helps?

Hi @CellKai,
Thanks for the suggestion. Unfortunately, fixing overlap_y_(%) to 5 does not change the result I get.

Hi,

could you share the images with us so we can take a closer look?

You can for example zip the images and use firefox send for sharing.

1 Like

Hello,
Below is the link for my test dataset. 2 colors, 4 fields, three time points.
Thanks!

2 Likes

Hi @ss5866

Thanks for sharing the files.

When I just ran the first two commands in your script (Define dataset and "As HDF5") and looked at the *.h5, I saw that the tiles are actually all in the same place and not placed according to the grid you specified.

It seems that the Manual Loader (Bioformats based) can’t be combine with "move_tiles_to_grid_(per_angle)?=[Move Tile to Grid (Macro-scriptable)] grid_type=[Snake: Right & Down] " . I don’t know if thats a bug or not implemented so far.

As a maybe not so satisfying fix, I successfully used the [Automatic Loader (Bioformats based)] instead, which required to rename your files to introduce the time-pattern more clearly in the file name:
e.g. : Position2_C0_#10000.tif --> Position2_C0_#1000t0.tif

Please see the code below. I re-uploaded your files as well as the renamed ones

dir1 = getDirectory("Choose Source Directory");
filename = "test.xml"
position = "2"


run("Define dataset ...", 
    "define_dataset=[Automatic Loader (Bioformats based)]" + 
    " project_filename="+ filename + 
    " path="+ dir1 + 
    " exclude=10 pattern_0=Channels pattern_1=Tiles pattern_2=TimePoints " + 
    " move_tiles_to_grid_(per_angle)?=[Move Tile to Grid (Macro-scriptable)] grid_type=[Snake: Right & Down      ]" + 
    " how_to_load_images=[Re-save as multiresolution HDF5]" + 
    " dataset_save_path="+ dir1 +
    " check_stack_sizes subsampling_factors=[{ {1,1,1}, {2,2,2}, {4,4,4} }]" + 
    " hdf5_chunk_sizes=[{ {16,16,16}, {16,16,16}, {16,16,16} }]" + 
    " timepoints_per_partition=1 setups_per_partition=0 use_deflate_compression export_path="+ dir1+filename);

run("Calculate pairwise shifts ...", 
	"select="+dir1+filename +
	" process_angle=[All angles] process_channel=[All channels] process_illumination=[All illuminations] " + 
	"process_tile=[All tiles] process_timepoint=[All Timepoints] method=[Phase Correlation] channels =[use Channel 0] downsample_in_x=2 downsample_in_y=2");

run("Filter pairwise shifts ...",
    "select="+dir1+filename +" filter_by_link_quality min_r=0.7 max_r=1 ");	

run("Optimize globally and apply shifts ...",
    "select="+dir1+filename +" process_angle=[All angles] process_channel=[All channels] " +
    "process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints]" +
    " relative=2.500 absolute=3.500 global_optimization_strategy=" +
    "[Simple One-Round] ");

 run("Fuse dataset ...",
    "select="+dir1+filename +" process_angle=[All angles] process_channel=[All channels] " +
    "process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints]" + 
    " bounding_box=[All Views] downsampling=1 pixel_type=[16-bit unsigned integer] interpolation=[Linear Interpolation]" +
    " image=[Precompute Image] blend produce=[Each timepoint & channel] fused_image=[Save as (compressed) TIFF stacks] " +
    "output_file_directory=" +dir1);

I only now realize that firefox send has a limitation to a single download if you do not have an account, so this is actually only partially useful here.
.

1 Like

@CellKai,
Thanks for working with my images! This is very helpful as I was also wondering why I could not use the automatic loader. The result is much closer to the answer than I had. I will try this next week with my full data (with more than 800 timepoints), and try to correct the frameshift with something like ‘linear alignment with SIFT’. Thank you!!

SS

Hi,
no problem, I am happy if its helpful.

What I usually use to register shifts in time laps recordings is a ImageJ plugin called “MultiStackReg”, which allows you to register the time laps based on one stack (say, the BF channel) and then apply the registration to all other channels. There is also a thread here on the forum with a scripting example for this task.

To get the all the fused tifs after the bigStitcher into one stack for alignment, place them all together in a folder and use Plugins > Bio-Formats > Bio-Formats Importer with the options “Group files with similar files” and “Split channels” checked so you can register one channel and use it as reference for the other.

1 Like