Hi,
I would like to measure pixel intensities along the border of particles (cell membranes). In my macro each particle has a corresponding ROI. That would be equivalent to being able to measure the intensity *on* (and not within the ROI line), and be able to specify the line width (e.g., 3-15 pixels). In principle this looks simple but I'm not sure what would be the best way to achieve it. The simplest (and very rough) way I thought of was to run every measure twice, one on the "dilated" particles and one on the "eroded" same particles. However, it's not optimal if I want to get measures for different widths simultaneously (e.g., 3,5,7,9,11,13 and 15 pixels "ribbon" width). Thanks for any advice you could give! Best, Emmanuel |
Hi Emmanuel,
You can transform your selection into a boundary of designated width using Edit > Selection > Make Band. Will that do the trick? -Curtis On Wed, Aug 3, 2011 at 9:24 AM, Emmanuel Levy <[hidden email]>wrote: > Hi, > > I would like to measure pixel intensities along the border of > particles (cell membranes). In my macro each particle has a > corresponding ROI. That would be equivalent to being able to measure > the intensity *on* (and not within the ROI line), and be able to > specify the line width (e.g., 3-15 pixels). > > In principle this looks simple but I'm not sure what would be the best > way to achieve it. The simplest (and very rough) way I thought of was > to run every measure twice, one on the "dilated" particles and one on > the "eroded" same particles. However, it's not optimal if I want to > get measures for different widths simultaneously (e.g., 3,5,7,9,11,13 > and 15 pixels "ribbon" width). > > Thanks for any advice you could give! > Best, > > Emmanuel > |
In reply to this post by Emmanuel Levy
Hi Emmanuel,
You can try the macro I wrote below: p=2; //1-n Call ROI from ROI manager l=5; //Line width for line profile roiManager("Select", p-1); //index starts at 0) //Extract points in ROI getSelectionCoordinates(xCoordinates, yCoordinates); makeSelection("polyline",xCoordinates, yCoordinates); run("Line Width...", "line=l"); run("Plot Profile"); Best Regards, John ________________________________________ From: ImageJ Interest Group [[hidden email]] On Behalf Of Emmanuel Levy [[hidden email]] Sent: Wednesday, August 03, 2011 10:24 PM To: [hidden email] Subject: Measure intensities *on* rather than within an ROI line, and be able to specify the "line" width. Hi, I would like to measure pixel intensities along the border of particles (cell membranes). In my macro each particle has a corresponding ROI. That would be equivalent to being able to measure the intensity *on* (and not within the ROI line), and be able to specify the line width (e.g., 3-15 pixels). In principle this looks simple but I'm not sure what would be the best way to achieve it. The simplest (and very rough) way I thought of was to run every measure twice, one on the "dilated" particles and one on the "eroded" same particles. However, it's not optimal if I want to get measures for different widths simultaneously (e.g., 3,5,7,9,11,13 and 15 pixels "ribbon" width). Thanks for any advice you could give! Best, Emmanuel |
Hi Lim and Curtis,
Thanks a lot for your suggestions again. I've been playing around with this problem with a while and the first version that worked fine was to simply use: run("Enlarge...", "enlarge=-5"); Directly on the ROI. The reason I'm using this is that both other solutions expand the ROI on the "outside" and I need to do it in the "inside". Thus I measure two areas and then make the difference between them to get the "band" information. The only problem is that calling this on all ROIs is really slow (I've got really a lot of them)!! I just saw the code of "shrink", which is part of the "enlarge" function: http://geosysin.iict.ch/irstv-trac/browser/imageJ/macros/EnlargeSelection.txt?rev=90 And applying the trick from this function: run("Distance Map"); setThreshold(5, 255); on my thresholded image seem to do the job very well. This means I'll just use two different images as "masks". One with the entire cells, and one where they are further thresholded based on the distance map. Emmanuel On 3 August 2011 23:24, Lim Soon Yew <[hidden email]> wrote: > Hi Emmanuel, > > You can try the macro I wrote below: > > p=2; //1-n Call ROI from ROI manager > l=5; //Line width for line profile > roiManager("Select", p-1); //index starts at 0) > //Extract points in ROI > getSelectionCoordinates(xCoordinates, yCoordinates); > makeSelection("polyline",xCoordinates, yCoordinates); > run("Line Width...", "line=l"); > run("Plot Profile"); > > Best Regards, > John > ________________________________________ > From: ImageJ Interest Group [[hidden email]] On Behalf Of Emmanuel Levy [[hidden email]] > Sent: Wednesday, August 03, 2011 10:24 PM > To: [hidden email] > Subject: Measure intensities *on* rather than within an ROI line, and be able to specify the "line" width. > > Hi, > > I would like to measure pixel intensities along the border of > particles (cell membranes). In my macro each particle has a > corresponding ROI. That would be equivalent to being able to measure > the intensity *on* (and not within the ROI line), and be able to > specify the line width (e.g., 3-15 pixels). > > In principle this looks simple but I'm not sure what would be the best > way to achieve it. The simplest (and very rough) way I thought of was > to run every measure twice, one on the "dilated" particles and one on > the "eroded" same particles. However, it's not optimal if I want to > get measures for different widths simultaneously (e.g., 3,5,7,9,11,13 > and 15 pixels "ribbon" width). > > Thanks for any advice you could give! > Best, > > Emmanuel |
Hi Emmanuel,
I had a similar problem and used the following macro to generate pericellular Rois from a set of oval rois (cell borders): n = roiManager("count"); for (i=0; i<n; i++) { roiManager("select", i); run("Fit Spline"); run("Make Band...", "band=1"); run("Enlarge...", "enlarge=7"); roiManager("Update"); } The macro transforms the border into a band and then enlarges it in and out by 3 px and then updates the Roi in the set. You can manipulate these values by changing the 7 to any odd integer. I hope this will help. Stoyan 2011/8/9 Emmanuel Levy <[hidden email]>: > Hi Lim and Curtis, > > Thanks a lot for your suggestions again. > > I've been playing around with this problem with a while and the first > version that worked fine was to simply use: > > run("Enlarge...", "enlarge=-5"); > > Directly on the ROI. The reason I'm using this is that both other > solutions expand the ROI on the "outside" and I need to do it in the > "inside". Thus I measure two areas and then make the difference > between them to get the "band" information. > > The only problem is that calling this on all ROIs is really slow (I've > got really a lot of them)!! > > I just saw the code of "shrink", which is part of the "enlarge" function: > http://geosysin.iict.ch/irstv-trac/browser/imageJ/macros/EnlargeSelection.txt?rev=90 > > And applying the trick from this function: > > run("Distance Map"); > setThreshold(5, 255); > > on my thresholded image seem to do the job very well. This means I'll > just use two different images as "masks". One with the entire cells, > and one where they are further thresholded based on the distance map. > > Emmanuel > > > > On 3 August 2011 23:24, Lim Soon Yew <[hidden email]> wrote: >> Hi Emmanuel, >> >> You can try the macro I wrote below: >> >> p=2; //1-n Call ROI from ROI manager >> l=5; //Line width for line profile >> roiManager("Select", p-1); //index starts at 0) >> //Extract points in ROI >> getSelectionCoordinates(xCoordinates, yCoordinates); >> makeSelection("polyline",xCoordinates, yCoordinates); >> run("Line Width...", "line=l"); >> run("Plot Profile"); >> >> Best Regards, >> John >> ________________________________________ >> From: ImageJ Interest Group [[hidden email]] On Behalf Of Emmanuel Levy [[hidden email]] >> Sent: Wednesday, August 03, 2011 10:24 PM >> To: [hidden email] >> Subject: Measure intensities *on* rather than within an ROI line, and be able to specify the "line" width. >> >> Hi, >> >> I would like to measure pixel intensities along the border of >> particles (cell membranes). In my macro each particle has a >> corresponding ROI. That would be equivalent to being able to measure >> the intensity *on* (and not within the ROI line), and be able to >> specify the line width (e.g., 3-15 pixels). >> >> In principle this looks simple but I'm not sure what would be the best >> way to achieve it. The simplest (and very rough) way I thought of was >> to run every measure twice, one on the "dilated" particles and one on >> the "eroded" same particles. However, it's not optimal if I want to >> get measures for different widths simultaneously (e.g., 3,5,7,9,11,13 >> and 15 pixels "ribbon" width). >> >> Thanks for any advice you could give! >> Best, >> >> Emmanuel > -- Dr. Stoyan P. Pavlov, MD Departament of Anatomy, Histology and Embryology Medical University "Prof. Dr. Paraskev Stoyanov", Varna Prof. Marin Drinov Str.55 9002 Varna Bulgaria Tel: +359 (0) 52 - 677 - 050 #2638 e-mail: [hidden email] |
In reply to this post by Emmanuel Levy
Hi Emmanuel,
Directly on the ROI. The reason I'm using this is that both other > solutions expand the ROI on the "outside" and I need to do it in the > "inside". Thus I measure two areas and then make the difference > between them to get the "band" information. > For interior bands, you can use the ROI Manager's XOR function. Here is a small macro: run("Add to Manager"); run("Enlarge...", "enlarge=-3"); run("Add to Manager"); roiManager("XOR"); roiManager("Deselect"); roiManager("Delete"); -Curtis On Tue, Aug 9, 2011 at 1:27 AM, Emmanuel Levy <[hidden email]>wrote: > Hi Lim and Curtis, > > Thanks a lot for your suggestions again. > > I've been playing around with this problem with a while and the first > version that worked fine was to simply use: > > run("Enlarge...", "enlarge=-5"); > > Directly on the ROI. The reason I'm using this is that both other > solutions expand the ROI on the "outside" and I need to do it in the > "inside". Thus I measure two areas and then make the difference > between them to get the "band" information. > > The only problem is that calling this on all ROIs is really slow (I've > got really a lot of them)!! > > I just saw the code of "shrink", which is part of the "enlarge" function: > > http://geosysin.iict.ch/irstv-trac/browser/imageJ/macros/EnlargeSelection.txt?rev=90 > > And applying the trick from this function: > > run("Distance Map"); > setThreshold(5, 255); > > on my thresholded image seem to do the job very well. This means I'll > just use two different images as "masks". One with the entire cells, > and one where they are further thresholded based on the distance map. > > Emmanuel > > > > On 3 August 2011 23:24, Lim Soon Yew <[hidden email]> > wrote: > > Hi Emmanuel, > > > > You can try the macro I wrote below: > > > > p=2; //1-n Call ROI from ROI manager > > l=5; //Line width for line profile > > roiManager("Select", p-1); //index starts at 0) > > //Extract points in ROI > > getSelectionCoordinates(xCoordinates, yCoordinates); > > makeSelection("polyline",xCoordinates, yCoordinates); > > run("Line Width...", "line=l"); > > run("Plot Profile"); > > > > Best Regards, > > John > > ________________________________________ > > From: ImageJ Interest Group [[hidden email]] On Behalf Of Emmanuel > Levy [[hidden email]] > > Sent: Wednesday, August 03, 2011 10:24 PM > > To: [hidden email] > > Subject: Measure intensities *on* rather than within an ROI line, and be > able to specify the "line" width. > > > > Hi, > > > > I would like to measure pixel intensities along the border of > > particles (cell membranes). In my macro each particle has a > > corresponding ROI. That would be equivalent to being able to measure > > the intensity *on* (and not within the ROI line), and be able to > > specify the line width (e.g., 3-15 pixels). > > > > In principle this looks simple but I'm not sure what would be the best > > way to achieve it. The simplest (and very rough) way I thought of was > > to run every measure twice, one on the "dilated" particles and one on > > the "eroded" same particles. However, it's not optimal if I want to > > get measures for different widths simultaneously (e.g., 3,5,7,9,11,13 > > and 15 pixels "ribbon" width). > > > > Thanks for any advice you could give! > > Best, > > > > Emmanuel > |
Hello Stoyan and Curtis,
Thanks for the suggestion. If you (or anyone else) needs to do something similar, I recommend using the method described above (with the distance map + thresholding), so that the "inner" limit of each ROI is defined in all ROIs at once. This is a lot faster than using the "enlarge" function on each ROI individually. e.g., my code is now speeded up by a factor of ~5 (it took ~24h to process one batch of images, so I'm happy it's now only ~6h!). Best, Emmanuel On 9 August 2011 10:19, Curtis Rueden <[hidden email]> wrote: > Hi Emmanuel, > >> Directly on the ROI. The reason I'm using this is that both other >> solutions expand the ROI on the "outside" and I need to do it in the >> "inside". Thus I measure two areas and then make the difference >> between them to get the "band" information. > > For interior bands, you can use the ROI Manager's XOR function. Here is a > small macro: > > run("Add to Manager"); > run("Enlarge...", "enlarge=-3"); > run("Add to Manager"); > roiManager("XOR"); > roiManager("Deselect"); > roiManager("Delete"); > > -Curtis > > On Tue, Aug 9, 2011 at 1:27 AM, Emmanuel Levy <[hidden email]> > wrote: >> >> Hi Lim and Curtis, >> >> Thanks a lot for your suggestions again. >> >> I've been playing around with this problem with a while and the first >> version that worked fine was to simply use: >> >> run("Enlarge...", "enlarge=-5"); >> >> Directly on the ROI. The reason I'm using this is that both other >> solutions expand the ROI on the "outside" and I need to do it in the >> "inside". Thus I measure two areas and then make the difference >> between them to get the "band" information. >> >> The only problem is that calling this on all ROIs is really slow (I've >> got really a lot of them)!! >> >> I just saw the code of "shrink", which is part of the "enlarge" function: >> >> http://geosysin.iict.ch/irstv-trac/browser/imageJ/macros/EnlargeSelection.txt?rev=90 >> >> And applying the trick from this function: >> >> run("Distance Map"); >> setThreshold(5, 255); >> >> on my thresholded image seem to do the job very well. This means I'll >> just use two different images as "masks". One with the entire cells, >> and one where they are further thresholded based on the distance map. >> >> Emmanuel >> >> >> >> On 3 August 2011 23:24, Lim Soon Yew <[hidden email]> >> wrote: >> > Hi Emmanuel, >> > >> > You can try the macro I wrote below: >> > >> > p=2; //1-n Call ROI from ROI manager >> > l=5; //Line width for line profile >> > roiManager("Select", p-1); //index starts at 0) >> > //Extract points in ROI >> > getSelectionCoordinates(xCoordinates, yCoordinates); >> > makeSelection("polyline",xCoordinates, yCoordinates); >> > run("Line Width...", "line=l"); >> > run("Plot Profile"); >> > >> > Best Regards, >> > John >> > ________________________________________ >> > From: ImageJ Interest Group [[hidden email]] On Behalf Of Emmanuel >> > Levy [[hidden email]] >> > Sent: Wednesday, August 03, 2011 10:24 PM >> > To: [hidden email] >> > Subject: Measure intensities *on* rather than within an ROI line, and be >> > able to specify the "line" width. >> > >> > Hi, >> > >> > I would like to measure pixel intensities along the border of >> > particles (cell membranes). In my macro each particle has a >> > corresponding ROI. That would be equivalent to being able to measure >> > the intensity *on* (and not within the ROI line), and be able to >> > specify the line width (e.g., 3-15 pixels). >> > >> > In principle this looks simple but I'm not sure what would be the best >> > way to achieve it. The simplest (and very rough) way I thought of was >> > to run every measure twice, one on the "dilated" particles and one on >> > the "eroded" same particles. However, it's not optimal if I want to >> > get measures for different widths simultaneously (e.g., 3,5,7,9,11,13 >> > and 15 pixels "ribbon" width). >> > >> > Thanks for any advice you could give! >> > Best, >> > >> > Emmanuel > > |
Free forum by Nabble | Edit this page |