3D Image registration for cell tracing

Dear all,

I am trying to trace glial cells on a long-term basis in the adult zebrafish brain. As a living organism, fish cannot remain anesthesized under the microscope for long, which does not allow me to take long videos to check movement, as can be done with cell cultures. Instead, we develop different imaging sessions (once a day) and try to check cell movements between different time points. To allow a proper tracing, we therefore need stable landmarks that would allow us to see cell shifts from these structures. For this, I am using transgenic fish lines showing blood vessels in green and our cells of interest in red.

After the last imaging session, I end up with several Z-stacks showing blood vessels and cells throughout different time points. For the analysis of these images then, I would need to bring all the different time points into register using the blood vessels as landmarks. This means, I would need to set the first image (day0) as a fixed image and modify the later time points in order to match the blood vessels with the first one, which would allow me to see the corresponding movements in the cells.

The reason why I explain all the procedure here is because I am not able to find a proper and accurate plug-in/software/tool to get this done. The closest thing I managed to get has been 2D registration using the maximal projection of the stacks through the bUnwarpJ plug-in in ImageJ. However, this does not allow me to detect cell shifts or movements on the Z axis.

I would really appreciate any help any of you could give me and I thank you all beforehand for it!

Pablo

1 Like

Hi @pbarquinvid,

Welcome to the forum.

I’d recommend trying elastix, brought to fiji by @Christian_Tischer . There’s also cmtk.
It’s hard to give more concrete suggestions, without seeing your images.

John

Dear John Bogovic,

Thanks a lot for your quick response. I will definitely try with the Elastix plug in. I was actually trying to use Simple Elastix, but I even failed to compile it on MacOS and gave up in the end. Hopefully, it will work!

All the best,

Pablo

1 Like

Hi @bogovicj,

I come back to you after unsuccessfully trying both plugins you suggested. I’ve read in some messages you haven’t used Elastix? It seems to run but for some reason I don’t get result (output) images, just the input ones and some errors.

As for the CMTK, I get the output script and run it in the terminal, but I’m not quite sure what is supposed to happen after it? I am a bit new to bioinformatics and coding, so I don’t know if I can get a viewing of my result registered image or something. I copy the script I get after running the terminal in case it helps:

zbifjn4:~ pablo$ /Volumes/PABLO/Ninkovic´s\ LAB\ PROJECT/OLIGODENDROCYTES/Live\ Imaging/CMTK\ Registration\ Trial/yourregistrationfolder/commands/munger_2019-09-26_11.27.39.command ; exit;

logout

Saving session…

…copying shared history…

…saving history…truncating history files…

…completed.

Deleting expired sessions…9 completed.

[Process completed]

THANKS IN ADVANCE!

Hi @pbarquinvid,

elastix

I’ve used elastix quite a lot recently (more recently than those forum posts :slight_smile: )

  1. What errors? If you post them here, someone may be able to help you debug. (Include the exact command line call and parameters file for the highest chance at useful help).
  2. Elastix has a bunch of stuff stored in it’s parameters file (check the manual for details). One of those parameters

Make sure your parameters file has a line that looks like this in it:

(WriteResultImage "true")

cmtk

I’m having a hard time making out what’s going on in the command line call. I actually had in mind that you use the fiji GUI plugin for cmtk. That being said:

If you want to use “munger.pl” to call cmtk, the command line call will look something like this see here.

munger.pl -b "$CMTKBINDIR" -e nii -v -aw -X 26 -C 8 -G 80 -R 4 \
    -A '--accuracy 0.4' -W '--accuracy 0.4' -T $nThreads -s \
    $target $moving

where $target and $moving are the file names for your target and moving images, respectively.

John

P.S. Hint check out this page on text formatting, it’s nice to put code / terminal commands(output) in “triple backticks”, so to get the nicely highlighted and formatted munger example above, I typed:

```bash
munger.pl -b “$CMTKBINDIR” -e nii -v -aw -X 26 -C 8 -G 80 -R 4
-A ‘–accuracy 0.4’ -W ‘–accuracy 0.4’ -T $nThreads -s
$target $moving
```

1 Like

Hello, could you tell us a bit more about how exactly you tried to run it and what the errors were? I might be able to help!

1 Like

Dear @Christian_Tischer ,

Thanks for your answer. I am trying to use the Elastix plugin for ImageJ to register 2 2-channel stacks of the same sample taken at different time points. After selecting all the folders and images the plugin window asks for and pressing OK, I come up with the following errors:

  1. File not found: TransformParameters0.txt on Output_Directory.
  2. MetaImage reader: result.mhd (no such file or directory).

Now, as I have been trying to use the Elastix software itself before, I know the 4 things to add when calling it (fixed and moving image, output directory and parameters). Therefore, I kind of imagine what the plugin means by those errors. However, I thought the transforming parameters file was not necessary on the plugin, as I already choose the registration type in the scroll down. Also, I am not clicking in the “initial transformation” check, so I don’t really understand why such “file not found” error is appearing.

As for the result image, indeed the plugin seems to write files on the selected output directory, such as the fixed and moving images used and some running overview/summary. The result.mhd image is indeed not written, though, so the plugin doesn’t seem to run. I copy here the running summary that Fiji gives:

