abria / TeraStitcher

A tool for fast automatic 3D-stitching of teravoxel-sized microscopy images
http://abria.github.io/TeraStitcher/
Other
82 stars 32 forks source link

How To Keep Track of Image Scaling After Stitching? #73

Open JulianPitney opened 4 years ago

JulianPitney commented 4 years ago

Hi guys,

The scaling in our scans is important to us (i.e the µm/pixels ratio). TeraStitcher does not seem to preserve the ratio that the input tiles had. Is there a way to figure out how this scaling has been transformed after stitching? Let me know if my question is clear or if I need to elaborate more. Thanks in advance.

iannellog commented 4 years ago

Sorry for the delay, I was on holiday. Actually, TeraStitcher keeps memory of voxel size in the .xml files (tag voxel_dims) providing that you have correctly imported the dataset. Nevertheless I do not clearly understand which is your problem. I may guess that you need this information to be stored someway in the output image. Indeed, we did not pay much attention to this issue. Could you please better explain what you need? Perhaps this can be easily added/corrected.

JulianPitney commented 4 years ago

No worries, thanks for replying.

For example, in our input tiles, we have measured the µm/px ratio to be 1.43 µm per pixel in both the x and y direction. We are wondering if this scaling is preserved after stitching, and if not, how can we calculate the new µm/px ratio? We need this information because we're trying to do stroke volume measurements in brain scans.

iannellog commented 4 years ago

Ok, you mean if pixels in the output image do correspond to pixels in the input image. The answer is yes, absolutely. This is true if you do not use the --resolutions command line option (or specify --resolutions=0). This is true also in Z direction: the µm/px ratio in Z does correspond to the distance between adjacent slices generated by the acquisition system. What it is possible with TeraStitcher is to generate lower resolution images, where voxels do correspond to the mean of a matrix of voxels, but you have to explicitly request this feature using the --resolutions option.

JulianPitney commented 4 years ago

Okay I see. Yeah I just found this line in the documentation "Resolutions to be produced. Possible values are [[i]...] where i = 0,..,10 and 2^i is the subsampling factor. See Merge step.".

I'm still not certain how I would calculate the new voxel size (in µm) after stitching. When you say: "where voxels do correspond to the mean of a matrix of voxels", which matrix of voxels? My current understanding is that if, for example, I set --resolutions=1 then 2^1 = 2 would mean that every voxel in the output image was equal to the mean of 2 voxels in the input image. But I'm not sure if I'm interpreting this correctly. Please correct me if I'm wrong.

iannellog commented 4 years ago

No, if you ask to generate the stitched image with the option --resolution=1, each voxel in the output image will be the mean of a 3D matrix of 2x2x2 voxels. However if you specify also the option --isotropic, each voxel in the output image is the mean of either a 2x2x2 or a 2x2x1 matrix (the last dimension is along Z) depending on the original voxel size. If the original voxel is highly anisotropic (Z size is twice the X, Y size or more) voxel along Z are not merged, in order to generate an image with a voxel as much isotropic as possible (I stress that this happens ONLY if you specify the --isotropic option). In other words, if you DO NOT use the --isotropic option voxel size in each dimension is 2^i times the original voxel size, where i is the resolution specified. You can specify also more resolutions at a time, which generates multiple images at different resolutions. This was implemented to enable the processing of ultra-TB images at different resolutions.