ij-macro-programming-workshop

Previous            Exercise            Next

Exercise 21 - Measure the distance of spots to the border of the nucleus

Exercise 21.3 - Measure the distance of the spots to the border

Aims:

A distance transform takes a mask as input and outputs an image in which the pixel values represent the shortest distance from the pixel to the border of the object.

Continue the code from the last exercise! Apply the Exact Euclidean Distance Transform to the nucleus mask. Use the particle analyzer to add the spots to the roi-manager and eliminate very small objects in the same time. Make sure the min. intensity is measured (Set Measurements). Activate the EDT image and measure the rois.

roiManager("reset");
inputImageID = getImageID();
inTitle = getTitle();
DoG(1.4, 3);

setAutoThreshold("Triangle dark");
run("Convert to Mask");
run("Watershed");
spotsMaskID = getImageID();
selectImage(inputImageID);
run("Duplicate...", "duplicate channels=2-2");
setAutoThreshold("Triangle dark");
run("Convert to Mask");
nucleusMaskID = getImageID();
imageCalculator("and", spotsMaskID, nucleusMaskID);

cell-1-1.tif cell-1.tif

your code starts after this line

selectImage(nucleusMaskID);
run("Exact Euclidean Distance Transform (3D)");
selectImage(spotsMaskID);
run("Analyze Particles...", "size=50-Infinity show=Nothing add");
selectImage("EDT");
rename(inTitle);
run("Set Measurements...", "min centroid center display add redirect=None decimal=3");
roiManager("measure");
close();
close();
close();
roiManager("show all without labels");
LabelMinMaxXYXMYM
cell.tif:0001-06645.00020.100965.779663.541966.129664.711
cell.tif:0002-06636.00019.105983.881662.552983.939663.423
cell.tif:0003-06677.07120.1001012.868666.5881012.906667.463
cell.tif:0004-06717.61622.091941.944670.198941.963671.209
cell.tif:0005-06746.00017.029915.800674.510915.822675.274
cell.tif:0006-06764.12317.720902.533676.238903.057677.334
cell.tif:0007-067518.97428.862960.578675.591960.635675.902
cell.tif:0008-068928.01844.4071007.199688.4521007.038688.934
cell.tif:0009-069131.30543.4171020.580691.7881020.618692.080
cell.tif:0010-06955.09916.279867.115695.656867.641696.200
cell.tif:0011-069816.55331.3851072.849698.0911072.706698.687
cell.tif:0012-07138.60220.616855.441712.665855.761713.245
cell.tif:0013-071725.61236.620874.899717.500875.093717.641
cell.tif:0014-07235.65717.692837.315723.370837.905724.037
cell.tif:0015-072671.25379.310970.900726.777970.897726.839
cell.tif:0016-072810.00022.2041139.263728.4211138.815728.935
cell.tif:0017-07326.70820.0001151.908731.9311151.523732.800
cell.tif:0018-073618.68233.615845.899737.645846.306738.043
cell.tif:0019-07343.00013.4541165.077734.3251164.851735.202
cell.tif:0020-073440.36149.041877.978733.935878.024734.040
cell.tif:0021-074912.36929.5471167.235749.9601166.497750.709
cell.tif:0022-075590.139105.3611017.077754.9741016.951755.109
cell.tif:0023-075783.86393.295917.183757.400917.218757.456
cell.tif:0024-076193.557110.635942.552761.747942.610761.913
cell.tif:0025-07634.47219.723814.758763.737815.960764.052
cell.tif:0026-079117.46437.577818.506791.395819.271791.367
cell.tif:0027-079640.60847.8021179.696796.7161179.635796.771
cell.tif:0028-08007.07122.361799.631801.263800.573801.638
cell.tif:0029-08028.48525.2391219.944801.8211218.855802.383
cell.tif:0030-081689.140104.8051127.883815.6551127.790815.801
cell.tif:0031-0821108.227125.873903.054821.679903.180821.795
cell.tif:0032-082575.61185.907862.557825.490862.626825.528
cell.tif:0033-08255.38520.2481255.238826.0301254.630827.014
cell.tif:0034-0853160.524179.7251046.928852.4301046.891852.513
cell.tif:0035-085023.77031.953803.255851.066803.408851.165
cell.tif:0036-085662.62676.4001201.724855.8951201.605856.035
cell.tif:0037-086411.66232.2021284.349864.2241283.428864.911
cell.tif:0038-08784.12317.4931308.610877.9171307.603878.169
cell.tif:0039-088020.61636.7971287.416880.3031287.045880.757
cell.tif:0040-089353.82466.4831259.029894.0671258.887894.178
cell.tif:0041-08925.65717.0001316.653892.6291316.150893.173
cell.tif:0042-089740.31148.5491280.044897.4261279.996897.527
cell.tif:0043-090330.52944.7771293.778904.2781293.429904.450
cell.tif:0044-0905159.806174.6681109.593904.9471109.523905.007
cell.tif:0045-0904180.424187.5451086.208903.9311086.195903.948
cell.tif:0046-09114.12332.0161316.414913.3211314.392913.642
cell.tif:0047-0906154.175164.7701122.000906.0251121.978906.062
cell.tif:0048-092837.57752.8111294.189928.4331293.845928.466
cell.tif:0049-094450.01066.7081285.190945.5461284.840945.531
cell.tif:0050-09418.94421.3781329.118941.2941328.429941.783
cell.tif:0051-0945236.212244.0021048.577945.6381048.566945.653
cell.tif:0052-0945247.976255.7831032.375945.5541032.365945.568
cell.tif:0053-095012.00028.460760.827950.265761.521950.862
cell.tif:0054-095718.00036.0561318.648957.7971317.785957.999
cell.tif:0055-0956121.758129.9731218.173955.8271218.139955.834
cell.tif:0056-0968233.944241.963983.013968.000983.032968.005
cell.tif:0057-09817.00019.4161332.625981.2571331.837981.280
cell.tif:0058-0985148.930160.078891.345984.881891.393984.886
cell.tif:0059-1007283.551300.1471037.4521008.0931037.4391008.161
cell.tif:0060-10017.81020.1001334.4201000.7341333.6511001.041
cell.tif:0061-10034.00020.881741.4441002.946742.9781003.247
cell.tif:0062-1004153.209169.5791184.5211003.8291184.4001003.847
cell.tif:0063-101433.24248.703769.0001013.132769.4311013.055
cell.tif:0064-1022125.172132.673857.6821022.245857.7101022.254
cell.tif:0065-1036113.437120.880841.6051036.658841.6401036.655
cell.tif:0066-1041291.342303.9751026.3461041.8691026.3871041.884
cell.tif:0067-10443.00021.0241333.3971043.3831332.0721044.021
cell.tif:0068-1046101.124113.1111239.3991046.3351239.3011046.312
cell.tif:0069-10639.00021.095734.1261062.726734.8181062.648
cell.tif:0070-10589.48718.9741333.6981057.9841333.2671058.002
cell.tif:0071-1062266.558274.607993.8141062.729993.8291062.737
cell.tif:0072-106795.005104.3071247.6391067.5761247.5811067.572
cell.tif:0073-107266.37079.310791.5871071.933791.7451071.927
cell.tif:0074-107482.00093.0211261.1291073.6241261.0401073.596
cell.tif:0075-1073182.176192.260906.3001073.186906.3391073.189
cell.tif:0076-1077140.089149.4961196.5251076.1751196.4891076.169
cell.tif:0077-108173.11080.3061271.3541080.7251271.3031080.689
cell.tif:0078-1085124.535134.8481209.2761084.9081209.2541084.829
cell.tif:0079-1085177.544186.9791148.4391084.0481148.4021084.053
cell.tif:0080-108910.00032.5581327.9241089.8141326.1251090.565
cell.tif:0081-1091102.005110.0001234.2581090.7111234.2181090.692
cell.tif:0082-1093112.009124.487835.4151092.559835.5171092.523
cell.tif:0083-109875.92899.2471253.4791097.8901253.2021097.668
cell.tif:0084-1101123.911135.624846.2321101.366846.3091101.363
cell.tif:0085-1103152.322166.4121163.4631103.3431163.3511103.359
cell.tif:0086-1108277.894294.4101012.8821108.7791012.9131108.724
cell.tif:0087-1104101.789110.4541224.2661104.5781224.2211104.559
cell.tif:0088-11167.21124.0421326.1211117.8101325.0861117.655
cell.tif:0089-1107203.961213.8601106.0821106.2801106.0541106.268
cell.tif:0090-111025.63242.4501306.5061110.1151306.0071110.069
cell.tif:0091-111387.983100.1701232.3801113.5281232.2901113.464
cell.tif:0092-111270.80380.2121255.5721112.2251255.5141112.197
cell.tif:0093-1115146.123154.324866.0001115.296866.0331115.307
cell.tif:0094-112060.74570.7251261.7571120.8331261.6791120.783
cell.tif:0095-112919.64737.6961304.4501129.7791303.8231129.224
cell.tif:0096-114254.70871.6101252.8941142.7321252.5311142.675
cell.tif:0097-1145140.730150.416865.7961145.326865.8401145.330
cell.tif:0098-11567.21119.6471301.9341156.2501300.8761156.584
cell.tif:0099-117815.26429.0691279.4721177.8971279.2711177.211
cell.tif:0100-1183130.096151.489879.2331182.915879.3621182.742
cell.tif:0101-1182108.780126.8901178.6671182.3411178.5191182.321
cell.tif:0102-118992.914109.1791193.9181188.9731193.7381188.939
cell.tif:0103-1191170.496178.7321114.4851191.5761114.4581191.568
cell.tif:0104-119321.58733.9561267.7021193.2021267.2971193.172
cell.tif:0105-1202182.332191.6381095.0661201.3021095.0621201.270
cell.tif:0106-1200113.886121.7581171.3361200.8441171.2961200.850
cell.tif:0107-120416.27930.0171271.0111204.1181270.5011203.885
cell.tif:0108-121295.509118.9621177.7981212.8761177.3981212.854
cell.tif:0109-121439.00055.0731241.1691215.1481240.8881214.919
cell.tif:0110-121793.606109.786859.5281216.951859.6561216.844
cell.tif:0111-1218160.552171.7321108.2701218.6491108.2461218.604
cell.tif:0112-1218187.843194.1651056.5191218.5771056.5181218.561
cell.tif:0113-123265.00077.4731208.9891233.2281208.8581233.152
cell.tif:0114-1238127.475141.4851134.4501238.1621134.3441238.150
cell.tif:0115-123957.80167.956824.6491239.014824.7221238.921
cell.tif:0116-12428.06224.5151265.5601242.2801264.5171242.144
cell.tif:0117-12702.82810.8171266.0951269.8791265.6571269.480
cell.tif:0118-127139.62353.824835.3741271.123835.5311270.917
cell.tif:0119-128076.36888.4591167.5001280.5931167.4291280.488
cell.tif:0120-128214.86629.000812.9781282.519813.4171282.075
cell.tif:0121-1281117.337126.909958.5161281.742958.5461281.703
cell.tif:0122-1289118.512135.7941023.7961290.1671023.7351290.005
cell.tif:0123-12883.60614.3181253.2611287.4031252.3771287.284
cell.tif:0124-129612.80627.295826.6701297.734827.0951297.405
cell.tif:0125-129312.00027.8931239.8241293.9541238.9841293.889
cell.tif:0126-130216.40131.2411228.1041303.2531227.6981302.846
cell.tif:0127-1302116.090124.278992.4511301.992992.4681301.956
cell.tif:0128-131268.44788.1191122.4901312.4341122.2751312.166
cell.tif:0129-13143.60613.892825.5591315.912826.1241315.550
cell.tif:0130-132240.85359.4811160.9861322.2371160.7141321.878
cell.tif:0131-132779.75690.604963.7501327.385963.7401327.272
cell.tif:0132-132926.92642.4381185.9411329.6241185.6601329.276
cell.tif:0133-13329.84919.6981212.0121332.0121211.6261331.833
cell.tif:0134-133610.81727.785861.1511336.394862.1251336.070
cell.tif:0135-133716.97126.9071197.5121337.5491197.2761337.333
cell.tif:0136-134520.00045.6071155.1601344.9851154.4041344.063
cell.tif:0137-135028.84442.720903.6901349.603903.9371349.328
cell.tif:0138-135333.52644.2941124.6851354.1311124.5391353.979
cell.tif:0139-136515.81129.2061146.2631364.7371146.1461364.291
cell.tif:0140-136639.85053.141954.2161366.745954.3111366.532
cell.tif:0141-137138.62649.6491062.8011370.5821062.8151370.391
cell.tif:0142-137117.80433.5411122.8921371.0201122.3641370.609
cell.tif:0143-138219.20937.577950.1251384.315950.0761383.540
cell.tif:0144-137836.05645.880967.3361378.045967.3341377.874
cell.tif:0145-138310.29617.2051127.4411383.7551127.2981383.515
cell.tif:0146-14069.22025.0801017.2291405.5701016.7141404.820
cell.tif:0147-14085.09913.0001034.6431408.3391034.5171407.937

your code ends before this line


function DoG(sigma1, sigma2) {
	run("Duplicate...", " ");
	bigBlurID = getImageID();	
	run("Duplicate...", " ");
	smallBlurID = getImageID();	
	run("Gaussian Blur...", "sigma="+sigma1);
	selectImage(bigBlurID);
	bigBlurTitle = getTitle();
	run("Gaussian Blur...", "sigma="+sigma2);
	imageCalculator("subtract", smallBlurID, bigBlurID);
	close(bigBlurTitle);
}

Previous            Exercise            Next