📜 ⬆️ ⬇️

Chronicles of the laboratory: how we considered ground coffee as a software for analyzing cellular structures



Other articles of the cycle:
Hello, I am Meklon and I am caffeine-dependent
Compote from coffee dried fruits. Meet a cascara - a cyclist's best friend

I continue the coffee theme, which I started on geektimes: Hello, I am Meklon and I am caffeine-dependent . Today, we will create lewdness with software for bioengineering tasks - CellProfiler. Normal people consider them to be cells, plasmids, protein expression, and other necessary things. We are damned, so we will carry out a grain-size analysis of the milling of micrographs, beat coffee with static electricity and think about how to attach a hairdryer to this outrage. And of course, we will need an adhesive tape to obtain a graphene pattern of particle distribution.
')
In general, computer image analysis is flexible and can be used in completely strange tasks. At the same time we will check whether it is possible to replace the Turk with a flask with a magnetic stirrer. In the end, the main principle of survival in the laboratory - "No coffee - no work") There are a lot of photos under the cut, but I tried to shrink them to a decent size.

Graphene and coffee




The main task that I wanted to solve was an objective comparison of the quality of grinding of different coffee grinders. In theory, high-quality grinding is characterized by perfect uniformity. So we need to count the number of particles in a given area and sort them by size. The greater the variance - the worse the quality. The simplest example is a rotary coffee grinder, which breaks up grains with fast rotating blades. In its profile of grinding there are simultaneously large fractions and fine dust. Good espresso from this coffee will not work. The problem is related to the uneven penetration of the “water channels” through which the coffee tablet is poured. Small particles will give bitterness due to overexposure, and large ones will create “workarounds” that will make the coffee watery. In contrast to the rotary, a mill-type coffee grinder gives a more or less calibrated version with identical particles.
Actually, now the task consists of two main points:
  1. Place the particles in a normal distribution on a transparent substrate so that they can be photographed with a microscope
  2. Calculate the size and number of particles manually for a couple of years automated complex
  3. Take stock, make a cup of good espresso and meticulously praise yourself for your wits

When we raised this question in the previous topic, sptor and mwizard suggested using vibration in various ways. But this method, like many others, has a very important drawback - the unevenness of the effect of vibration on particles of different sizes. We need to get a cast of real average composition, and not create a sorting tray of the gold miner in miniature. The most successful idea came to mind eexo - use regular tape. What exactly is a good method? Cheap, angry. Just at first glance. And most importantly - by touching ground coffee with scotch tape, you get a complete set of particles in a realistic distribution. Naturally, without a rake, electrical injuries and villainous laughter during the experiment could not have done ...


The result is a little closer


Hair dryer against electrophore machine


image

One of the main problems I encountered was the tendency of small coffee dust particles to stick together, which ultimately leads to an incorrect definition of the boundaries and sizes of objects. The logic suggested that the problem could be solved by electrifying the coffee particles with the same charge. It remains only to understand how it is easier to do. Van de Graaff generator was not at hand. I decided to just shake the bag of ground coffee. Since the package turned out to be slightly leaky, I had to sweep and wipe the coffee powder throughout the laboratory for a long time. Yes, and electrification especially did not work.

An alternative version was presented to me at one of the university exhibitions, where unhappy schoolchildren are brought by buses and forced to be inspired by the expositions of educational institutions. I had fun with a simulator of endoscopic operations, removing the gallbladder for speed, but after the third round it was getting annoying. I wasn’t allowed to sit quietly on the Internet. Every 15-20 minutes, all wireless communication tightly fell. When I decided to go to the neighboring stands - I saw those strange people who had collected a Tesla coil and a couple of related devices from a pile of copper wire and someone's mother. It was this vundervaflya shit in all frequencies when turned on and dropped the entire connection.



I tried to remove this tired man, who once again showed the children glowing gas-distributing tubes, but the phone was beginning to go wild with the mind next to the installation, throwing out the camera’s hardware error, and then hanging tight. The tablet seemed to hold, but the file slightly beat. Tesla Coil, the thing is certainly cool, but it does not solve my problem. But on the same table they found an electrophore machine with leyden banks. I used this kind of car when I was at school, so that I could charge classmates in the corridor with electric shocks. The physics teacher scolded and screamed so that I would immediately be grounded to the battery. In general, I immersed one of the electrodes in the coffee and began to rotate the handle. Judging by the fact that the hair began to crackle quietly - the potential was gained tangible. But svolochnaya powder stubbornly did not want to fluff. Then I made a big mistake, deciding to add more statics. The Leyden banks that they used were somehow particularly evil. And very, very capacious. A beautiful flash between my hands turned out to be extremely painful. Apparently, the people carefully finalized the design.

As a result, I also refused an electrophore machine and decided to take pictures as it is. Already after I photographed the samples, an alternative idea came to my mind, but there was no time to implement it. There will be a mood - try. The idea is to use very hot air, friction and convection at the same time. That is stupid hair dryer and pipe. Pour a teaspoon of coffee into the pipe, turn on the hairdryer, wait for the electrification and drop the scotch tape on the hard frame inside to collect the particles. The diagram below:



Microscope and CellProfiler




Having received our portion of thoughtful views from colleagues, we solemnly go to the microscope, waving pieces of scotch. As it turned out, coffee particles have an interesting translucent structure at high magnification:


Another photo


Unfortunately, our microscope does not support z-stacking , and in EXIF ​​does not write enough data to do this in a third-party software. Therefore, the depth of field is small and collecting a clear picture from the series will not work.

