# Advanced: Making a sweeping slice through volume of data.7

Posted by Doug Hull,

A MATLAB user recently asked how we could make a visualization similar to this one.

I was a little surprised that we were able to do the visualization, with interactivity in less that 15 lines of code.

%%
d = flow; d = shiftdim(d,2);
x = 25;
y = 26;
z = 21.59561;
v =  3.22068;

h = slice(d,x,y,z)
d(:,:,z:end) = nan;
isosurface(d,-v)

set(h,'edgeColor','none')
axis equal
zlim([0 size(d,3)])
colormap spring


This video makes use of cell mode to get the interactivity. You can see how something like this could be done with a GUI to get the interactivity that you might want.

If you like this kind of thing, Slice-o-matic, will be good for you.

Vick replied on : 1 of 7
Good job Doug, I wasn't quite sure what those +- cell modes were until I saw this video. Another thing I was expecting in this code was "hold on" somewhere, I believe either slice or isosurface has it by default?
Shaffy replied on : 2 of 7
Hey Doug, I am doing something similar to your work, I'm building 3d human head using 377 image slices. I have wrote this following code:
myFolder = 'C:\Users\shaffy\Desktop\Design 4\HEAD';
for ii = 2:377 %loop through the rest
file_name = ['a_vm1' num2str(ii,'%03i') '.png'];
end

But when I run this I get errors such as : ??? Assignment has more non-singleton rhs dimensions than non-singleton subscripts Can you help me? Thanks man
dhull replied on : 3 of 7
Shaffy, Run this with the debugger at the line that is giving your problems, run just the left hand side and the right hand side, see what is coming out. You might have to reshape, or gather the outputs or something. Hard to tell without your data. Doug
Ian replied on : 4 of 7
Hi Doug As you said that we can do a visualisation like the first video with just the subsequent following line of code, i wonder myself on how i can do that with a stack of images. I downloaded Sliceomatic, but i'm not too sure how to implement it. When i load in the .tif files, the sliceomatic files seems to change the original color of my picture. And i'm at a lost on how to subsequently add more pictures on top of the first one i started the sliceomatic gui up with. THanks!
doug replied on : 5 of 7
@Ian, I suspect the Tif are coming in with a different colormap for each one. Sliceomatic can only deal with one colormap for the whole stack. Would it make sense to turn your images into greyscale, so they all have same range? Doug
bintoro replied on : 6 of 7
Hi doug, I have 9 2D images of weather radar reflectivity (.png), each image represents one layer radar elavation. Each image have black color for the backgroud. How to combine these 9 images to one 3D image? How to draw each one with some space between?
Doug replied on : 7 of 7
You can combine them in a 3d matrix: Three(:,:,2) = Two This would concatinate Matrix Two into the third dimension of Three

This site uses Akismet to reduce spam. Learn how your comment data is processed.