Project

General

Profile

Skin Tools » MRI_Skin_Tools.txt

The toolset of the MRI Skin Tools - Volker Baecker, 10/06/2011 01:55 PM

 
/**
* MRI Skin Tools
*
* The Skin Tools allow to analyse masks of skin
* tissue that touch the right and left border of the image.
* The length of the lower border line is measured. For
* each extremum on the lower border line of the mask the
* length of a vertical line across the mask is measured.
*
* written 2011 by Volker Baecker (INSERM) at Montpellier RIO Imaging (www.mri.cnrs.fr)
*/

var helpURL = "http://dev.mri.cnrs.fr/wiki/imagej-macros/Skin_Tools"
var minRadius = 15;

macro "Unused Tool - C037" { }

macro "MRI Skin Tools Help Action Tool -C000D00D01D02D03D04D0aD0bD0cD0dD0eD0fD10D11D12D13D14D1aD1bD1cD1dD1eD1fD20D21D22D23D24D2aD2bD2cD2dD2eD2fD30D31D32D33D34D3bD3cD3dD3eD3fD40D41D42D43D4cD4dD4eD4fD50D51D52D5dD5eD5fD60D6eD6fD70D7eD7fD80D8dD8eD8fD90D91D9bD9cD9dD9eD9fDa0Da1Da2DaaDabDacDadDaeDafDb0Db1Db2DbaDbbDbcDbdDbeDbfDc0Dc1Dc2Dc3DcaDcbDccDcdDceDcfDd0Dd1Dd2Dd3DdbDdcDddDdeDdfDe0De1De2De3DebDecDedDeeDefDf0DfcDfdDfeDffCfffD05D06D07D08D09D25D26D27D28D29D35D36D37D38D39D3aD44D45D46D47D48D49D4aD4bD53D54D55D56D57D58D59D5aD5bD5cD61D62D63D64D65D66D67D68D69D6aD6bD6cD6dD81D82D83D84D85D86D87D88D89D8aD8bD8cD92D93D94D95D96D97D98D99D9aDa3Da4Da5Da6Da7Da8Da9Dc4Dc5Dc6Dc7Dc8Dc9Dd4Dd5Dd6Dd7Dd8Dd9DdaDe4De5De6De7De8De9DeaDf1Df2Df3Df4Df5Df6Df7Df8Df9DfaDfbC0ffD15D16D17D18D19D71D72D73D74D75D76D77D78D79D7aD7bD7cD7dDb3Db4Db5Db6Db7Db8Db9"{
run('URL...', 'url='+helpURL);
}

macro "Options Action Tool- C000T4b12o" {
Dialog.create("MRI Skin Tools Options");
Dialog.addNumber("minimum radius", minRadius);
Dialog.show();
minRadius = Dialog.getNumber();
}

macro "Measure Skin Properties Action Tool- C000T4b12m" {
run("Set Measurements...", " bounding display redirect=None decimal=3");
measureOneImage();
roiManager("Show All");
roiManager("Measure");
}

macro "Measure Skin Properties Batch Action Tool- C000T4b12b" {
showStatus("measure skin properties...");
run("Clear Results");
setForegroundColor(255, 255, 0);
run("Set Measurements...", " bounding display redirect=None decimal=3");
call("fr.cnrs.mri.macro.io.IOSettings.resetFileLists");
call("fr.cnrs.mri.macro.io.IOSettings.show");
waitForUser("Please select the input files using the IO_Settings dialog and press ok");
list = call("fr.cnrs.mri.macro.io.IOSettings.getFileList");
if (list=="none") {IJ.log("No files selected! Macro stopped."); return;}
files = split(list, ",");
for (i=0; i < files.length; i++) {
file = files[i];
open(file);
folder = File.getParent(file);
roiManager("reset");
measureOneImage();
run("Select None");
roiManager("Measure");
run("RGB Color");
roiManager("draw");
if (!File.exists(folder + "/" + "control/")) File.makeDirectory(folder+ "/" + "control/");
saveAs("jpeg", folder + "/" + "control/" + File.nameWithoutExtension + ".jpg");
close();
showProgress(i/(files.length-1));
}
filename = folder+"/Results.csv";
writeResultsTableToFile(filename);
roiManager("reset");
}

function measureOneImage() {
roiManager("reset");
run("Select None");
setThreshold(0,224);
run("Analyze Particles...", "size=500-Infinity circularity=0.00-1.00 show=Nothing add");
roiManager("Select", 0);
roiManager("Delete");
roiManager("Select", 0);
roiManager("Delete");
run("MRI Roi Converter");
roiManager("Add");
run("MRI Extrema", minRadius);
call("roi.RoiConverter.addVerticalLinesToRoiManager");
}

function writeResultsTableToFile(filename) {
if (File.exists(filename)) File.delete(filename);
f = File.open(filename);
print(f, "File\t" + "x\t" + "y\t" + "angle\t" + "length\n");
for (i=0; i<nResults; i++) {
label = getResultLabel(i);
BX = getResult("BX", i);
BY = getResult("BY", i);
Angle = getResult("Angle", i);
Length = getResult("Length", i);
if (Length!=0)
print(f, label + "\t" + BX + "\t" + BY + "\t" + Angle + "\t" + Length + "\n");
}
File.close(f);
}
(3-3/16)