(Fiji Is Just) ImageJ 2.0.0-rc-69/1.52p; Java 1.8.0_202 [64-bit]; Mac OS X 10.14.6; 486MB of 7284MB (6%)
 
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NullPointerException
	at net.imagej.legacy.LegacyService.runLegacyCompatibleCommand(LegacyService.java:309)
	at net.imagej.legacy.DefaultLegacyHooks.interceptRunPlugIn(DefaultLegacyHooks.java:163)
	at ij.IJ.runPlugIn(IJ.java)
	at ij.Executer.runCommand(Executer.java:137)
	at ij.Executer.run(Executer.java:66)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at net.imagej.legacy.LegacyService.runLegacyCompatibleCommand(LegacyService.java:305)
	... 5 more
Caused by: java.lang.NullPointerException

Also, find here the text included in the run_elastix.sh file written in the output directory:

#!/bin/bash

ELASTIX_PATH=/Users/agninkovic/Pablo/elastix_macosx64_v4/

export DYLD_LIBRARY_PATH=$ELASTIX_PATH/lib/

$ELASTIX_PATH/bin/elastix $@

I hope you can help me with this info, sorry if I was too extended and thanks in advance for your time!

Pablo

1 Like

This usually happens if elastix did not run through.
In the elastix working directory that you can choose in the UI…


…there should be a file called: elastix.log
Could you upload it here please?

1 Like

Dear @Christian_Tischer,

Sorry for the late reply. So, could you first clarify what I should choose as the Elastix working directory? As far as I had understood, I had to download the Elastix software itself, as well as the plugin. Now, since for Mac I could only find the binaries (which are downloaded both together in a common folder), I actually thought the working directory was this one containing the binaries. Then, as an output directory, I created one myself, where the program could save the output data. Can this be the problem, as I chose the wrong working directory? If so, should the working directory be the one containing the input images?

Again, I apologise for my ignorance regarding the topic, I am quite new in image analysis.

Thanks a lot!

Pablo

1 Like

No worries! I admit that it is a bit clunky to link Fiji to the elastix binaries in that way!
For me, it looks like this:


So, the upper one is where elastix is installed. In fact not the /bin sub-folder where the binaries are but one level up. The lower one is an arbitrary temporary directory.

1 Like

Dear @Christian_Tischer,

This is how I was doing then, and I did not get any Elastix.log file. I select as the Elastix directory the one I get when downloading the binaries, and as a working directory the one containing both my input pictures and the output directory. In the output directory, I get the following:
-Fixed.mhd and Moving.mhd
-Fixed.raw and moving.raw
-Elastix_Parameters.txt
-run_transformix-sh
-run_elastix.sh

All the best,
Pablo

It seems like elastix is not running at all.

  1. Which operating system do you use?
  2. Could you please post here the run_elastix.sh file?

Yes, that is what I was thinking as well from the beginning, but then would I even get any files in the output directory? I am using MacOS Mojave and here is the run_elastix.sh

#!/bin/bash
ELASTIX_PATH=/Users/agninkovic/Pablo/elastix_macosx64_v4/
export DYLD_LIBRARY_PATH=$ELASTIX_PATH/lib/
ELASTIX_PATH/bin/elastix @

Thanks!

1 Like

And if you go to your terminal window into that folder, what do you have there?
For me it looks like this:

$ ls /Applications/elastix_macosx64_v4.8
total 64
drwx------@ 10 tischer  staff   320B Mar  2  2018 ./
drwxrwxr-x+ 79 root     admin   2.5K Oct 11 15:03 ../
-rw-r--r--@  1 tischer  staff    11K Sep  7  2015 LICENSE
-rw-r--r--@  1 tischer  staff   2.5K Sep  7  2015 NOTICE
drwxr-xr-x@  4 tischer  staff   128B Feb 21  2018 bin/
drwxr-xr-x@  3 tischer  staff    96B Feb 20  2018 lib/

Hello @Christian_Tischer,

This is what I get, indeed almost nothing, only the bin and lib folders:

zbifjn4:~ pablo$ ls /Applications/elastix_macosx64_v4-2
LICENSE NOTICE bin lib

Ok, it seems like this is where your elastix is:

/Applications/elastix_macosx64_v4-2

But this is what is currently in the run_elastix.sh

/Users/agninkovic/Pablo/elastix_macosx64_v4/

  1. If there is no elastix in this folder it will not work… or do you have it two times on your computer?

  2. You could try putting /Applications/elastix_macosx64_v4-2 as the Elastix directory into the Fiji User interface of Elastix. Does it work then?

Dear @Christian_Tischer,

Sorry, I had two different pathways for the folders because I was answering you from my personal laptop and work computer. I was trying to get it working (unsuccessfully) in both of them. Anyway, using the elastix_macosx64_v4-2 as the Elastix directory in the interface is what I was already doing in both my computers without results.

So this is how I have been doing: I downloaded the Elastix binaries and I was selecting the Elastix directory with the pathway contained in the “downloads” folder. I have seen you indeed moved the binaries to the applications folder: “$ ls /Applications/elastix_macosx64_v4.8”. Does the binary folder need to be there maybe for proper working?

I am sorry this is taking so much time up.

Bests,

Pablo

1 Like

I don’t think it needs to be there. Did you get Elastix working from the command line?