Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ENH: Read image and ROI stacks in ImageJ
  • Loading branch information
pan14001 committed May 18, 2017
1 parent 1b20330 commit 877f6a9
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 55 deletions.
82 changes: 82 additions & 0 deletions src/imagej_open.ijm
@@ -0,0 +1,82 @@
// @UIService ui
// @File(label="Raw images directory", description="Images path", style="directory", value="/share/Pariksheet/consultations/rnai-screen-tf/results/z_projection") path
// @String(label="Plate name", choices={"160415_015529-V", "501B102", "502B98", "503B99", "507B99"}) plate
// @String(label="Well", value="C03") well
// @File(label="ROI nucleus images directory", description="Images path", style="directory", value="/share/Pariksheet/consultations/rnai-screen-tf/results/cellprofiler/nuc") path_nuc
// @File(label="ROI centromere images directory", description="Images path", style="directory", value="/share/Pariksheet/consultations/rnai-screen-tf/results/cellprofiler/cen") path_cen
// @File(label="ROI ectopic centromere images directory", description="Images path", style="directory", value="/share/Pariksheet/consultations/rnai-screen-tf/results/cellprofiler/ect") path_ect
// @File(label="ROI overlap images directory", description="Images path", style="directory", value="/share/Pariksheet/consultations/rnai-screen-tf/results/cellprofiler/ect_overlap") path_ect_overlap
// @OUTPUT Dataset image

/*
* Open multiple TIFF files as hyperstack and overlay ROIs.
*/

// Use batch mode for speed and protecting user settings.
setBatchMode(true);
// Clear all ROIs.
if (roiManager("count") > 0) {
roiManager("deselect")
roiManager("delete")
}

/** Open hyperstack of the well */
function imOpen(path, plate, well) {
run("Image Sequence...",
" open=" + path +
" file=" + plate + "_" + well +
" sort");
run("Stack to Hyperstack...",
" order=xyctz" +
" channels=3" +
" slices=1" +
" frames=" + nSlices / 3 +
" display=Composite")
Stack.setChannel(1);
run("Blue");
Stack.setChannel(2);
run("Red");
Stack.setChannel(3);
run("Green");
}
//imOpen(path, plate, well);

/** Import ROIs generated by CellProfiler */
function roiOpen(path, plate, well, color) {
run("Image Sequence...",
" open=" + path +
" file=" + plate + "_" + well +
" sort");
getMinAndMax(im_min, im_max);
im_list = getList("image.titles");
orig = im_list[lengthOf(im_list) - 1];
roi_min = roiManager("count");
// Iterate through all the images to add the ROIs to the ROI manager.
for (i = 1; i < 3; i++) {//im_max; i++) {
selectWindow(orig);
run("Duplicate...", "duplicate");
setThreshold(i, i);
run("Convert to Mask", "method=Default background=Dark");
run("Analyze Particles...", "add stack");
close();
}
roi_max = roiManager("count") - 1;
// If any new ROIs were added, set an appropriate color.
if (roi_max + 1 > roi_min) {
roi_ids = newArray();
for (i = roi_min; i <= roi_max; i++)
roi_ids = Array.concat(roi_ids, i);
roiManager("select", roi_ids);
roiManager("Set Color", color);
}
}

roiOpen(path_nuc, plate, well, "blue");
roiOpen(path_cen, plate, well, "green");
roiOpen(path_ect, plate, well, "red");

// Only show ROIS in current slice.
roiManager("Associate", "true");
roiManager("Show All");

setBatchMode(false);
55 changes: 0 additions & 55 deletions src/imagej_open.py

This file was deleted.

0 comments on commit 877f6a9

Please sign in to comment.