MRI_Skin_Tools.txt

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

Download (4 KB)

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

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

    
16
macro "Unused Tool - C037" { }
17

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

    
22
macro "Options Action Tool- C000T4b12o" {
23
    Dialog.create("MRI Skin Tools Options");
24
    Dialog.addNumber("minimum radius", minRadius);
25
    Dialog.show();
26
    minRadius = Dialog.getNumber();
27
}
28

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

    
36
macro "Measure Skin Properties Batch Action Tool- C000T4b12b" {
37
     showStatus("measure skin properties...");
38
     run("Clear Results");
39
     setForegroundColor(255, 255, 0);
40
     run("Set Measurements...", "  bounding display redirect=None decimal=3");
41
    call("fr.cnrs.mri.macro.io.IOSettings.resetFileLists");
42
    call("fr.cnrs.mri.macro.io.IOSettings.show");
43
    waitForUser("Please select the input files using the IO_Settings dialog and press ok");
44
    list = call("fr.cnrs.mri.macro.io.IOSettings.getFileList");
45
    if (list=="none") {IJ.log("No files selected! Macro stopped."); return;}
46
    files = split(list, ",");
47
    for (i=0; i < files.length; i++) {
48
        file = files[i];
49
        open(file);
50
        folder = File.getParent(file);
51
        roiManager("reset");
52
        measureOneImage();
53
        run("Select None");
54
        roiManager("Measure");
55
        run("RGB Color");
56
        roiManager("draw");
57
        if (!File.exists(folder + "/" + "control/")) File.makeDirectory(folder+ "/" + "control/");
58
        saveAs("jpeg", folder + "/" + "control/" + File.nameWithoutExtension + ".jpg");
59
        close();
60
        showProgress(i/(files.length-1));
61
   }
62
   filename = folder+"/Results.csv";
63
   writeResultsTableToFile(filename);
64
    roiManager("reset");
65
}
66

    
67
function measureOneImage() {
68
    roiManager("reset");
69
    run("Select None");
70
    setThreshold(0,224);
71
    run("Analyze Particles...", "size=500-Infinity circularity=0.00-1.00 show=Nothing add");
72
    roiManager("Select", 0);
73
    roiManager("Delete");
74
    roiManager("Select", 0);
75
    roiManager("Delete");
76
    run("MRI Roi Converter");
77
    roiManager("Add");
78
    run("MRI Extrema", minRadius);
79
    call("roi.RoiConverter.addVerticalLinesToRoiManager");
80
}
81

    
82
function writeResultsTableToFile(filename) {
83
    if (File.exists(filename)) File.delete(filename);
84
    f = File.open(filename);
85
    print(f, "File\t" + "x\t" + "y\t" + "angle\t" + "length\n");	
86
    for (i=0; i<nResults; i++) {
87
        label = getResultLabel(i);
88
        BX = getResult("BX", i);
89
        BY = getResult("BY", i);
90
        Angle = getResult("Angle", i);
91
        Length = getResult("Length", i);
92
       if (Length!=0)
93
            print(f, label + "\t" + BX + "\t" + BY + "\t" + Angle + "\t" + Length + "\n");	
94
    }
95
    File.close(f);
96
}