Gizmo and customized surface cuts
thomas_braun
I want to create a Gizmo with some fancy slices.
My starting point is the Gizmo slicer Panel. It creates slices at planes in the X,Y,Z direction.
Now I would like to define these surface planes more freely. For example I want them to hold data summed over multiple indizes, or even all planes in a direction.
For the z-direction I've succeeded by using a Surface with a Matrix wave as source, define my MxN surface wave with constant entries, and use "Color from wave" from a custom color table.
// create necessary waves
Function doStuff0()
Wave data // 3D data to visualize
Make/O/D/N=(DimSize(data,0),DimSize(data,1)) cut0
cut0 = DimOffset(data,2)
CopyScales data, cut0
Duplicate/O cut0, sum0, col0
Redimension/N=(-1,-1,4) col0
variable sl
// sum all layers
variable i, j, k
for(i=0; i < DimSize(data,0); i+=1)
for(j=0; j < DimSize(data,1); j+=1)
sl = 0
for(k=0; k < DimSize(data,2); k+=1)
sl += data[i][j][k]
endfor
sum0[i][j] = sl
endfor
endfor
// color table magic
colortab2wave Rainbow
Wave m_colors
Redimension/D/N=(-1,4) m_colors
m_colors[][3] = 0 // alpha
m_colors /=65535
wavestats/Q sum0
SetScale/I x, V_min, V_max, "", m_colors
col0 = m_colors(sum0[p][q])[r]
End
///.. relevant gizmo code
AppendToGizmo Surface=root:cut0,name=proj0
ModifyGizmo ModifyObject=proj0 property={ surfaceColorType,3}
ModifyGizmo ModifyObject=proj0 property={ srcMode,0}
ModifyGizmo ModifyObject=proj0 property={ surfaceColorWave,root:col0}
//...
Function doStuff0()
Wave data // 3D data to visualize
Make/O/D/N=(DimSize(data,0),DimSize(data,1)) cut0
cut0 = DimOffset(data,2)
CopyScales data, cut0
Duplicate/O cut0, sum0, col0
Redimension/N=(-1,-1,4) col0
variable sl
// sum all layers
variable i, j, k
for(i=0; i < DimSize(data,0); i+=1)
for(j=0; j < DimSize(data,1); j+=1)
sl = 0
for(k=0; k < DimSize(data,2); k+=1)
sl += data[i][j][k]
endfor
sum0[i][j] = sl
endfor
endfor
// color table magic
colortab2wave Rainbow
Wave m_colors
Redimension/D/N=(-1,4) m_colors
m_colors[][3] = 0 // alpha
m_colors /=65535
wavestats/Q sum0
SetScale/I x, V_min, V_max, "", m_colors
col0 = m_colors(sum0[p][q])[r]
End
///.. relevant gizmo code
AppendToGizmo Surface=root:cut0,name=proj0
ModifyGizmo ModifyObject=proj0 property={ surfaceColorType,3}
ModifyGizmo ModifyObject=proj0 property={ srcMode,0}
ModifyGizmo ModifyObject=proj0 property={ surfaceColorWave,root:col0}
//...
But how can I do that for the other dimensions? I've tried parametric and quad waves, but these don't allow setting a custom color wave in the way it is done with the Matrix wave as source.
I could translate and rotate my surface defined with Matrix wave as source. But this gets quite involved, as I have to keep track of wave scaling also. And speaking of complicated I'm not sure I want to involve textures either.
Any ideas?
Thanks
Thomas
An easy way to accomplish what you want is to create a parametric wave for the desired plane and assign to it a color wave that represents your data. This is how the image on the left is created. The parametric wave happens to define a sphere and the data are sampled along a sphere in an MRI of a brain.
Obviously there are other ways to accomplish the same thing, e.g., using textures, but I really think the other approaches are far more complicated than using a parametric surface. Feel free to email me a sample experiment if you need more specific help.
A.G.
WaveMetrics, Inc.
March 26, 2014 at 04:55 pm - Permalink