1 #pragma rtGlobals=3// Use modern global access method and strict wave access. 2 #pragma IgorVersion = 6.2 3 #pragma ModuleName = PearlAreaDisplay 62 name = GetDataFolder(1, df)
63 name = ReplaceString(
"root:", name,
"")
64 name = name[0, strlen(name) - 2]
65 name = ReplaceString(
" ", name,
"")
66 name = CleanupName(prefix + name, 0)
67 if (CheckName(name, 6))
68 name = UniqueName(name, 6, 0)
88 dfref savedf = GetDataFolderDFR()
89 dfref imagedf = GetWavesDataFolderDFR(image)
92 string dfname = ReplaceString(
"root:", GetDataFolder(1, imagedf),
"")
93 string graphtitle = dfname +
" View" 95 svar graphname = view_graphname
96 display /k=1/n=$graphname as graphtitle
98 appendimage /w=$graphname image
117 dfref savedf = GetDataFolderDFR()
118 dfref imagedf = GetWavesDataFolderDFR(image)
119 string s_imagedf = GetDataFolder(1, imagedf)
120 setdatafolder imagedf
124 string dfname = ReplaceString(
"root:", GetDataFolder(1, imagedf),
"")
125 string graphtitle = dfname +
" Histogram" 127 svar graphname = hist_graphname
128 display /k=1/n=$graphname as graphtitle
130 appendtograph /w=$graphname hist
132 ModifyGraph /w=$graphname rgb(hist)=(39168,0,0)
133 ModifyGraph /w=$graphname mode=6
134 ModifyGraph /w=$graphname mirror=1
135 ModifyGraph /w=$graphname minor=1
136 ModifyGraph /w=$graphname axThick=0.5
137 ModifyGraph /w=$graphname lblPosMode=1,lblPos=30,lblMargin=0
138 ModifyGraph /w=$graphname btLen=4
139 ModifyGraph /w=$graphname margin(left)=45,margin(bottom)=35,margin(top)=10,margin(right)=10
140 ModifyGraph /w=$graphname gfSize=10
141 Label /w=$graphname bottom
"value" 142 Label /w=$graphname left
"# pixels" 168 variable show_legend = 0
170 if (WaveDims(image) != 2)
171 abort
"ad_display_profiles: image wave must be two-dimensional." 173 if (ParamIsDefault(filter))
174 filter =
"ad_box_filter" 178 dfref savedf = GetDataFolderDFR()
179 dfref imagedf = GetWavesDataFolderDFR(image)
180 string s_imagedf = GetDataFolder(1, imagedf)
181 setdatafolder imagedf
182 string s_viewdf = CleanupName(
"view_" + NameOfWave(image), 0)
183 newdatafolder /o/s $s_viewdf
184 dfref viewdf = GetDataFolderDFR()
185 s_viewdf = GetDataFolder(1, viewdf)
188 string /g sourcepath = GetWavesDataFolder(image, 2)
189 string viewname =
"view_image" 190 duplicate /o image, $viewname /wave=view
191 make /n=(3,3)/o xprofiles
192 make /n=(3,3)/o yprofiles
193 string /g view_filter
194 string /g view_filter_options
196 view_filter_options =
"" 197 variable /g view_filter_smoothing_x = 1
198 variable /g view_filter_smoothing_y = 1
199 variable /g view_cursor_mode = 0
200 string dfname = ReplaceString(
"root:", GetDataFolder(1, imagedf),
"")
201 string graphtitle = dfname + NameOfWave(image) +
" Profiles" 203 svar graphname = prof_graphname
204 variable /g graph_avg
205 variable /g graph_min
206 variable /g graph_max
207 variable /g graph_sum
208 variable /g graph_sdev
211 display /k=1 /n=$graphname /w=(100,100,500,400) as graphtitle
213 AppendToGraph /w=$graphname /L=xprofiles xprofiles[*][0],xprofiles[*][1],xprofiles[*][2]
214 AppendToGraph /w=$graphname /VERT/B=yprofiles yprofiles[*][0],yprofiles[*][1],yprofiles[*][2]
215 AppendImage /w=$graphname view
216 string imgname = StringFromList(0, ImageNameList(graphname,
";"))
217 ModifyImage /w=$graphname $imgname ctab= {*,*,BlueGreenOrange,0}
218 ModifyGraph /w=$graphname rgb(xprofiles)=(39168,0,0),rgb(yprofiles)=(39168,0,0)
219 ModifyGraph /w=$graphname rgb(xprofiles#1)=(0,26112,0),rgb(yprofiles#1)=(0,26112,0)
220 ModifyGraph /w=$graphname rgb(xprofiles#2)=(0,9472,39168),rgb(yprofiles#2)=(0,9472,39168)
221 ModifyGraph /w=$graphname mirror(xprofiles)=2,mirror(bottom)=3,mirror(yprofiles)=2,mirror(left)=3
222 ModifyGraph /w=$graphname nticks=3
223 ModifyGraph /w=$graphname minor=1
224 ModifyGraph /w=$graphname axThick=0.5
225 ModifyGraph /w=$graphname lblPosMode=1,lblPos=30,lblMargin=0
226 ModifyGraph /w=$graphname btLen=4
227 ModifyGraph /w=$graphname freePos(xprofiles)=0
228 ModifyGraph /w=$graphname freePos(yprofiles)=0
229 ModifyGraph /w=$graphname axisEnab(xprofiles)={0.64,1}
230 ModifyGraph /w=$graphname axisEnab(bottom)={0,0.6}
231 ModifyGraph /w=$graphname axisEnab(yprofiles)={0.64,1}
232 ModifyGraph /w=$graphname axisEnab(left)={0,0.6}
233 ModifyGraph /w=$graphname zero(left)=8
234 ModifyGraph /w=$graphname margin(left)=40,margin(bottom)=30,margin(top)=20,margin(right)=40
235 ModifyGraph /w=$graphname gfSize=10
238 string labels = note(image)
240 lab = StringByKey(
"AxisLabelX", labels,
"=",
"\r")
244 Label /w=$graphname bottom lab +
" (\\U)" 245 lab = StringByKey(
"AxisLabelY", labels,
"=",
"\r")
249 Label /w=$graphname left lab +
" (\\U)" 250 lab = StringByKey(
"AxisLabelD", labels,
"=",
"\r")
254 Label /w=$graphname xprofiles lab +
" (\\U)" 255 Label /w=$graphname yprofiles lab +
" (\\U)" 259 Legend /w=$graphname/C/N=text0/J/F=2/D=0.5/T={28}/A=RT/X=0.00/Y=0.00
"\\s(xprofiles)\tprofile A" 260 AppendText /w=$graphname
"\\s(xprofiles#1)\tprofile B" 261 AppendText /w=$graphname
"\\s(xprofiles#2)\tROI average" 262 AppendText /w=$graphname
"min\t\\{" + s_viewdf +
"graph_min}" 263 AppendText /w=$graphname
"max\t\\{" + s_viewdf +
"graph_max}" 264 AppendText /w=$graphname
"sum\t\\{" + s_viewdf +
"graph_sum}" 265 AppendText /w=$graphname
"avg\t\\{" + s_viewdf +
"graph_avg}" 266 AppendText /w=$graphname
"sdev\t\\{" + s_viewdf +
"graph_sdev}" 268 TextBox /w=$graphname /C/N=text0 /F=0 /B=1 /X=1.00 /Y=1.00
269 lab = StringByKey(
"Dataset", labels,
"=",
"\r")
271 AppendText /w=$graphname lab
273 AppendText /w=$graphname
"sum\t\\{" + s_viewdf +
"graph_sum}" 274 AppendText /w=$graphname
"avg\t\\{" + s_viewdf +
"graph_avg}" 275 AppendText /w=$graphname
"sdev\t\\{" + s_viewdf +
"graph_sdev}" 279 Cursor /w=$graphname /A=1 /P /I /S=2 /H=1 /L=1 A $imgname 0,0
280 Cursor /w=$graphname /A=1 /P /I /S=2 /H=1 /L=1 B $imgname DimSize(view, 0)-1, DimSize(view, 1)-1
282 pcurs = floor(DimSize(xprofiles, 0) / 3)
283 Cursor /w=$graphname /A=0 /P /S=1 /H=0 C xprofiles#2 pcurs
284 pcurs = floor(DimSize(xprofiles, 0) * 2 / 3)
285 Cursor /w=$graphname /A=0 /P /S=1 /H=0 D xprofiles#2 pcurs
286 pcurs = floor(DimSize(yprofiles, 0) / 3)
287 Cursor /w=$graphname /A=0 /P /S=1 /H=0 E yprofiles#2 pcurs
288 pcurs = floor(DimSize(yprofiles, 0) * 2 / 3)
289 Cursor /w=$graphname /A=0 /P /S=1 /H=0 F yprofiles#2 pcurs
290 ShowInfo /w=$graphname /CP=0
293 ControlBar /w=$graphname 21
295 Button b_reset_cursors win=$graphname, fColor=(65535,65535,65535),fSize=10
297 SetVariable sv_smoothing_x win=$graphname, title=
"X smoothing",pos={130,2},bodyWidth=40
298 SetVariable sv_smoothing_x win=$graphname, value=view_filter_smoothing_x,limits={1,100,1}
300 SetVariable sv_smooting_y win=$graphname, title=
"Y smoothing",pos={240,2},bodyWidth=40
301 SetVariable sv_smooting_y win=$graphname, value=view_filter_smoothing_y,limits={1,100,1}
304 PopupMenu pm_export win=$graphname, mode=0,title=
"Export" 305 PopupMenu pm_export win=$graphname, value=
"X profile;Y profile;X profile (collate);Y profile (collate)" 307 PopupMenu pm_export win=$graphname, help={
"Export profile of selected area and display in graph. Collate mode = display all profiles in same graph."}
326 if (DataFolderRefStatus(viewdf) == 0)
329 dfref savedf = GetDataFolderDFR()
333 string viewname =
"view_image" 334 duplicate /o image, $viewname /wave=view
338 svar view_filter_options
339 nvar smoothing_x = view_filter_smoothing_x
340 nvar smoothing_y = view_filter_smoothing_y
342 view_filter_options = ReplaceNumberByKey(
"SmoothingX", view_filter_options, smoothing_x,
"=",
";")
343 view_filter_options = ReplaceNumberByKey(
"SmoothingY", view_filter_options, smoothing_y,
"=",
";")
344 filterfunc(view, view_filter_options)
372 dfref savedf = GetDataFolderDFR()
374 dfref viewdf = GetWavesDataFolderDFR(view_image)
375 svar /sdfr=viewdf graphname = prof_graphname
376 nvar /sdfr=viewdf cursor_mode = view_cursor_mode
377 wave /sdfr=viewdf xprofiles, yprofiles
379 variable dx = DimSize(view_image, 0)
380 variable dy = DimSize(view_image, 1)
383 Cursor /w=$graphname /A=0 /P /I /S=2 /H=1 /L=1 A view_image 0, 0
384 Cursor /w=$graphname /A=0 /P /I /S=2 /H=1 /L=1 B view_image dx-1, dy-1
385 Cursor /w=$graphname /A=0 /P /I /S=2 /H=2 /L=1 C view_image round(0.2 * dx) -1, 0
386 Cursor /w=$graphname /A=0 /P /I /S=2 /H=2 /L=1 D view_image round(0.8 * dx) -1, 0
387 Cursor /w=$graphname /A=0 /P /I /S=2 /H=2 /L=1 E view_image round(0.4 * dx) -1, 0
388 Cursor /w=$graphname /A=0 /P /I /S=2 /H=2 /L=1 F view_image round(0.6 * dx) -1, 0
390 ShowInfo /w=$graphname /CP=0
394 Cursor /w=$graphname /A=1 /P /I /S=2 /H=1 /L=1 A view_image 0,0
395 Cursor /w=$graphname /A=1 /P /I /S=2 /H=1 /L=1 B view_image dx-1, dy-1
397 pcurs = floor(DimSize(xprofiles, 0) / 3)
398 Cursor /w=$graphname /A=0 /P /S=1 /H=0 C xprofiles#2 pcurs
399 pcurs = floor(DimSize(xprofiles, 0) * 2 / 3)
400 Cursor /w=$graphname /A=0 /P /S=1 /H=0 D xprofiles#2 pcurs
401 pcurs = floor(DimSize(yprofiles, 0) / 3)
402 Cursor /w=$graphname /A=0 /P /S=1 /H=0 E yprofiles#2 pcurs
403 pcurs = floor(DimSize(yprofiles, 0) * 2 / 3)
404 Cursor /w=$graphname /A=0 /P /S=1 /H=0 F yprofiles#2 pcurs
405 ShowInfo /w=$graphname /CP=0
429 variable
ad_profiles_set_cursor(wave image,
string cursorname, variable xa, variable ya, variable pscale = defaultValue){
435 if (ParamIsDefault(pscale))
440 dfref savedf = GetDataFolderDFR()
442 dfref viewdf = GetWavesDataFolderDFR(view_image)
443 svar /sdfr=viewdf graphname = prof_graphname
450 pa = round((xa - DimOffset(view_image, 0)) / DimDelta(view_image, 0))
451 qa = round((ya - DimOffset(view_image, 1)) / DimDelta(view_image, 1))
454 pa = min(pa, DimSize(view_image, 0) - 1)
456 qa = min(qa, DimSize(view_image, 1) - 1)
458 Cursor /i /p /w=$graphname $cursorname view_image pa, qa
485 if (ParamIsDefault(clear))
491 dfref viewdf = GetWavesDataFolderDFR(view_image)
492 svar /sdfr=viewdf graphname = prof_graphname
494 string cursors =
"A;B" 495 string colors =
"39168,0,0;0,26112,0" 500 string groupname =
"crosshairs" 505 SetDrawEnv /W=$graphname push
506 DrawAction /w=$graphname getgroup=$groupname,
delete, begininsert
507 SetDrawEnv /w=$graphname gstart, gname=$groupname
509 SetDrawEnv /W=$graphname dash=4
510 SetDrawEnv /W=$graphname linethick=0.5
512 ncursors = ItemsInList(cursors,
";")
513 for (icursor=0; icursor < ncursors; icursor += 1)
514 cursorname = StringFromList(icursor, cursors,
";")
515 color = StringFromList(icursor, colors,
";")
516 rgb.red = str2num(StringFromList(0, color,
","))
517 rgb.green = str2num(StringFromList(1, color,
","))
518 rgb.blue = str2num(StringFromList(2, color,
","))
519 if (strlen(CsrInfo($cursorname, graphname)) > 0)
520 xx = hcsr($cursorname, graphname)
521 yy = vcsr($cursorname, graphname)
522 SetDrawEnv /W=$graphname linefgc=(rgb.red, rgb.green, rgb.blue)
523 SetDrawEnv /W=$graphname save
524 SetDrawEnv /W=$graphname xcoord=bottom, ycoord=prel
525 DrawLine /W=$graphname xx, 0, xx, 1
526 SetDrawEnv /W=$graphname xcoord=prel, ycoord=left
527 DrawLine /W=$graphname 0, yy, 1, yy
531 SetDrawEnv /w=$graphname gstop
532 DrawAction /w=$graphname endinsert
533 SetDrawEnv /W=$graphname pop
534 SetDrawEnv /W=$graphname save
536 DrawAction /w=$graphname getgroup=$groupname,
delete 550 dfref viewdf = GetWavesDataFolderDFR(view)
551 svar /z /sdfr=viewdf sourcepath
552 if (svar_exists(sourcepath))
553 wave /z img = $sourcepath
565 dfref savedf = GetDataFolderDFR()
566 dfref imagedf = GetWavesDataFolderDFR(source)
567 string s_imagedf = GetDataFolder(1, imagedf)
568 setdatafolder imagedf
569 string s_viewdf = CleanupName(
"view_" + NameOfWave(source), 0)
570 newdatafolder /o/s $s_viewdf
571 dfref viewdf = GetDataFolderDFR()
589 dfref savedf = GetDataFolderDFR()
590 dfref imagedf = GetWavesDataFolderDFR(source)
592 setdatafolder imagedf
593 string s_viewdf = CleanupName(
"view_" + NameOfWave(source), 0)
594 if (DataFolderExists(s_viewdf))
595 setdatafolder $s_viewdf
596 viewdf = GetDataFolderDFR()
612 string viewname =
"view_image" 613 wave /sdfr=viewdf view = $viewname
619 STRUCT WMButtonAction &ba
621 switch( ba.eventCode )
623 string imgname = StringFromList(0, ImageNameList(ba.win,
";"))
624 wave /z image = ImageNameToWaveRef(ba.win, imgname)
625 if (waveexists(image))
626 Cursor /i/p A $imgname 0,0
627 Cursor /i/p B $imgname DimSize(image, 0)-1, DimSize(image, 1)-1
638 STRUCT WMSetVariableAction &sva
642 switch( sva.eventCode )
646 imglist = ImageNameList(sva.win,
";")
647 wave /z img = ImageNameToWaveRef(sva.win, StringFromList(0, imglist))
650 if (WaveExists(source))
663 STRUCT WMPopupAction &pa
665 switch( pa.eventCode )
667 variable popNum = pa.popNum
669 string imgname = StringFromList(0, ImageNameList(pa.win,
";"))
670 wave /z image = ImageNameToWaveRef(pa.win, imgname)
671 if (waveexists(image) && (popNum >= 1) && (popNum <= 2))
673 else if (waveexists(image) && (popNum >= 3) && (popNum <= 4))
687 struct WMWinHookStruct &s
688 variable hookresult = 0
695 imglist = ImageNameList(s.winName,
";")
696 wave /z img = ImageNameToWaveRef(s.winName, StringFromList(0, imglist))
698 viewdf = GetWavesDataFolderDFR(img)
699 cmd =
"killdatafolder /z " + GetDataFolder(1, viewdf)
704 imglist = ImageNameList(s.winName,
";")
705 wave /z img = ImageNameToWaveRef(s.winName, StringFromList(0, imglist))
729 dfref savedf = GetDataFolderDFR()
730 dfref imagedf = GetWavesDataFolderDFR(image)
731 setdatafolder imagedf
733 svar graphname = prof_graphname
736 if (strlen(CsrInfo(A, graphname)) > 0)
737 pa = pcsr(A, graphname)
738 qa = qcsr(A, graphname)
745 if (strlen(CsrInfo(B, graphname)) > 0)
746 pb = pcsr(B, graphname)
747 qb = qcsr(B, graphname)
749 pb = DimSize(image, 0) - 1
750 qb = DimSize(image, 1) - 1
778 dfref savedf = GetDataFolderDFR()
779 dfref imagedf = GetWavesDataFolderDFR(image)
780 setdatafolder imagedf
791 redimension /n=(dimsize(image,0), 3) xprofiles
792 setscale /p x dimoffset(image,0), dimdelta(image,0), WaveUnits(image,0), xprofiles
793 setscale d 0, 0, waveunits(image,-1), xprofiles
794 xprofiles[][0] = image[p][qa]
795 xprofiles[][1] = image[p][qb]
798 note xprofiles,
"SourceWave=" + nameofwave(image)
799 note xprofiles,
"SourceDimension=0" 800 note xprofiles,
"SourceIndex0=" + num2str(qa)
801 note xprofiles,
"SourceIndex1=" + num2str(qb)
808 for (qq = q0; qq <= q1; qq += 1)
809 xprofiles[][2] += image[p][qq]
811 xprofiles[][2] /= q1 - q0 + 1
814 redimension /n=(dimsize(image,1), 3) yprofiles
815 setscale /p x dimoffset(image,1), dimdelta(image,1), WaveUnits(image,1), yprofiles
816 setscale d 0, 0, waveunits(image,-1), yprofiles
817 yprofiles[][0] = image[pa][p]
818 yprofiles[][1] = image[pb][p]
821 note yprofiles,
"SourceWave=" + nameofwave(image)
822 note yprofiles,
"SourceDimension=1" 823 note yprofiles,
"SourceIndex0=" + num2str(pa)
824 note yprofiles,
"SourceIndex1=" + num2str(pb)
831 for (pp = p0; pp <= p1; pp += 1)
832 yprofiles[][2] += image[pp][p]
834 yprofiles[][2] /= p1 - p0 + 1
837 Duplicate /r=[p0,p1][q0,q1]/o image, roi_image
838 WaveStats /Q roi_image
842 graph_sum = v_avg * v_npnts
847 if (waveexists(hist))
848 Histogram /B=3 roi_image, hist
875 variable
ad_export_profile(wave view_image, variable dim, variable trace = defaultValue, variable show = defaultValue, variable overwrite = defaultValue){
882 dfref savedf = GetDataFolderDFR()
884 if (ParamIsDefault(trace))
887 if (ParamIsDefault(show))
890 if (ParamIsDefault(overwrite))
895 dfref imagedf = GetWavesDataFolderDFR(view_image)
899 wave /sdfr=imagedf profiles=xprofiles
903 wave /sdfr=imagedf profiles=yprofiles
909 string graphname_string =
"export_graph_" + dim_label
910 svar /z /sdfr=imagedf linked_graphname = $graphname_string
914 if (WaveExists(source_image))
915 dfref sourcedf = GetWavesDataFolderDFR(source_image)
916 setdatafolder sourcedf
922 string profile_note = note(profiles)
927 variable index_width = ceil(log(DimSize(view_image, 1 - dim)))
928 variable index0 = NumberByKey(
"SourceIndex0", profile_note,
"=",
"\r")
929 variable index1 = NumberByKey(
"SourceIndex1", profile_note,
"=",
"\r")
930 name_dim =
"_" + dim_label
931 sprintf name_index,
"%0*u_%0*u", index_width, index0, index_width, index1
932 name_base = NameOfWave(source_image)
933 name_base = name_base[0, min(strlen(name_base), 31 - strlen(name_index) - strlen(name_dim) - 1)]
934 profile_name = name_base + name_dim + name_index
935 if ((overwrite == 0) && (CheckName(profile_name, 1)))
936 profile_name = UniqueName(profile_name +
"_", 1, 0)
940 duplicate /o /r=[][trace] profiles, $profile_name /wave=dest_profile
941 redimension /n=(dimsize(profiles, 0)) dest_profile
942 profile_note = ReplaceStringByKey(
"SourceWave", profile_note, NameOfWave(source_image),
"=",
"\r")
944 note dest_profile, profile_note
945 print
"created", GetWavesDataFolder(dest_profile, 2)
952 graphname =
"export_profiles_" + dim_label
953 graphtitle = UpperStr(dim_label) +
" Profiles" 956 if (svar_exists(linked_graphname) && (ItemsInList(WinList(linked_graphname,
";",
"WIN:1"),
";") >= 1))
957 graphname = linked_graphname
959 graphname = GetWavesDataFolder(source_image, 0) + name_dim
961 graphtitle = UpperStr(dim_label) +
" Profiles: " + GetWavesDataFolder(source_image, 2)
964 if ((ItemsInList(WinList(graphname,
";",
"WIN:1"),
";") >= 1))
965 appendtograph /w=$graphname dest_profile
967 setdatafolder imagedf
968 display /k=1 /n=$graphname dest_profile as graphtitle
970 ModifyGraph /w=$graphname mirror=1,nticks=3,minor=1
971 ModifyGraph /w=$graphname axThick=0.5,btLen=4
972 ModifyGraph /w=$graphname gfSize=10
973 ModifyGraph /w=$graphname grid=2,gridHair=0,gridRGB=(52224,52224,52224)
974 Legend /w=$graphname /C/N=legend0/F=0/B=1/A=LT/X=0.00/Y=0.00
977 string /g $graphname_string = graphname
989 ModifyGraph /w=$graphname /z rgb[0]=(0, 0, 0)
990 ModifyGraph /w=$graphname /z rgb[1]=(65535, 16385, 16385)
991 ModifyGraph /w=$graphname /z rgb[2]=(2, 39321, 1)
992 ModifyGraph /w=$graphname /z rgb[3]=(0, 0, 65535)
993 ModifyGraph /w=$graphname /z rgb[4]=(39321, 1, 31457)
994 ModifyGraph /w=$graphname /z rgb[5]=(48059, 48059, 48059)
995 ModifyGraph /w=$graphname /z rgb[6]=(65535, 32768, 32768)
996 ModifyGraph /w=$graphname /z rgb[7]=(0, 65535, 0)
997 ModifyGraph /w=$graphname /z rgb[8]=(16385,65535,65535)
998 ModifyGraph /w=$graphname /z rgb[9]=(65535, 32768, 58981)
1010 dfref savedf = GetDataFolderDFR()
1011 dfref imagedf = GetWavesDataFolderDFR(image)
1012 setdatafolder imagedf
1015 Histogram /B=3 image, hist
1017 setdatafolder savedf
1048 variable xsmoothing = NumberByKey(
"SmoothingX", options,
"=",
";")
1049 variable ysmoothing = NumberByKey(
"SmoothingY", options,
"=",
";")
1051 if ((NumType(xsmoothing) == 0) && (xsmoothing >= 2))
1052 Smooth /B /DIM=0 /E=3 xsmoothing, image
1054 if ((NumType(ysmoothing) == 0) && (ysmoothing >= 2))
1055 Smooth /B /DIM=1 /E=3 ysmoothing, image
1070 MatrixTranspose image
1085 if(exists(
"NewGizmo") != 4)
1086 abort
"Gizmo XOP must be installed." 1088 if (WaveDims(data) != 3)
1089 abort
"ad_display_brick: data must be three-dimensional." 1092 dfref savedf = GetDataFolderDFR()
1093 dfref datadf = GetWavesDataFolderDFR(data)
1094 string s_datadf = GetDataFolder(1, datadf)
1097 setdatafolder viewdf
1098 string dfname = ReplaceString(
"root:", s_datadf,
"")
1099 string graphtitle = dfname +
" Gizmo" 1101 svar graphname = gizmo_graphname
1103 if ((strlen(graphname) > 0) && (wintype(graphname) == 13))
1104 setdatafolder savedf
1108 variable nx = dimsize(data, 0)
1109 variable ny = dimsize(data, 1)
1110 variable nz = dimsize(data, 2)
1117 setdatafolder datadf
1118 sprintf cmd,
"NewGizmo /k=1 /n=%s /w=(100,100,500,400) /t=\"%s\"", graphname, graphtitle
1120 cmd =
"AppendToGizmo /D Axes=BoxAxes, name=axes0" 1123 obj =
"surface_xmid" 1124 pp = round(nx / 2 - 1)
1125 sprintf cmd,
"AppendToGizmo /D surface=%s, name=%s", nameofwave(data), obj
1127 sprintf cmd,
"ModifyGizmo modifyObject=%s, property={srcMode, 128}", obj
1129 sprintf cmd,
"ModifyGizmo ModifyObject=%s, property={plane, %d}", obj, pp
1131 sprintf cmd,
"ModifyGizmo modifyObject=%s, property={surfaceCtab, BlueGreenOrange}", obj
1133 sprintf cmd,
"ModifyGizmo ModifyObject=%s, property={SurfaceCTABScaling,128}", obj
1135 sprintf cmd,
"ModifyGizmo modifyObject=%s, property={surfaceCTABAlpha, 1.0}", obj
1138 obj =
"surface_ymid" 1139 pp = round(ny / 2 - 1)
1140 sprintf cmd,
"AppendToGizmo /D surface=%s, name=%s", nameofwave(data), obj
1142 sprintf cmd,
"ModifyGizmo modifyObject=%s, property={srcMode, 64}", obj
1144 sprintf cmd,
"ModifyGizmo ModifyObject=%s, property={plane, %d}", obj, pp
1146 sprintf cmd,
"ModifyGizmo modifyObject=%s, property={surfaceCtab, BlueGreenOrange}", obj
1148 sprintf cmd,
"ModifyGizmo ModifyObject=%s, property={SurfaceCTABScaling,128}", obj
1150 sprintf cmd,
"ModifyGizmo modifyObject=%s, property={surfaceCTABAlpha, 1.0}", obj
1153 obj =
"surface_zmid" 1154 pp = round(nz / 2 - 1)
1155 sprintf cmd,
"AppendToGizmo /D surface=%s, name=%s", nameofwave(data), obj
1157 sprintf cmd,
"ModifyGizmo modifyObject=%s, property={srcMode, 32}", obj
1159 sprintf cmd,
"ModifyGizmo ModifyObject=%s, property={plane, %d}", obj, pp
1161 sprintf cmd,
"ModifyGizmo modifyObject=%s, property={surfaceCtab, BlueGreenOrange}", obj
1163 sprintf cmd,
"ModifyGizmo ModifyObject=%s, property={SurfaceCTABScaling,128}", obj
1165 sprintf cmd,
"ModifyGizmo modifyObject=%s, property={surfaceCTABAlpha, 1.0}", obj
1169 sprintf cmd,
"ModifyGizmo ModifyObject=%s,property={-1,axisScalingMode,1}", obj
1171 sprintf cmd,
"ModifyGizmo ModifyObject=%s,property={-1,axisColor,0,0,0,1}", obj
1173 sprintf cmd,
"ModifyGizmo ModifyObject=%s,property={0,ticks,3}", obj
1175 sprintf cmd,
"ModifyGizmo ModifyObject=%s,property={1,ticks,3}", obj
1177 sprintf cmd,
"ModifyGizmo ModifyObject=%s,property={2,ticks,3}", obj
1179 sprintf cmd,
"ModifyGizmo modifyObject=%s property={Clipped,0}", obj
1181 sprintf cmd,
"ModifyGizmo modifyObject=%s property={-1,fontScaleFactor,2}", obj
1184 sprintf cmd,
"ModifyGizmo showAxisCue=1" 1187 setdatafolder savedf
1201 dfref savedf = GetDataFolderDFR()
1202 dfref datadf = GetWavesDataFolderDFR(data)
1203 string s_datadf = GetDataFolder(1, datadf)
1206 setdatafolder viewdf
1207 svar /z ex_panel = slicer_panelname
1208 if (svar_exists(ex_panel))
1209 string panels = WinList(
"SlicerPanel*",
";",
"WIN:64")
1210 if (WhichListItem(ex_panel, panels,
";") >= 0)
1211 dowindow /f $(StringFromList(0, panels,
";"))
1216 variable /g x_slice_pos
1217 variable /g y_slice_pos
1218 variable /g z_slice_pos
1219 variable /g slab_thickness
1220 string /g brick_path = getwavesdatafolder(data, 2)
1221 variable /g x_autoinc = 0
1222 variable /g y_autoinc = 0
1223 variable /g z_autoinc = 0
1226 string labels = note(data)
1227 string xlabel = StringByKey(
"AxisLabelX", labels,
"=",
"\r")
1228 if (!strlen(xlabel))
1231 string ylabel = StringByKey(
"AxisLabelY", labels,
"=",
"\r")
1232 if (!strlen(ylabel))
1235 string zlabel = StringByKey(
"AxisLabelZ", labels,
"=",
"\r")
1236 if (!strlen(zlabel))
1239 string dlabel = StringByKey(
"Dataset", labels,
"=",
"\r")
1240 if (!strlen(dlabel))
1241 dlabel = NameOfWave(data)
1245 NewPanel /k=1 /W=(500,600,890,940) /N=SlicerPanel as
"Brick Slicer" 1246 string /g slicer_panelname = S_name
1247 string panel = s_name
1249 GroupBox g_xslice win=$panel,pos={8,8},size={376,96},title=xlabel
1251 Slider sl_xslice_position win=$panel,limits={0,100,1},variable=x_slice_pos,vert= 0
1253 SetVariable sv_xslice_position win=$panel,limits={0,100,1},value=x_slice_pos
1255 Button b_xslice_center win=$panel,help={
"reset to center position"}
1257 Button b_xslice_extract win=$panel,help={
"extract this slice to a separate wave"}
1260 TitleBox tb_xslice_animation win=$panel,pos={288,32},size={356,16},title=
"animation",frame=0
1261 TitleBox tb_xslice_animation win=$panel,anchor= MC
1263 Button b_xslice_back win=$panel,help={
"animate backwards"}
1265 Button b_xslice_forward win=$panel,help={
"animate forward"}
1267 Button b_xslice_stop win=$panel,help={
"stop animation"}
1269 GroupBox g_yslice win=$panel,pos={8,108},size={376,96},title=ylabel
1271 Slider sl_yslice_position win=$panel,limits={0,100,1},variable=y_slice_pos,vert= 0
1273 SetVariable sv_yslice_position win=$panel,limits={0,100,1},value=y_slice_pos
1275 Button b_yslice_center win=$panel,help={
"reset to center position"}
1277 Button b_yslice_extract win=$panel,help={
"extract this slice to a separate wave"}
1280 TitleBox tb_yslice_animation win=$panel,pos={288,132},size={356,16},title=
"animation",frame=0
1281 TitleBox tb_yslice_animation win=$panel,anchor= MC
1283 Button b_yslice_back win=$panel,help={
"animate backwards"}
1285 Button b_yslice_forward win=$panel,help={
"animate forward"}
1287 Button b_yslice_stop win=$panel,help={
"stop animation"}
1289 GroupBox g_zslice win=$panel,pos={8,208},size={376,96},title=zlabel
1291 Slider sl_zslice_position win=$panel,limits={0,100,1},variable=z_slice_pos,vert= 0
1293 SetVariable sv_zslice_position win=$panel,limits={0,100,1},value=z_slice_pos
1295 Button b_zslice_center win=$panel,help={
"reset to center position"}
1297 Button b_zslice_extract win=$panel,help={
"extract this slice to a separate wave"}
1300 TitleBox tb_zslice_animation win=$panel,pos={288,232},size={356,16},title=
"animation",frame=0
1301 TitleBox tb_zslice_animation win=$panel,anchor= MC
1303 Button b_zslice_back win=$panel,help={
"animate backwards"}
1305 Button b_zslice_forward win=$panel,help={
"animate forward"}
1307 Button b_zslice_stop win=$panel,help={
"stop animation"}
1309 TitleBox t_slicerpath win=$panel,pos={8,316},size={128,20},disable=2,title=dlabel
1314 setwindow $panel, userdata(control_datafolder) = GetDataFolder(1, viewdf)
1315 setwindow $panel, userdata(brick_path) = brick_path
1317 x_slice_pos = dimoffset(data, 0) + dimsize(data, 0) * dimdelta(data, 0) / 2
1318 y_slice_pos = dimoffset(data, 1) + dimsize(data, 1) * dimdelta(data, 1) / 2
1319 z_slice_pos = dimoffset(data, 2) + dimsize(data, 2) * dimdelta(data, 2) / 2
1321 svar /z /sdfr=viewdf gizmo_graphname
1322 if (svar_exists(gizmo_graphname) && (strlen(gizmo_graphname) > 0) && (wintype(gizmo_graphname) == 13))
1327 svar /z /sdfr=viewdf slice_graphname
1328 if (svar_exists(slice_graphname) && (strlen(slice_graphname) > 0) && (wintype(slice_graphname) == 1))
1333 setdatafolder savedf
1348 if (WaveDims(data) != 3)
1349 abort
"ad_display_slice: data must be three-dimensional." 1352 dfref savedf = GetDataFolderDFR()
1353 dfref datadf = GetWavesDataFolderDFR(data)
1354 string s_datadf = GetDataFolder(1, datadf)
1357 setdatafolder viewdf
1358 string dfname = ReplaceString(
"root:", s_datadf,
"")
1359 dfname = dfname[0, strlen(dfname) - 2]
1360 string graphtitle = dfname +
" Slice" 1362 if (exists(
"slice_graphname") != 2)
1363 string /g slice_graphname =
"" 1365 string /g slice_wavename = CleanupName(
"slice_" + NameOfWave(data), 0)
1366 svar graphname = slice_graphname
1367 svar slicename = slice_wavename
1369 make /n=(1,1)/o $slicename
1370 wave slice = $slicename
1371 if ((strlen(graphname) == 0) || (wintype(graphname) != 1))
1374 variable z_slice_pos = dimoffset(data, 2) + dimsize(data, 2) * dimdelta(data, 2) / 2
1379 setdatafolder savedf
1387 dfref savedf = GetDataFolderDFR()
1391 wave brick = $brick_path
1394 variable lo, hi, inc
1395 lo = dimoffset(brick, 0)
1396 inc = dimdelta(brick, 0)
1397 hi = lo + inc * (dimsize(brick, 0) - 1)
1398 Slider sl_xslice_position,limits={lo,hi,inc}
1399 SetVariable sv_xslice_position,limits={lo,hi,inc}
1400 lo = dimoffset(brick, 1)
1401 inc = dimdelta(brick, 1)
1402 hi = lo + inc * (dimsize(brick, 1) - 1)
1403 Slider sl_yslice_position,limits={lo,hi,inc}
1404 SetVariable sv_yslice_position,limits={lo,hi,inc}
1405 lo = dimoffset(brick, 2)
1406 inc = dimdelta(brick, 2)
1407 hi = lo + inc * (dimsize(brick, 2) - 1)
1408 Slider sl_zslice_position,limits={lo,hi,inc}
1409 SetVariable sv_zslice_position,limits={lo,hi,inc}
1411 setdatafolder savedf
1427 dfref savedf = GetDataFolderDFR()
1428 dfref datadf = GetWavesDataFolderDFR(brick)
1430 svar /z /sdfr=viewdf graphname=gizmo_graphname
1432 variable pp = round((value - dimoffset(brick, dim)) / dimdelta(brick, dim))
1433 if ((pp < 0) || (pp >= dimsize(brick, dim)))
1437 if (svar_exists(graphname) && (strlen(graphname) > 0) && (wintype(graphname) == 13))
1439 string obj =
"surface_" + axes[dim] +
"mid" 1441 sprintf cmd,
"ModifyGizmo /N=%s ModifyObject=%s, property={plane, %d}", graphname, obj, pp
1463 dfref savedf = GetDataFolderDFR()
1464 dfref datadf = GetWavesDataFolderDFR(brick)
1466 svar /z /sdfr=viewdf graphname = slice_graphname
1467 svar /z /sdfr=viewdf slicename = slice_wavename
1469 variable pp = round((value - dimoffset(brick, dim)) / dimdelta(brick, dim))
1470 if ((pp < 0) || (pp >= dimsize(brick, dim)))
1474 if (svar_exists(graphname) && (strlen(graphname) > 0) && (wintype(graphname) == 1))
1475 setdatafolder viewdf
1494 setdatafolder savedf
1500 STRUCT WMSliderAction &sa
1502 dfref savedf = GetDataFolderDFR()
1504 switch( sa.eventCode )
1508 if( sa.eventCode & 1 )
1509 string control_datafolder = GetUserData(sa.win,
"",
"control_datafolder")
1510 setdatafolder control_datafolder
1511 string brick_path = GetUserData(sa.win,
"",
"brick_path")
1512 string axis = StringFromList(1, sa.ctrlName,
"_")
1513 variable dim = char2num(axis[0]) - char2num(
"x")
1515 wave /z brick = $brick_path
1516 if (WaveExists(brick))
1520 Abort
"can't find original wave " + brick_path
1526 setdatafolder savedf
1532 STRUCT WMSetVariableAction &sva
1534 dfref savedf = GetDataFolderDFR()
1536 switch( sva.eventCode )
1540 string control_datafolder = GetUserData(sva.win,
"",
"control_datafolder")
1541 setdatafolder control_datafolder
1542 string brick_path = GetUserData(sva.win,
"",
"brick_path")
1543 string axis = StringFromList(1, sva.ctrlName,
"_")
1544 variable dim = char2num(axis[0]) - char2num(
"x")
1546 wave /z brick = $brick_path
1547 if (WaveExists(brick))
1551 Abort
"can't find original wave " + brick_path
1558 setdatafolder savedf
1564 STRUCT WMButtonAction &ba
1566 dfref savedf = GetDataFolderDFR()
1568 switch( ba.eventCode )
1570 string control_datafolder = GetUserData(ba.win,
"",
"control_datafolder")
1571 setdatafolder control_datafolder
1572 string brick_path = GetUserData(ba.win,
"",
"brick_path")
1573 string axis = StringFromList(1, ba.ctrlName,
"_")
1574 string cmd = StringFromList(2, ba.ctrlName,
"_")
1575 variable dim = char2num(axis[0]) - char2num(
"x")
1576 string posvariable = getdatafolder(1) + axis[0] +
"_slice_pos" 1577 nvar pos = $(posvariable)
1579 wave /z brick = $brick_path
1580 if (WaveExists(brick))
1598 Abort
"can't find original wave " + brick_path
1605 setdatafolder savedf
1613 STRUCT WMButtonAction &ba
1615 dfref savedf = GetDataFolderDFR()
1617 switch( ba.eventCode )
1619 string control_datafolder = GetUserData(ba.win,
"",
"control_datafolder")
1620 setdatafolder control_datafolder
1621 string brick_path = GetUserData(ba.win,
"",
"brick_path")
1622 wave brick = $brick_path
1623 dfref brickdf = GetWavesDataFolderDFR(brick)
1625 string axis = StringFromList(1, ba.ctrlName,
"_")
1626 string cmd = StringFromList(2, ba.ctrlName,
"_")
1627 variable dim = char2num(axis[0]) - char2num(
"x")
1628 string posvariable = getdatafolder(1) + axis[0] +
"_slice_pos" 1630 nvar pos = $(posvariable)
1631 variable pp = round((pos - dimoffset(brick, dim)) / dimdelta(brick, dim))
1632 if ((pp < 0) || (pp >= dimsize(brick, dim)))
1636 variable dig = ceil(log(dimsize(brick, dim)))
1638 sprintf slicename,
"%s_%s%0*u", NameOfWave(brick), axis[0], dig, pp
1639 setdatafolder brickdf
1653 sprintf msg,
"%s=%g", axis[0], pos
1661 setdatafolder savedf
1671 nvar pos = $posvariable
1672 pos = dimoffset(brick, dim) + dimdelta(brick, dim) * dimsize(brick, dim) / 2
1679 STRUCT WMBackgroundStruct &s
1681 dfref savedf = GetDataFolderDFR()
1682 setdatafolder root:pearl_area:slicer
1683 wave /t bg_brickpaths
1684 wave /t bg_graphnames
1685 wave /t bg_variablepaths
1690 variable nn = numpnts(bg_brickpaths)
1694 for (ii = 0; ii < nn; ii += 1)
1695 wave /z brick = $bg_brickpaths[ii]
1696 nvar /z pos = $bg_variablepaths[ii]
1697 dim = bg_dimensions[0]
1698 pos += bg_increments[ii]
1700 pp = round((pos - dimoffset(brick, dim)) / dimdelta(brick, dim))
1702 pos = dimoffset(brick, dim) + dimdelta(brick, dim) * (dimsize(brick, dim) - 1)
1703 else if (pp >= dimsize(brick, dim) - 0.5)
1704 pos = dimoffset(brick, dim)
1706 if (waveexists(brick))
1712 setdatafolder savedf
1718 dfref savedf = GetDataFolderDFR()
1720 newdatafolder /o/s pearl_area
1721 newdatafolder /o/s slicer
1723 make /n=0/o/t bg_brickpaths
1724 make /n=0/o/t bg_variablepaths
1725 make /n=0/o/i/u bg_dimensions
1726 make /n=0/o bg_increments
1730 setdatafolder savedf
1747 dfref savedf = GetDataFolderDFR()
1748 setdatafolder root:pearl_area:slicer
1749 wave /t bg_brickpaths
1750 wave /t bg_variablepaths
1756 FindValue /TEXT=posvariable /TXOP=4 /Z bg_variablepaths
1760 idx = numpnts(bg_variablepaths)
1761 InsertPoints idx, 1, bg_brickpaths, bg_variablepaths, bg_dimensions, bg_increments
1765 bg_brickpaths[idx] = GetWavesDataFolder(brick, 2)
1766 bg_variablepaths[idx] = posvariable
1767 bg_dimensions[idx] = dimension
1768 bg_increments[idx] = delta
1771 if (numpnts(bg_variablepaths) > 0)
1772 CtrlNamedBackground ad_slicer, start
1775 setdatafolder savedf
1786 dfref savedf = GetDataFolderDFR()
1787 setdatafolder root:pearl_area:slicer
1788 wave /t bg_brickpaths
1789 wave /t bg_variablepaths
1794 FindValue /TEXT=posvariable /TXOP=4 /Z bg_variablepaths
1796 DeletePoints v_value, 1, bg_brickpaths, bg_variablepaths, bg_dimensions, bg_increments
1800 if (numpnts(bg_variablepaths) == 0)
1801 CtrlNamedBackground ad_slicer, stop
1804 setdatafolder savedf
threadsafe wave ad_extract_slab_x(wave dataset, variable p1, variable p2, string destname, variable noavg=defaultValue)
variable ad_profiles_cursor_mode(wave image, variable mode)
switch cursors on a profiles graph
static variable ad_slicer_move_bg(WMBackgroundStruct *s)
move a slice by one step (background task).
static variable set_trace_colors(string graphname)
static variable slp_slice_position(WMSliderAction *sa)
set slice coordinate (slider procedure).
variable ad_slicer_start_bg(wave brick, variable dimension, string posvariable, variable delta)
start the animation.
variable ad_profiles_crosshairs(wave image, variable clear=defaultValue)
draw permanent crosshairs in a profiles graph.
variable ad_update_profiles(wave image)
update a profiles graph with new data.
variable ad_slicer_stop_bg(string posvariable)
stop the animation.
variable ad_default_image_filter(wave image, string options)
abstract filter function for image display.
static variable svp_smoothing(WMSetVariableAction *sva)
variable ad_brick_slicer(wave data)
open a slicer panel for 3D data.
variable ad_profiles_set_slice(wave brick, variable dim, variable value)
set the position of the slicing plane of a 3D brick in a profiles window.
static dfr get_view_folder(wave source)
find the view data folder corresponding to the given source.
variable ad_calc_histogram(wave image)
calculate the histogram.
static dfr make_view_folder(wave source)
create a view data folder.
threadsafe wave ad_extract_slab_z(wave dataset, variable r1, variable r2, string destname, variable noavg=defaultValue)
variable ad_calc_profiles(wave image, variable pa, variable qa, variable pb, variable qb)
calculate profiles, statistics, and histogram of a rectangular region of interest.
variable ad_profiles_set_cursor(wave image, string cursorname, variable xa, variable ya, variable pscale=defaultValue)
move a cursor to the specified position in a profiles graph.
static wave get_view_image(wave source)
find the view image wave corresponding to the given source.
instant visualization of angle scan and manipulator position.
static variable bp_extract_slice(WMButtonAction *ba)
export a slice (button procedure).
static variable pmp_export(WMPopupAction *pa)
static wave get_source_image(wave view)
find the source image wave corresponding to the given view.
string ad_display_histogram(wave image)
display the histogram of a 2D image.
threadsafe wave ad_extract_slab_y(wave dataset, variable q1, variable q2, string destname, variable noavg=defaultValue)
string ad_display(wave image)
open a new graph window with a 2D image.
static string graphname_from_dfref(dfref df, string prefix)
compose a valid and unique graph name from a data folder reference
variable ad_calc_cursor_profiles(wave image)
calculate profiles, statistics, and histogram of a cross-hair delimited region of interest...
static variable update_slice_info()
update controls with data scale limits.
variable ad_slicer_init_bg()
initialize the slice animation background task.
string ad_display_profiles(wave image, string filter=defaultValue)
open a new profiles graph window.
static variable svp_slice_position(WMSetVariableAction *sva)
set slice coordinate (button procedure).
static variable bp_reset_cursors(WMButtonAction *ba)
variable ad_export_profile(wave view_image, variable dim, variable trace=defaultValue, variable show=defaultValue, variable overwrite=defaultValue)
export a profile from a profiles graph to the source data folder.
variable ad_gizmo_set_plane(wave brick, variable dim, variable value)
set the position of a slicing plane of a 3D brick in a Gizmo window.
variable ad_transpose_filter(wave image, string options)
transpose image filter.
string ad_display_slice(wave data)
display three-dimensional data by 2D slice.
static variable bp_move_slice_center(wave brick, variable dim, string posvariable)
move the slice to the center of the dimension (button procedure).
static variable bp_move_slice(WMButtonAction *ba)
move slice (button procedure).
variable ad_box_filter(wave image, string options)
boxcar smoothing filter.
string ad_display_brick(wave data)
open a new "gizmo" window with three-dimensional data.
variable ad_profiles_hook(WMWinHookStruct *s)
hook function for user events in the profiles window.