abria / TeraStitcher

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

Empty Output When Using CLI #74

Closed JulianPitney closed 3 years ago

JulianPitney commented 3 years ago

Background: Terastitcher (GUI version) has been working well for us for a while now. It's use has become a routine part of our microscopy pipelines. Since we're doing it so often I decided I should automate it with the CLI. I've gone through all the documentation multiple times and tried to use it to write a script that does exactly what we've been doing with the GUI. This script is shown below.

:: Step 1 (Import)
set volumePath="C:\Projects\terastitch_script\test"
set ref1="x"
set ref2="y"
set ref3="z"
set vxl1="1.43"
set vxl2="1.43"
set vxl3="5.0"
set imin_regex="000000.tif"
set imin_plugin="tiff3D"
set volin_plugin="TiledXY|3Dseries"
terastitcher --import --volin=%volumePath% --ref1=%ref1% --ref2=%ref2% --ref3=%ref3% --vxl1=%vxl1% --vxl2=%vxl2%^
 --vxl3=%vxl3% --volin_plugin=%volin_plugin% --imin_regex=%imin_regex% --imin_plugin=%imin_plugin%

:: Step 2 (Align)
set USECUDA_X_NCC=1
set projin=%volumePath%\xml_import.xml
set /a oH=245
set /a oV=205
set /a sH=99
set /a sV=99
set /a sD=99
terastitcher --displcompute --projin=%projin% --oH=%oH% --oV=%oV% --sH=%sH% --sV=%sV% --sD=%sD%

:: Step 3 (Project)
set projin=%volumePath%\xml_displcomp.xml
terastitcher --displproj --projin=%projin%

:: Step 4 (Threshold)
set projin=%volumePath%\xml_displproj.xml
set threshold="0.7"
terastitcher --displthres --projin=%projin% --threshold=%threshold%

:: Step 5 (Place)
set projin=%volumePath%\xml_displthres.xml
terastitcher --placetiles --projin=%projin%

:: Step 6 (Merge)
set projin=%volumePath%\xml_merging.xml
set volout="C:\Projects\terastitch_script\result"
set volout_plugin="TiledXY|3Dseries"
set imout_plugin="tiff3D"
set /a resolutions=1
terastitcher --merge --projin=%projin% --volout=%volout% --volout_plugin=%volout_plugin% --resolutions=%resolutions% --imout_plugin=%imout_plugin%

Problem: At first this script seems to work (All the correct directories and files are created and all the steps appear to run successfully). However, when I open the stitched/output tiff stack, the stack is completely empty (all 0's/all black).

I've been troubleshooting this all night now but still can't nail down the problem. So far I've tried:

Please let me know if you have any ideas. I'll update this post as I make progress. Thanks in advance.

iannellog commented 3 years ago

I have no time now to examine your problem in detail. In the meantime, to help me could you please:

JulianPitney commented 3 years ago

No problem. I appreciate you taking the time to respond at all. In regard to your questions:

iannellog commented 3 years ago

I had a look to your xmls and I do not find any evident problems with them. The only difference seems to be that the default value of the --subvoldim option is 100 in the GUI version and 200 in the CLI version. It should not make any difference for your problem, but you can try to use the same value just to check.

One other information I would like to check just to be sure is the version of TeraStitcher you are using. Please run terastitcher --version and send it to me.

Send me also the xml_merging.xml files of both versions for checking also them.

Finally, try to run the following command (without using the script):

terastitcher --merge --projin="C:\Projects\terastitch_script\test\xml_merging.xml" --volout="C:\Projects\terastitch_script\result" --volout_plugin="TiledXY|3Dseries" --resolutions=1 --imout_plugin="tiff3D"

Run it using the xml_merging.xml file generated by both the GUI and the CLI, and check if there is any difference.

JulianPitney commented 3 years ago

I ran the same scan I was using for testing through the GUI version again just to rule out a problem with my .tif files. The GUI version works perfectly.

I also installed everything from scratch and tried the same script using the same data on a different machine. There was a large change in the file size of the output. On the original machine, the output is generally about ~50MB. On the new machine, the output was ~500MB. Both were still empty/black however. I should note that the file size of the output when using the GUI version is ~1.9GB. (Everything works correctly in the GUI case).

iannellog commented 3 years ago

Sorry for the many questions, but I am trying to figure out what is happening.

Let me resume the situation:

Actually the two versions compute different alignments on your image (I do not know why, possibly for the difference in --subvoldim). Again this should not be the reason of your problems, but it is not easy to be sure. If you can, you could do some more experiments:

One more thing is that I noticed that you enabled the USECUDA flag in the script. Actually this is weird, since version 1.10.18 does not contain CUDA code.

I do not make tests with version 1.10.18 since a long time. I will try it just to check if there is some bug I fixed in versions 1.11 and then forgotten.

JulianPitney commented 3 years ago

One more thing is that I noticed that you enabled the USECUDA flag in the script. Actually this is weird, since version 1.10.18 does not contain CUDA code. Yeah I was initially trying to get CUDA running but then I noticed that the windows binaries don't have CUDA built in. I've tried removing that line but it seems to have no affect either way. I'm assuming terastitcher detects that CUDA is not available and defaults to CPU.

I do not make tests with version 1.10.18 since a long time. I will try it just to check if there is some bug I fixed in versions 1.11 and then forgotten. I'm comfortable with C++ debugging, if you want to point me to some .cpp files I can help look.

EDIT: Can I ask if you or anyone you know has the CLI version working correctly right now? If yes, what's their environment like? Which OS are they using? Because I'd be willing to setup a new machine with a different OS/Environment if that would make this work.

iannellog commented 3 years ago

The CLI version has been used by many people with no problems, so your case is really very weird. The fact that the alignments computed by the two versions with the same input parameters are different (very different in some cases) prove that there should be something wrong in your executables. Just to avoid too much tests, could you please let me download just one non empty tile of your dataset? With one tile I can reproduce a test dataset and check if version 1.10.18 on Windows (are you using Windows, right?) has also problems on my machines. If you want to do another test, try to download version 1.11.10 which contains only the CLI version and that work fine on my machine stitching one channel, 16 bits, images. I will write you again as soon as I have news.

JulianPitney commented 3 years ago

Here's a Google Drive link to one of our tiles. (https://drive.google.com/file/d/1jBowXoVYjSzmC7rNrstr_6l6AMA7jAP7/view?usp=sharing)

Yes I'm using Windows 10.

Yeah I'm going to try with 1.11.10. I have no idea how I ended up with the 1.10.18 CLI version. I'll report back after testing 1.11.10

iannellog commented 3 years ago

I have just stitched a test dataset using your image (4x4 tiles) Of course all tiles are equal, hence alignment computation is meaningless. However this does not affect the execution of single steps of the pipeline. The final image is correctly generated. I used CLI version of release 1.11.10 on Mac OS (however I am sure that it works on all platforms).

JulianPitney commented 3 years ago

[SOLVED]

Success! Using 1.11.10 on Windows worked perfectly.

I also discovered how I ended up using terastitcher version: 1.10.18 (with Qt 5.2.1). I installed the GUI version some months ago and didn't realize it had added the binaries to my PATH. Even though I had added the 1.11.10 binaries to the PATH, it was finding the 1,10,18 version first. Everything is clear now.

Thank you very much for your help. Greatly appreciated.