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

Is there a way to align 2-ch images using one channel as an alignment map? #15

Open puifais opened 7 years ago

puifais commented 7 years ago

Hello,

Is there a way to align 2-ch images using one channel as an alignment map? For example, may be you have 2-Ch images (say red and green) but the features in red channels are obvious and easy to align, but the green channels are not so easy to align.

Puifai

abria commented 7 years ago

Yes. In the Align step, you can specify the channel selection using the --imin_channel parameter from the command line, or the "Channel selection" pull-down menu from the GUI.

iannellog commented 7 years ago

I add that after having computed the alignment using the most informative channel you can stitch the final as an RGB image using the tool TeraConverter (included in the distribution).

I try to explain how to generate RGB images with the help of the attached file. I apologize because the documentation of these features is somehow incomplete and difficult to read, but we are continuously developing our tools and it is difficult to maintain updated the documentation. Any comment is welcome that can help us to better explain the features of our tools.

Starting from an RGB unstitched dataset you can proceed as follows:

  1. generate the .xml file with the aligned tile positions using step 1-5 of TeraStitcher. In steps 1 and 2 you have to specify which channel to use (command line option --imin_channel that can assume values R, G or B); use the channel that provides the better alignments

  2. use teraconverter to generate the stitched image; configure CMake to generate teraconverter (check the boxes: WITH_UTILITY_MODULE_teraconveter and WITH_UTILITY_MODULE_volumeconverter); for teraconveter it is available only the command line interface, not the GUI interface

For stitching with teraconveter you should use the following command line options:

-s=complete path and name of the xml file generated by TeraStitcher -d=complete path of the directory where you want to save the stitched image --sfmt="TIFF (unstitched, 3D)" % use this format for any unstitched source, independently of its actual organization --dfmt="TIFF (series, 2D)" % this generates a series of 2D RGB TIFFs in the directory you specify

These are the minimal set of options needed to generate the stitched image. Of course you can specify other options if you want to change the default behavior of TeraConverter (e.g. you can control if the output TIFFs are compressed or not and, if compressed, how many rows should be packed in a strip, use command line option -h for the list of available options).

I hope this can help.

Best.

-- Giulio

2017-03-28 16:56 GMT+02:00 Puifai Santisakultarm notifications@github.com:

Hello,

Is there a way to align 2-ch images using one channel as an alignment map? For example, may be you have 2-Ch images (say red and green) but the features in red channels are obvious and easy to align, but the green channels are not so easy to align.

Puifai

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/abria/TeraStitcher/issues/15, or mute the thread https://github.com/notifications/unsubscribe-auth/AIdv1uAiLlWshE-eYaT4kpc2zwtdc-swks5rqR-7gaJpZM4MrvyW .

--


Giulio Iannello Preside della Facolta' Dipartimentale di Ingegneria Universita' Campus Bio-Medico di Roma v. Alvaro del Portillo, 21 00128 Roma, Italy

Tel: +39-06-22541-9602 E-mail: g.iannello@unicampus.it Fax: +39-06-22541-9609 URL: https://scholar.google.it/citations?user=L-UJxIgAAAAJ


puifais commented 7 years ago

Just so I understand correctly, the starting images and folder structures are the same as when dealing with 1 channel. The only difference is that each file (i.e. each z-plane) is an RGB image?

iannellog commented 7 years ago

That is correct: the organization of the unstitched image and the corresponding import step do not depend on the number of channels.

-- Giulio

2017-03-28 23:12 GMT+02:00 Puifai Santisakultarm notifications@github.com:

Just so I understand correctly, the starting images and folder structures are the same as when dealing with 1 channel. The only difference is that each file (i.e. each z-plane) is an RGB image?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/abria/TeraStitcher/issues/15#issuecomment-289906389, or mute the thread https://github.com/notifications/unsubscribe-auth/AIdv1mmlixZeRRkFwR8_yWrsm2WJEjZlks5rqXesgaJpZM4MrvyW .

--


Giulio Iannello Preside della Facolta' Dipartimentale di Ingegneria Universita' Campus Bio-Medico di Roma v. Alvaro del Portillo, 21 00128 Roma, Italy

Tel: +39-06-22541-9602 E-mail: g.iannello@unicampus.it Fax: +39-06-22541-9609 URL: https://scholar.google.it/citations?user=L-UJxIgAAAAJ


puifais commented 7 years ago

Hm...it doesn't seem to like RGB image

error when using rgb
iannellog commented 7 years ago

Puifai, the error you got shows that you have used the Qt GUI of TeraStitcher. Using the GUI, you have executed the merge step of TeraStitcher that can only operate on one channel at the time (you have to select which).

Unfortunately, to generate RGB images you must use TeraConverter which is a different executable and it is not supported at the moment by the GUI. TeraConverter is a much more flexible tool to generate big images and for this reason we do not support any more the merge step of TeraStitcher (i.e. the last one, the other steps are continuously maintained). I understand that command line executables are difficult to use for who is not a programmer, and we will update as soon as possible the GUI, but at the moment you must use the command line version if you want to generate RGB images.