In principle, for our purposes, we do not need perfect clarity. Therefore, we take a 4x lens and photograph our future espresso:


Sample from the roaster, ground Mahlkoenig EKK43


Sample from my home grinder, ground DeLonghi KG89

Unfortunately, something fell off in the camera built into the microscope and she started to make a lot of noise. I assumed that the Peleté element on the matrix had died, but it was not possible to cool it down normally with a coolant. Therefore, the second frame looks quite beaten due to post-filtering.

Now we give the images to the entrance of the specialized free software CellProfiler . It is rewritten in Python, was once a superstructure over MatLAB. Developed by a small team of The Broad Institute of MIT and Harvard. The interface is completely non-humanoid, but it allows researchers like me to perform complex batch processing and statistical image analysis without deep programming knowledge. Everything is organized in the form of a pipeline, when the original image is fed into the input, then the necessary manipulations are performed on it, the necessary objects are recognized, counted and measured, after which the cycle is repeated again on the entire file array. As a result, some time is spent on writing the pipeline, but then you can feed at least 100,000 images and go for tea. The process is parallelized according to the number of processor threads.


Program interface

I will briefly describe the stages:
  1. Convert three channels of 8-bit sRGB into one, monochrome
  2. Invert image. This is a historical feature - the program is sharpened by the recognition of light objects on a dark background
  3. Threshold filtering for background clipping. A manually selected global threshold was used.
  4. Identification of objects and their boundaries. The Otsu algorithm was used to separate objects from the background.
  5. Measurement of object parameters - area, eccentricity, diameter, etc.
  6. Classification of objects into 3 conditional groups by the parameter "area"
  7. Saving selected results table and saving individual intermediate images




Here is the identification of objects. Recognition in our version is far from ideal, since it did not turn out to separate stuck particles. According to the settings, the algorithm, after separating the background, tries to find round-shaped objects.

Recognized objects, large. Bounding defects are visible




After sorting into small, medium and large particles, we obtained the following distribution for a professional and home grinder, respectively:




I will not interpret the results, since the samples did not initially meet the requirements for separation of particles. If someone is interested in repeating, I laid out the pipeline for Cellprofiler on Dropbox . You can check it yourself. Visually, grinding on a professional machine is more uniform, but more difficult to say. Very high sample requirements for normal statistics.

Other uses


CellProfiler doesn't care what to count. I quite successfully sawed the pipelines for analyzing some nanocrystals. For fun, I even tried to see how he would cope with the definition of objects in astrophotography. In the example below, I simply fed the software a high resolution photo of the starry sky and brought all the channels into one monochrome. Theoretically, playing with filters and intensity thresholds, you can separate the stars of different spectral classes from each other. Especially if the source is not 8-bit. The program natively supports work with wide dynamic range images.

The source, a little crushed Habrastorage:



But honestly certain 34767 stars with some degree of error.



With further analysis, you can analyze the coefficient of the neighborhood, use masks, sort by area, color, or something else.

How to make coffee in the lab


Thinking well with Diana, we decided that Guatemala Plataniyo Ezipto should not be lost to our favorite variety. I love him wildly for the fullness and fullness of espresso, with tantalizing notes of mature cocoa and light sourness. One of the brightest varieties of medium degree of roasting, in my opinion. Especially when it is fried a few days ago. But since we started testing the samples, we decided to try an alternative approach to making coffee. We will cook it on a precision laboratory heater with a magnetic stirrer. The main thing is not to get then on the head from the head of the laboratory.

This will help me Diana in_green_shoes . She is actually a linguist and translator, but sometimes, when no one sees her, she puts on a robe and makes a smart appearance, playing a scientist.



First we collect de-ionized water from Milli-Q. On resistance - a deaf insulator with a resistance of 18.2 MΩ · cm Water of such purity is used for analytical chemistry, molecular biology and now for coffee brewing.

Diana with a smart look examines a flask with water


Now you need to carefully examine the sample. And make friends with him. After all, this is a friend-coffee powder. This variety makes her especially happy, yes.




We accurately weigh the right amount of coffee. We weigh exactly. Four decimal places will be enough, I think. We are in the laboratory after all.



Pour coffee into a flask and throw a neodymium magnet in a ceramic shell. During the cooking process, it will rotate at a speed of about 1000 revolutions per minute, ensuring maximum extraction.




And here is the heater itself. In theory, it is also necessary to dip the feedback sensor in the coffee, but before that it was used with something toxic, and patiently expect that something does not fall off. Therefore, we decided to get by with a simpler version. Just set 320 degrees for primary heating and reduce the temperature to 97 just before boiling. The magnetic stirrer rotates like an abnormal, providing continuous stirring.




We catch foam raising in the same way as with classic Turk:



As a result, we get burns due to the fact that we have forgotten about heating the neck of the flask from hot steam. At the next attempt we use thick gloves and gently pour the result into cups. The coffee turned out to be aromatic, but very highly extracted. Eyes open sharply and you start to run like caffeine protein. The method is actually just for fun, but why not try it? Well, as a bonus, I will add more photos from this photoset)

I think coffee has a strange effect on her.






PS I still managed to contact the guys from Torrefakto, promised to find time to answer questions. They actually have a lot of different high-tech stuff. Only one photocolorimeter for accurate determination of the color of the grain is worth something. This, for example, is an important point in an objective assessment of the degree of roasting. If it is interesting, I will try to find time to talk about these things.

Source: https://habr.com/ru/post/271405/


All Articles