I am measuring the width and height of ROI in two-wave XY graphs. What I do is just copy & paste the min_values and max_values for both axis-ranges after expending the ROI. It is really painful to simply repeat thousands times. I am wondering whether anyone could kindly provide a procedure so that the four axis-range values of ROI can be exported into the same row of a table which can be calculated easily.
Any help is appreciated.
I think what you want to do can be done using the GetMarquee operation. Unfortunately, this operation works best on 1D graphs. I've done a quick hack to adapt it for 2D images. Paste the following in your procedure window, select an area with the mouse on your 2D image (the "marquee"), then right-click and choose "Print Image ROI".
Menu"GraphMarquee""Print Image ROI"EndFunction PrintImageROI()// 1. get the marquee in point units (axis units directly accessible only for 1D graphs!)// sanity test: let there be exactly one imageString TopGraphImages = ImageNameList("",";")if(ItemsInList(TopGraphImages)!= 1)Print"There is either no image or more than one on the graph"return -1endifGetMarquee// sanity test: was there a marquee at all?if(V_flag == 0)Print"There is no marquee"return -1endifVariable mpL = V_left, mpR = V_right, mpT = V_top, mpB = V_bottom
// print "marquee in points (left, top, right, bottom) =", mpL, mpT, mpR, mpB// 2. get the plot area in point unitsGetWindow kwTopWin, psize
Variable ppL = V_left, ppR = V_right, ppT = V_top, ppB = V_bottom
// print "plot area in points (left, top, right, bottom) =", ppL, ppT, ppR, ppB// 3. get the axis limits// get limits of axes that image is displayed againstString theImage = StringFromList(0, TopGraphImages)String XAxis = StringByKey("XAXIS", ImageInfo("", theImage, 0))String YAxis = StringByKey("YAXIS", ImageInfo("", theImage, 0))String XAxisLimits = StringFromList(2, StringByKey("SETAXISCMD", axisinfo("", XAxis)), " ")String YAxisLimits = StringFromList(2, StringByKey("SETAXISCMD", axisinfo("", YAxis)), " ")// order left/right correctly, remember whether a swap occurredVariable axMin = str2num(StringFromList(0, XAxisLimits, ",")), axMax = str2num(StringFromList(1, XAxisLimits, ",")), swap
Variable paL = min(axMin, axMax), paR = max(axMin, axMax), xSwap = (paL != axMin)// order top/bottom correctly, remember whether a swap occurred
axMin = str2num(StringFromList(0, YAxisLimits, ",")); axMax = str2num(StringFromList(1, YAxisLimits, ","))Variable paT = max(axMin, axMax), paB = min(axMin, axMax), ySwap = (paB != axMin)// print "plot area in axis units (left, top, right, bottom) =", paL, paT, paR, paB; print xSwap, ySwap// 4. express the marquee coordinates in axis unitsVariable maL = paL + (mpL - ppL)*(paR - paL)/(ppR - ppL), maR = paL + (mpR - ppL)*(paR - paL)/(ppR - ppL), swap
if( xSwap )
swap = maL; maL = maR; maR = swap
endifVariable maT = paT + (mpT - ppT)*(paB - paT)/(ppB - ppT), maB = paT + (mpB - ppT)*(paB - paT)/(ppB - ppT)if( ySwap )
swap = maT; maT = maB; maB = swap
endifprint"marquee in axis units (left, top, right, bottom) =", maL, maT, maR, maB
End
Is that what you wanted?
Oh, on rereading this, I see you are doing 1D (XY) graphs. I was confused by your use of the word "ROI" which for me is associated with 2D graphs. Igor calls this a "Marquee" instead of a "ROI". You can probably use the example code in the help topic for GetMarquee directly. Just type DisplayHelpTopic"GetMarquee" on the command line...
My code snippet above is overly complicated and does not work with auto-scaled image axes. Actually, GetMarquee() works perfectly fine for images, as was pointed out to me by Nasser. Only, the sample code for GetMarquee() needs to be slightly adapted since usually, images are displayed vs. the top axis rather than the bottom axis. An axis-insensitive version for images would then be:
Menu"GraphMarquee""Print Marquee Coordinates", PrintMarqueeCoords()EndFunction PrintMarqueeCoords()GetMarqueeif(V_flag == 0)Print"There is no marquee"else// the following three lines are valid for images onlyString topImageInfo = ImageInfo("", StringFromList(0, ImageNameList("",";")), 0)String xAxisName = StringByKey("XAXIS", topImageInfo)String yAxisName = StringByKey("YAXIS", topImageInfo)// alternatively, if you know the axes are top and left, use // xAxisName = "top"; yAxisName="left"// or use the following form, which selects the axes corresponding to chronologically first object displayed on the top graph// yAxisName = StringFromList(0, AxisList(""))// xAxisName = StringFromList(1, AxisList(""))GetMarquee$xAxisName, $yAxisNameprintf"marquee left in %s axis terms: %g\r", xAxisName, V_left
printf"marquee right in %s axis terms: %g\r", xAxisName, V_right
printf"marquee top in %s axis terms: %g\r", yAxisName, V_top
printf"marquee bottom in %s axis terms: %g\r", yAxisName, V_bottom
endifEnd
GetMarquee
operation. Unfortunately, this operation works best on 1D graphs. I've done a quick hack to adapt it for 2D images. Paste the following in your procedure window, select an area with the mouse on your 2D image (the "marquee"), then right-click and choose "Print Image ROI".Is that what you wanted?
Oh, on rereading this, I see you are doing 1D (XY) graphs. I was confused by your use of the word "ROI" which for me is associated with 2D graphs. Igor calls this a "Marquee" instead of a "ROI". You can probably use the example code in the help topic for
GetMarquee
directly. Just typeDisplayHelpTopic "GetMarquee"
on the command line...-Wolfgang
October 11, 2009 at 01:59 pm - Permalink
October 18, 2009 at 08:15 pm - Permalink
GetMarquee()
works perfectly fine for images, as was pointed out to me by Nasser. Only, the sample code forGetMarquee()
needs to be slightly adapted since usually, images are displayed vs. the top axis rather than the bottom axis. An axis-insensitive version for images would then be:Wolfgang
January 14, 2011 at 03:20 am - Permalink