Categories
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. 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.

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.

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

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

And here are the same two movies now synchronized by embryonic stage:

The same two embryos, now synchronized.

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. Here are the instructions step-by-step:

  1. Open both image stacks in ImageJ.
  2. Adjust 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 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.

Categories
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 http://www.postdocnet.mpg.de/

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 :)

Categories
notes 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 https://github.com/nelas/gif.sh

Categories
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…

Categories
articles code science

Search PLOS articles using DuckDuckGo

Last year I decided to experiment with DuckDuckHack, the developer plataform 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.

Screenshot from 2013-10-19 11:25:05

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.

Categories
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.

Categories
articles biology code

Living bibliography

On a Saturday morning a few weeks ago 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 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 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 ou create trending topics with popular taxa based on the number of readers and related publications.

Living Bibliography Home Page
Living Bibliography home page

Regardless of the source, article data also allows to extract 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. Specially 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 a little and reload the page (at least until I automate this).

Living Bibliography Taxon Page
Living Bibliography taxon page

If you are interested you can test the Living Bibliography at livingbib.organelas.com. Just remember it is completely experimental, I do not garantee 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 :)