Posted by
Krs5 on
URL: http://imagej.273.s1.nabble.com/Selecting-grid-created-ROIs-based-on-an-Initially-Defined-ROI-tp5019936p5019944.html
Dear Patrick,
Using the image you provided I created the macro code below. I hope it does what you have in mind
---------------------------start------------------------------
title = getTitle();
makeRectangle(9, 38, 874, 779);
run("Crop");
run("Duplicate...", "title=test");
run("Split Channels");
selectWindow("test (green)");
run("Duplicate...", " ");
// Find yellow ROIs
setAutoThreshold("Default dark");
setThreshold(0, 246);
run("Convert to Mask");
run("Analyze Particles...", "size=150-1500 add");
// Find tissue ROI
selectWindow("test (green)");
setAutoThreshold("Default");
setThreshold(0, 18);
setOption("BlackBackground", false);
run("Convert to Mask");
run("Options...", "iterations=5 count=1 do=Nothing");
run("Dilate");
run("Close-");
run("Skeletonize");
run("Fill Holes");
run("Analyze Particles...", "size=500-Infinity");
// Check overlap of yellow ROI with tissue ROI
n = roiManager("count");
for (i=0;i<n;i++){
roiManager("select",n-i-1);
getRawStatistics(nPixels, mean, min, max, std, histogram);
if (max<255){
roiManager("delete");
min = min +1;
}
}
// overlap with original image
selectWindow(title);
roiManager("Show None");
roiManager("Show All");
-----------------------------------------end--------------------------------
Best wishes
Kees
Dr Ir K.R. Straatman
Senior Experimental Officer
Advanced Imaging Facility
Centre for Core Biotechnology Services
University of Leicester
www.le.ac.uk/advanced-imaging-facility
-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of Patrick Dooley
Sent: 23 January 2018 16:36
To:
[hidden email]
Subject: Selecting grid-created ROIs based on an Initially Defined ROI
This is my first post here, so forgive any poor formatting issues! I also posted this in the ImageJ forums, apologies if anyone is seeing this twice.
So the background information: I have a section of brain tissue that’s been scanned into a .vsi file format. Using the OlympusImageJPlugin I can open the overview of the image so I can define my initial-ROI, which currently is the entire slice of cortex. What the Olympus plugin nicely allows me to do is create a grid over my initial-ROI selection, then I can export each of those set width grid-ROIs into a tiff file in a folder for analyzation further down the line.
What I can’t quite figure out is how to only have Fiji save the grid-ROIs that overlap with my initially defined ROI, the entire cortex slice. I read this similar topic, which definitely gave me a few ideas, but none of them worked…
Right now the only idea I have is to create a macro that pulls the x,y coordinates from the grid-ROIs, checks to see if they’re within the initial ROI, and if not delete that ROI or if they are save that ROI; not sure which of those options would be better if I have to take this route.
Is there an easy way to do this I’m just completely missing? I am a complete newbie with Fiji and essentially with programming, but I am ready to learn(especially because the dataset I need to obtain is for a grant that’s due in 6 days…!)
<
http://imagej.1557.x6.nabble.com/file/t381893/fiji_ROI_issue.png>
Alright, so there’s my sample image! My initial-ROI is the red outline, the yellow outline is the subsequently created grid-ROIs.
What I want to try to do is only have Fiji save tiff files of the grid-ROIs that contain any portion of the initial-ROI.
Thanks in advance!
--
Sent from:
http://imagej.1557.x6.nabble.com/--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html