{The original macro "ChordLength.SurfaceArea" (ftp://rsbweb.nih.gov/pub/nih-image/contrib) was developed by Prof. Robert Homer (Robert.Homer@yale.edu) was designed to measure the length of the air-tissue interface from color lung images.} {The macro developed by Prof. Homer has been modified to measure the percantage of lung occupied by paranchymal tissue (%tissue), and the surface density of the lung (Sv) from "*.OV3" images that are generated by SigmaScan Pro (Ver 5.0, SPSS, USA; www.spss.com). The "fill" command in SigmaScan Pro is used to generate an "*.OV3" image in which airspaces are black and the parenchyma is colored blue (ie. when blue is used as the fill color). The OV3 file is opened in Scion Image (Windows) or NIH Image (MAC)} {This macro measures the total number of black pixels (ie. pixels occupied by airspace) and the length of the black/blue interface to calculate %tissue and Sv respectively} Procedure onion; begin; repeat begin z:=PidNumber; Duplicate('copy'); y:=PidNumber; AnalyzeParticles('include'); autothreshold;makebinary; ImageMath('xor',z,y,1,0,z); Choosepic(y);Dispose; choosepic(z); ShowHistogram; s:=histogram[255]; choosepic(z); end; Until (s=0); end; macro 'Total surface area'; var IntVal,e,z,y,i,s,filt,ps,blk, total, tiss, i:integer; sum:real; file:string; begin ResetCounter; {The first part will return black pixles for estimating the %tissue. Prompt user for total number of pixles. The default value is 307200 (640 x 480 pixels) although it can be changed as needed} total:=GetNumber('Total pixels in file :', 307200); {measure the number of black pixels (ie. airspace pixels) of image, then calculate %tissue from total and black pixels} measure; blk:=histogram[255]; tiss:=100 - (blk/total*100); {*** optional *** PutMessage('% tissue=', tiss);} {The length of the air:tissue interface is detrmined using the perimeter function of Image, in conjuction with the "Onion" procedure designed by Prof. Homer. The macro prompts the user to "Ignore which size holes?". This allows small unfilled areas of lung parenchyma that are not associated with the epithelial surface to be excluded from analysis. The default value is 200, however this will need to be adjusted for images taken at different magnifications. In our experience, surface area measurments are increased by ~2-3% when all "holes" are included in the analysis.} { ** insert if colour images ** IntVal:=GetNumber('Threshold equals?(1--255):',50);} SetPrecision(2,8); file:=WindowTitle; ps:=GetNumber('Ignore which size holes? (0-50000):',200); SetParticleSize(ps,5000000); SetOptions('Perimeter, User1, User2'); ResetCounter; Redirect(false); LabelParticles(false); OutlineParticles(false); IgnoreParticlesTouchingEdge(false); IncludeInteriorHoles(false); WandAutoMeasure(false); AdjustAreas(false); SetUser1Label('total length'); SetScale(1,'pixel',1); SetThreshold(50); {need to change setThreshold from 50 to "IntVal" if using colour pictures, see above}; MakeBinary; filt:=GetNumber('How much filtering?1-2 OK. (0-99):',2); while filt>0 do begin Filter('Median'); filt:=filt-1;end; onion; Dispose; dispose; sum:=0; for i:=1 to rCount do sum:=sum+rLength[i]; rUser1[rCount]:=sum; rUser2[rcount]:=tiss; {copy results to clipboard} copyResults; PutMessage('Results in clipboard -- paste into excel',); ResetCounter; Dispose; end;