ImageJ: неправильный перенос координат с картинки на картинку - PullRequest
0 голосов
/ 17 марта 2020

для моей диссертации я должен считать клетки на фотографиях, окрашенных с помощью иммунофлуоресценции, и я пишу макрос в ImageJ, чтобы сделать это для меня. Для этого я делю цветное изображение, анализирую частицы в красном канале (цвет моего антитела), а затем хочу взять координаты анализируемых частиц и считать их только в том случае, если в тех же координатах в синем канале также есть окрашивание ( DAPI - просто общее окрашивание клеток). Таким образом, я заверяю, что грязи считается как можно меньше. Проблема в том, что когда я получаю координаты из таблицы результатов и использую их для создания точки (x, y), координаты «искажены» - обычно правильные координаты, но плюс 4i sh, хотя никогда не совпадают точно, что почему я не могу просто отвлечь число от координат. Ниже я сначала записываю критические строки кода, а затем весь код.

Заранее большое спасибо

run("Analyze Particles...", "  circularity=r1-r2 display clear in_situ");
                roiManager("deselect");
                z=nResults;

                for (j=0; j<z; j++) {   //loops through the Results table and adds to "counter" if a match is found
                    selectImage(channelsplit[2]);   //selects blue window
                    setThreshold(d,l);
                    run("Threshold...");
                    setOption("BlackBackground", true);
                    run("Convert to Mask", "method=Default background=Default black");
                    run("Coordinates...", "left=0 right=19373 top=0 bottom=13600"); //I tried to set the boundaries of the pictures equally, but it didnt work
                    makePoint(getResult("X", j)), (getResult("Y", j));
                    print ("X" + j + ": " + getResult("X",j));  //this and the following line are not to be in the program, once it works
                    print ("Y" + j + ": " + getResult("Y",j));
                    run ("Measure");
                    if (getResult("Mean", nResults-1)>100) {
                        counter++;
                    }
                } //for j
                print (i + ": " + counter);
setBatchMode(true);
if (isOpen("ROI Manager")) {
    r=roiManager("count");
} else {
    setBatchMode(false);
    exit("You need a ROI Manager open with the ROIs of all the pictures to be measured");
}

Dialog.create ("Variables")

Dialog.addCheckbox ("red", true);
Dialog.addCheckbox ("green", false);
Dialog.addCheckbox ("blue", false);
Dialog.addCheckbox ("watershed", true);

Dialog.addNumber ("Thresholddark:", 110);
Dialog.addNumber ("Thresholdlight:", 255);
Dialog.addNumber ("greenThresholddark:", 110);
Dialog.addNumber ("greenThresholdlight:", 253);
Dialog.addNumber ("pmin:", 15);
Dialog.addNumber ("pmax:", 100);
Dialog.addNumber ("roundness1:", 0.5);
Dialog.addNumber ("roundness2:", 1.0);

Dialog.addMessage("batch - select 'true' for your macro to run faster, but you will not see what it does until finished\nstack - selecht this box if you use unstacked pictures and want them stacked, deselect if you use a readied stack or a single picture\nred - select this box if you want to count red coloured cells \ngreen - select this box if you want to count green coloured cells \nblue - select this box if you want to count blue coloured cells\nall variables are the same for the colours you count. It may be better to adjust variables for each colour and count seperately\nwatershed - select this box only if you have overlapping cells in your image\nThresholdlight - particles lighter than this won't be measured/counted \nThresholddark - particles darker than this won't be measured/counted \nThresholdlight and Thresholddark can be between 0 and 255 \ntry thresholding manually at least once manually to get best results \npmin -  particles with a size smaller than this won't be counted \npmax - particles with a size greater than this won't be counted")
Dialog.show ();

cr=Dialog.getCheckbox();
cg=Dialog.getCheckbox();
cb=Dialog.getCheckbox();
w=Dialog.getCheckbox();

d=Dialog.getNumber();
l=Dialog.getNumber();
dg=Dialog.getNumber();
lg=Dialog.getNumber();
pmin=Dialog.getNumber();
pmax=Dialog.getNumber();
r1=Dialog.getNumber();
r2=Dialog.getNumber();

dir = getDirectory("Choose a Directory ");  //choose the folder with all the pictures to be measured
listFiles(dir);                 //I found this in a listFiles recursively Demo and changed it to open my pictures

function listFiles(dir) {
    list = getFileList(dir);
    for (o=0; o<list.length; o++) {     //loops through the file list, opening then analysing then closing one after another
        if (endsWith(list[o], "/")) {
            listFiles(""+dir+list[i]);
        } else {
            open(dir + list[o]);
//the previous opens all pictures in a given folder in a way i do not understand
//I only use this function because I could not use the variable list.length outside of it for unknown reasons
//following is my cellcount program to be executed for each picture
//then the picture will be closed before the new one is opened
            run("Split Channels");
            channelsplit = getList("image.titles");
            if (cr==1) {
            a=0;
            }
            if (cg==1) {
            a=1;
            }

            selectImage(channelsplit[a]);   //selects red or green window, depending on input in the Dialog
            setThreshold(d,l);
            run("Threshold...");
            setOption("BlackBackground", true);
            run("Convert to Mask", "method=Default background=Default black");
            run("Coordinates...", "left=0 right=19373 top=0 bottom=13600");

            for (i=2*o; i<=((2*o)+1); i++) {    //loops through two ROIs of the ROIManager
                counter=0;
                selectImage(channelsplit[a]);
                roiManager("deselect");
                roiManager("select", i);
                if (w==1) {
                    run("Watershed", "slice");
                }   
                run("Analyze Particles...", "  circularity=r1-r2 display clear in_situ");
                roiManager("deselect");
                z=nResults;

                for (j=0; j<z; j++) {   //loops through the Results table and adds to "counter" if a match is found
                    selectImage(channelsplit[2]);   //selects blue window
                    setThreshold(d,l);
                    run("Threshold...");
                    setOption("BlackBackground", true);
                    run("Convert to Mask", "method=Default background=Default black");
                    run("Coordinates...", "left=0 right=19373 top=0 bottom=13600"); //I tried to set the boundaries of the pictures equally, but it didnt work
                    makePoint(getResult("X", j)), (getResult("Y", j));
                    print ("X" + j + ": " + getResult("X",j));  //this and the following line are not to be in the program, once it works
                    print ("Y" + j + ": " + getResult("Y",j));
                    run ("Measure");
                    if (getResult("Mean", nResults-1)>100) {
                        counter++;
                    }
                } //for j
                print (i + ": " + counter);
                close("Results");   //closes Results to get the variables in order for the next window
//              IJ.renameResults("res" + i);
            } //for i
            close("*");     //closes all image windows to save RAM
        } //else
    } //for o
} //function
setBatchMode(false);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...