I would ask you to test if the command line version of TeraConverter works fine on your images. To do that you should issue a command of his kind:

teraconverter --sfmt="TIFF (unsititched, 3D)" --dfmt="TIFF (series, 2D)" -s="path and name of the xml file with alignments generated by TeraStitcher" -d="path where you want to save the series of RGB TIFFs corresponding to your stitched image"

more options can be found issuing the command "teraconverter -h" or looking at the teraconverter section on GitHub.

If it works, let us also know how urgent is this feature for you, because we cold try to anticipate the update of the GUI. I hope this can help.

Best.

-- Giulio

2017-03-31 19:12 GMT+02:00 Puifai Santisakultarm notifications@github.com:

Hm...it doesn't seem to like RGB image

[image: error when using rgb] https://cloud.githubusercontent.com/assets/22781262/24561137/86a0da96-15fa-11e7-9b12-7a70de13f7c7.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/abria/TeraStitcher/issues/15#issuecomment-290772523, or mute the thread https://github.com/notifications/unsubscribe-auth/AIdv1kiZi58dSXbAy4zvE7IZ7eqcM0i5ks5rrTQYgaJpZM4MrvyW .

--


Giulio Iannello Preside della Facolta' Dipartimentale di Ingegneria Universita' Campus Bio-Medico di Roma v. Alvaro del Portillo, 21 00128 Roma, Italy

Tel: +39-06-22541-9602 E-mail: g.iannello@unicampus.it Fax: +39-06-22541-9609 URL: https://scholar.google.it/citations?user=L-UJxIgAAAAJ


puifais commented 7 years ago

Okay, I am attempting to do this with command line as per your suggestion. And the very first thing I did was to import the XML file, which I generated using the TeraStitcher GUI.

Input:
./terastitcher --import --volin="~/Desktop/Image_TeraStitcher/xml_import.xml" --ref1=y --ref2=x --ref3=z --vxl1=1.01 --vxl2=1.01 --vxl3=4.64 --volin_plugin="TiledXY|2Dseries" Output:
dyld: Library not loaded: @rpath/QtWidgets.framework/Versions/5/QtWidgets Referenced from: /Applications/TeraStitcher-Qt5-standalone/bin/./terastitcher Reason: image not found Abort trap: 6

So then I deleted this XML file and mdata.bin, and tried to import the entire folder, rather than the XML. ./terastitcher --import --volin="~/Desktop/Image_TeraStitcher" --ref1=y --ref2=x --ref3=z --vxl1=1.01 --vxl2=1.01 --vxl3=4.64 --volin_plugin="TiledXY|2Dseries"

But I got the same error. Perhaps something went wrong with my installation?

Also, I appear to not have the TeraConverter Thoms-MacBook-Pro:bin puifai$ ls terastitcher terastitcher-gui.app Thoms-MacBook-Pro:bin puifai$ ./teraconverter -bash: ./teraconverter: No such file or directory

abria commented 7 years ago

Please download the latest version (1.9.67) for MacOS at this link. TeraConverter will be included.

abria commented 7 years ago

If you still have Qt-related errors / missing libraries when you run command-line tools, please download the standalone command-line tools from this link.

BTW I suggest to use the TeraStitcher-GUI to generate the .xml/mdata.bin, and then use the command-line teraconverter as suggested by Giulio.

We apologize for the unnecessary complexity of the "stitching color images" task. We are currently working to include the latest updates in TeraStitcher-GUI.

puifais commented 7 years ago

Hi Alessandro,

Don't worry at all. I'm just glad you guys came up with the tool. And I know it's a lot of work to maintain, support, improve, etc. Thank you very much.

I downloaded the command-line tool and now have teraconverter. Giulio suggested using the command line teraconverter for the merge step. However, I'm getting the error here at the Aligning step.

untitled

Should I do the Alignment using TeraStitcher command line first, then do the Merging with TeraConverter?

abria commented 7 years ago

It seems like the image was not imported correctly in the Import step. Could you please attach the .xml file, as well as all the image info (how many stacks along x and y, how many slices per stack, ...) you can provide? Thanks.

puifais commented 7 years ago

Sure. Here's the xml file. And this is the image info.

Please note that this image isn't the exact same image as the post above. This one gives this error at the Aligning step:

image

iannellog commented 7 years ago

Puifai, we have found the bug. Many thanks because it was a subtle one that happens only when the stitcher is launched using the GUI. I have already updated GitHub (TeraStitcher version 1.9.70), but you have to wait that Alessandro regenerates the installer before trying, unless you can rebuild the executables with CMake. Alessandro will inform you as soon as all the packages have been updated.

To avoid further misunderstandings, I summarize how you should use the tools, based on what I understood of your setup. Let me know if I miss something.

  1. You started from a .czi file containing a tile matrix with 3 rows and 2 columns (I have already stitched sample images of that kind, so I know the format)
  2. Your image has two 8 bits channels
  3. I suppose you have extracted the tiles somehow from the .czi file and stored them as series of 2D RGB TIFFs in a two-level hierarchy of folders (is this correct?)
  4. You have executed the import step from the GUI of TeraStitcher
  5. You have executed the aligning step from the GUI of TeraStitcher and got the errors

