imaging articles code

ImageJ macro to synchronize and combine image stacks

The embryos I study rarely develop in perfect synchrony. That means that when I film them under the microscope some embryos will be younger—or older—than others.

ImageJ macro with Drosophila embryo
Using an ImageJ macro to help me analyze movies of Drosophila embryos.

For this reason, I often need to synchronize the recordings to make sure they all begin at the same embryonic stage. When the movies are synchronized I can combine them side-by-side, and it becomes much easier to compare and spot differences between two embryos.

ImageJ macros save time

Combining movies in Fiji/ImageJ is straightforward using the Combine... command. But synchronizing is way harder. It depends on human classification and involves some calculations and stack juggling that can (and will) become tedious.

To help me out, I wrote a small ImageJ macro available here: SyncAndCombineStacks.ijm. Follow below to see how it works.

Combined movies without syncing

That’s what unsynchronized movies look like. I combined them fresh off the microscope without any synchronization:

Two embryos of the fruit fly Drosophila melanogaster. Both were acquired in the same microscopy session. The top embryo is older than the bottom embryo.

Combined movies after syncing

Here are the same two movies now synchronized by the embryonic stage:

The same two embryos are now synchronized.

How it works

The macro performs the hard work. It calculates how many frames to trim from each stack. Then it duplicates the selected range of frames common to both stacks. Finally, it combines the synchronized recordings into a single image stack. All you need to do is to select the corresponding frames between the two stacks.

Step-by-step instructions

Here are the instructions step-by-step:

  1. Open both image stacks in ImageJ.
  2. Adjust the contrast if needed (before running the macro).
  3. Select a reference frame in the top stack (e.g. stage easy to recognize).
  4. Select the correspondent frame in the bottom stack.
  5. Run the macro and fill in the dialog parameters.
  6. Click OK, wait a few seconds, and check if the synchronization is good. Otherwise, re-run with different parameters.


I’ve also recorded a small screencast:

Note! The macro does not touch the original stacks, but it outputs an RGB Color stack. There are a couple of reasons for that. Converting to RGB avoids contrast issues when the stacks have different pixel intensities. It also prevents quirks in video players that can’t handle 16-bit movies. But if you need to perform image analyses on the final stack, remove this option. I may add a checkbox for that in the future.

notes code

The PostdocNet website

Sometime ago I created a new logo for the PostdocNet, the network of postdocs of the Max Planck Society. The next step was re-designing their website… but then came 2020!

PostdocNet website
The new landing page for

Despite the challenging year, the website recently went live! I hope people enjoy the new visuals and I’m happy to have contributed to the PostdocNet :)

articles code

Convert video to animated GIF

Something that I began doing more often is converting videos of developing embryos or marine invertebrates to animated GIFs. But how to do this conversion without affecting the quality of the video?

A jellyfish moving its tentacles. Source: Cifonauta.

Some time ago I found this guide to convert videos to high-quality animated GIFs using the tool FFmpeg. The trick is to generate a color palette based on the original video to improve the color quality of the GIF. Based on this guide I created a small bash script to make my life easier and perhaps yours too ;)

Check it in

notes code

The PostdocNet logo

The PostdocNet is an organization that represents the collective of postdoctoral researchers working in the Max Planck institutes spread throughout Germany.

The network is relatively recent, only founded in 2019, but has already put forward important proposals to improve the working conditions and career development of postdocs.

A few months ago they contacted me to help re-design their logo and website to better represent the identity of the organization. Since I enjoy creating websites and I’m sympathetic to the mission (disclaimer: I’m a postdoc) – I accepted the challenge :)

After some rounds of feedback from the PostdocNet working groups, the final version of the logo is finally here:

The new PostdocNet logo.

You can read more about the story behind it here.

Now the website is next…

science articles code

Search PLOS articles using DuckDuckGo

Last year I decided to experiment with DuckDuckHack, the developer platform for the search engine DuckDuckGo. The idea was to use the instant answers to find scientific articles as a quick Google Scholar shortcut.

It’s feasible, in principle, but I decided to try something simpler. A plugin that uses the PLOS API to search their articles and display in the instant answer box.

To use it you just need to add the word “plos” + keywords (example above). The result is a list of titles and dates of the five most-relevant articles with direct links. Hovering the mouse over a link will show the authors and which PLOS journal. This final format was simplified after the initial pull request and polished up in the second.


The code is a simple Perl function that connects the PLOS API to DuckDuckGo, and a javascript function that handles the search response. The DDG community was quite friendly to help out with the code.

Since DuckDuckGo is less used than Google I guess the number of users might be low. Maybe I’m the only one… It would be amazing if it could query the whole scientific literature! But well, I like this little hack. I guess it’s the excitement of connecting services using APIs.

code notes

PLOS DuckDuckHack

Just prototyped a @duckduckhack spice plugin with @PLOS Search API! It shows top5 articles for a query. Suggestions?

PLOS DuckDuckHack

Edit: check out the final version.

articles biology code

Living Bibliography

Living Bibliography was born when, a few weeks ago, on a Saturday morning, I bumped into the Hack4Knowledge, a meeting to build apps, tools, and remixes with existing databases to innovate and enrich the creation and dissemination of knowledge.

I was already playing with the Mendeley API and took the opportunity to put an idea into practice: aggregate bibliographic references related to a taxon. It is not a particularly new idea, and it also does not differ much from searching a taxon name on google or Scopus, but since the Mendeley database is based on its users’ collections, it is possible to extract some interesting information. For example, find out which articles are more popular or create trending topics with popular taxa based on the number of readers and related publications.

Living Bibliography homepage
Living Bibliography homepage

Regardless of the source, article data also allows extracting useful information such as the most active authors on a certain taxon, network of collaborators, annual variation in the number of related articles, popular research topics for each group, etc. Integrating the data and using visualization tools it would be possible to “see” holes in the knowledge or follow the history of one’s research.

Imagine if every article was freely available with contained information (metadata) about the studied organisms with taxonomic classification, occurrence data, collection sites, dna sequences, citations with semantic markup, research topics, hypotheses to test, methods, raw data, etc. Anyone would be able to have a summary of the current knowledge about an organism. Especially interesting to set research quidelines and avoid spending money with the same mistakes; optimization of science. And do not forget about the possibility to attach observations, annotations, discussions, unsolved questions, and other collaborative activities.

Well, after creating a prototype of the idea, I have just pust the basic functions of the aggregator to work. Nothing I wrote above is included, just a search interface where you can use a scientific or common name and a page for each taxon with a list of related references and some sorting options. If a taxon is not in the database, it searches in realtimes, therefore, it is necessary to wait for a little while and reload the page (at least until I automate this).

Taxon page in Living Bibliography
Taxon page in Living Bibliography

If you are interested you can test the Living Bibliography at Just remember it is completely experimental, I do not guarantee that your favorite articles will appear or that the information will be accurate (there are many duplicated articles, wrong author names, badly formatted titles, swapped journal names, and so on at Mendeley). I don’t know how much I’ll be able to work on it, but the source code is open and I would love to hear ideas and suggestions :)