# Bioimage Analysis Wiki

### Sidebar

EMBL BioImage Data Analysis

EuBIAS

NEUBIAS

Popularity Ranking

 clij moved to a new house https://t.co/XJ0YBhE2jE About 2 hours, 37 mins ago by: Kota Miura (@cmci_) RT @regagino: My postdoc work with Sarah Woolner's lab @FBMH_UoM is out @CellReports! Decoupling the Roles of Cell Shape and Mechanical St… About 17 hours, 58 mins ago by: Kota Miura (@cmci_) RT @sbarolo: #WomeninSTEM get a lot of “Reply Guys” who repeat the same unhelpful comments. @shrewshrew and I (a woman & a man in science)… About 17 hours, 59 mins ago by: Kota Miura (@cmci_) RT @cohenlaboratory: Female with microscope? Add yourself to the list! https://t.co/gN3ThsklUj About 1 day, 17 hours ago by: Kota Miura (@cmci_) RT @Dr_Fluo: The mesmerizing real-time shuttling of protoplasm within the plasmodial syncitium of the #Physarum #SlimeMold. Scarily dynamic… About 1 day, 20 hours ago by: Kota Miura (@cmci_) I did the same on Sunday hearing the news. Many of the monologues of the people were a bit remote to me when I was… https://t.co/5dZWBQPMv5 About 1 day, 20 hours ago by: Kota Miura (@cmci_)
blogtng:blogtop
Algorithm FRAP Fiji ImageJ ImageJ Plugin ImageJ Plugin 3Dviewer Imaris Java Javascript Python R bias blog dokuwiki fiji google imagej java libraries matlab meetings neubias news papers python references software webadmin

# CMCI weblog

## Marriage Matching Algorithm

Consider that we have probe 1 and 2 labeling some molecule as dots, and for each cell we have several signals for each probe, cf. 3 dots for probe 1 and 2 dots for probe 2. The we have an assignment that we want to pair them each, leaving one probe 1 dot unpaired (cf. In my case I know that a probe 1 dot and a probe 2 dot are on a same chromosome.) What would be the algorithm?

In broader sense, this is a combinatorial optimization problem but I thought there could be simpler way of doing this.. then following is some possibilities.

One way is to construct a cost function, such as “sum of distace between paired”, calculate cost funciton for all possible combinations and choose the one with the lowest sum.

I found otherway of doing this, by so-called "stable marriage algorithm". In this case, same each number of boys and girls are matched.

In Javascript it should be as follows:

function make_matches(gb, bg){
var N = gb.length;
var boy = [], girl = [], position = [], rank = [];
var b, g, r, s, t;
for (g = 1; g <= N; g++){
rank[g] = [N+1];
for (r = 1; r <= N; r++){
b = gb[g-1][r-1];
rank[g][b] = r;
}
boy[g] = 0;
}
for (b = 1; b <= N; b++){
girl[b] = [0];
for (r = 1; r <= N; r++){
girl[b][r] = bg[b-1][r-1];
}
position[b] = 0;
}
for (b = 1; b <= N; b++){
s = b;
while (s != 0){
g = girl[s][++position[s]];
if (rank[g][s] < rank[g][boy[g]]){
t = boy[g]; boy[g] = s; s = t;
}
}
}
return boy;
}



Only the problem when applying this to a problem with non-equal number of boys and girls population. For this case, either modify the above algorithm, or prepare a dummy with very low ranking to satisfy the equal number of populaiton for using the algorithm as the above.

more references

## Bleach Correction (2)

As I test through different method further

1. Phair's method (or simple ratio)
2. Exponential decay fitting (or exponential ratio, I call)
3. Histogram streching,

all these methods are not really satisfactory. so I kept on searching for other methods and I tested something not used often, which is called “Histgram Matching”, and it seems to work better. Bleached images are better be blurred a bit. I might try implementing it as another method for bleaching correction.

Followings are links related to this method, which I referred to.

Histogram equalizaiton theory (by R. Fisher, S. Perkins, A. Walker and E. Wolfart.@ Image Processing Learning Resources).

I also refrred to Digital Image Processing using Matlab“ but it was too simply formulated (and, the matlab function which should be used is indicated but too short).

Paper: “A statistical approach for intensity loss compensation of confocal microscopy images”, Gopinath et al (2007) J. of microscopy ( Link). This paper tries to correct the acquistion bleaching while the image itself is changing a lot (the sample seems to be internalizing cell surface recepter, so from diffuse signal to dotty signals). In case of sequences with less changes in signal shape, the problem is more simple and straightforward, but such dynamic version should be already in our sight. (by the way, I am always amazed by works which Luby-Phelps is involved in. When I found the name on this paper, amazed again…).

Point Operations
CMPUT 206, Instructor: NilanjanRay
(powerpoint slides in PDF)

Java library: source for historam matching is in Burger & Burge website, chapter 5.
"Digital Image Processing: An algorithmic introduction uing Java"

## Photobleaching Correction -3D time series

There are several IJ tools available for 2D time series bleaching correction, but seems not with 3D:

2D-t tools:

• Phair's double normalization method. Dependent on ratio, similar to the above, but can specify reference area (if my understanding is correct).
• proposes two ways,
1. conceptually similar to above two: estimate the correction ratio. But this is done by fitting exponential decay curve and use decay parameter.
1. <jsm> I_c(t) = I(t) / exp^{-\tau t}</jsm>
2. use “enhance contrast”. framewise Histogram streching.

Among these, exponential decay method is theoretically clean (but in practice, timeseries are not teoretical…).

Anycase, there should be 3D-t bleach correction tool (and I need it NOW). I might make some quick solution using two methods, one using division of first frame and the other with exponential fitting.

By the way, bleaching corrected images cannot basically be used for intensity quantification (FRAP, on the other hands, correct bleaching after measuring the raw image). If you are analyzing shapes or positions, no problem for quantification.

here is the “ratio” version:

macro "Bleach Corection 3D-t by ratio"{
run("Duplicate...", "title=bleach_corrected duplicate");
getDimensions(width, height, channels, slices, frames);
if (frames == 1) {
uslices = getNumber("how many z slices/timepoint?", 1);
if ((slices%uslices) !=0) exit("that slice number dows not match with the current stack");
frames = slices / uslices;
}
tIntA = newArray(frames);
setBatchMode(true);
for(i=0; i<frames; i++){
startf = (i*slices)+1;
endf = (i+1)*slices;
op ="start="+startf+" stop="+endf+" projection=[Sum Slices]";
run("Z Project...", op);
//print(op);
getRawStatistics(nPixels, mean);
if (i==0) tIntA[i] = mean;
else tIntA[i] = mean/tIntA[0];
close();
}
setBatchMode("exit and display");
tIntA[0] =1;
for(i=0; i<frames; i++){
for(j=0; j<slices; j++){
curframe = i*slices + j+1;
setSlice(curframe);
//print("frame"+curframe + " factor" + tIntA[i]);
op = "value="+tIntA[i]+" slice";
run("Divide...", op);
}
print("time point:"+i+1 + "  factor" + tIntA[i]);
}
}



Before Correction (each row is a time point, with 8 z-slices)
Average intensity along stack slices. 5 peaks corresponds to 5 time points.

After Correction