Steps 1-4 are ok. Consider that I have partially implemented direct stitching of datasets stored in .czi files interfacing the bioformat library with TeraStitcher. If you were interested in helping me to complete this part of the pipeline (in standby at the moment), let me know (this way you could avoid step 3 above).

You can restart from step 5 specifying which channel to use (R, G or B) for alignment computation. You can still use the GUI for this.

After the aligning, the GUI generates four additional xml files. To generate an RGB stitched image you have to perform the last step with TeraConverter (you cannot use the GUI for this, currently only the command line interface is available for TeraConverter). As input to the TeraConverter you must specify the file xml_merging.xml generated by the GUI. The command line should look like:

teraconverter --sfmt="TIFF (unstitched, 3D)" -s=xml_merging.xml --dfmt="TIFF (series, 2D)" -d=destination_directory

Note that this way the stitched image is a series of 2D RGB TIFF. You can generate the stitched image also in other formats. Let me know if you are interested in more information about this. For completeness, consider that at the moment you can use the output format "TIFF (series, 2D)" with more than one channel only if channels are coded in 8 bits (your case). The case RGB 16 bits is supported for other output formats and will be available for 2D TIFFs soon.

Let me know if something is not clear.

Best.

-- Giulio

2017-04-08 0:15 GMT+02:00 Puifai Santisakultarm notifications@github.com:

Sure. Here's the xml file https://www.dropbox.com/s/c10belv8v1yspmf/xml_import.xml?dl=0. And this is the image info https://www.dropbox.com/s/4g5m4xqwrdcyzeq/file%20info.JPG?dl=0.

Please note that this image isn't the exact same image as the post above. This one gives this error at the Aligning step:

[image: image] https://cloud.githubusercontent.com/assets/22781262/24820653/f770a824-1b9e-11e7-850b-e7f7b6fbea20.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/abria/TeraStitcher/issues/15#issuecomment-292664863, or mute the thread https://github.com/notifications/unsubscribe-auth/AIdv1lYiZbn8iYViBzHJP-aYjQCQItB6ks5rtrWagaJpZM4MrvyW .

--


Giulio Iannello Preside della Facolta' Dipartimentale di Ingegneria Universita' Campus Bio-Medico di Roma v. Alvaro del Portillo, 21 00128 Roma, Italy

Tel: +39-06-22541-9602 E-mail: g.iannello@unicampus.it Fax: +39-06-22541-9609 URL: https://scholar.google.it/citations?user=L-UJxIgAAAAJ


puifais commented 7 years ago

Dear Giulio

we have found the bug. Many thanks because it was a subtle one that happens only when the stitcher is launched using the GUI. I have already updated GitHub (TeraStitcher version 1.9.70), but you have to wait that Alessandro regenerates the installer before trying, unless you can rebuild the executables with CMake. Alessandro will inform you as soon as all the packages have been updated.

That's great! Thank you

  1. You started from a .czi file containing a tile matrix with 3 rows and 2 columns (I have already stitched sample images of that kind, so I know the format)

Yes

  1. Your image has two 8 bits channels

We have both 8 and 16-bit images

  1. I suppose you have extracted the tiles somehow from the .czi file and stored them as series of 2D RGB TIFFs in a two-level hierarchy of folders (is this correct?)

Correct. We use ZEN blue to export the files into a series of RGB tiff files. Then I run them through a python script that I wrote to rename and reorganize them into the two-level hierachy of folders.

  1. You have executed the import step from the GUI of TeraStitcher

Yes, with no problem.

  1. You have executed the aligning step from the GUI of TeraStitcher and got the errors

Correct. This is the error I posted above.

Steps 1-4 are ok. Consider that I have partially implemented direct stitching of datasets stored in .czi files interfacing the bioformat library with TeraStitcher. If you were interested in helping me to complete this part of the pipeline (in standby at the moment), let me know (this way you could avoid step 3 above).

I am interested although not quite sure how I can be of help. If you tell me more, I will do whatever I can to contribute.

I will wait for Alessandro's updated packages and follow the rest of the instructions. We will use 8-bit image to do the multiple channel stitching right now since TeraConverter currently handles 8-bit 2D tiff output.

Thanks! Puifai

abria commented 7 years ago

Version 1.9.70 released!

puifais commented 7 years ago

Dear all,

We successfully stitched the 2-Ch (RGB) image using TeraStitcher GUI 1.9.7 and TeraConverter! Thank you so much!!

Best, Puifai

ilykos commented 5 years ago

Just a small advice for people using TeraConverter to go from grayscale stacks to rgb channels using this command:

teraconverter --sfmt="TIFF (unsititched, 3D)" --dfmt="TIFF (series, 2D)" -s="path and name of the xml file with alignments generated by TeraStitcher" -d="path where you want to save the series of RGB TIFFs corresponding to your stitched image"

Your output folder must be empty. If there are other outputfiles from TeraStitcher merge step, it will return a dimension mismatch error.