**Editor's Note:** This file was selected as MATLAB Central Pick of the Week

GUI for manipulating slices and isosurfaces over a volume.

Control over color transparency, contours, and rendering techniques via menus.

Original sliceomatic 1.0 for older versions of MATLAB is in the zip file.

Eric Ludlam (2020). Sliceomatic (https://www.mathworks.com/matlabcentral/fileexchange/764-sliceomatic), MATLAB Central File Exchange. Retrieved .

Created with
R14SP1

Compatible with any release

**Inspired:**
pcolor3, IsoSlicer, MRI Brain Segmentation, Mia 2.5, VolumeViewer

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!Create scripts with code, output, and formatted text in a single executable document.

Duncan LFor Matlab 2019b, works following advice of Vinh.

Very slick applet!

Found a bug where moving the arrow sliders won't move/update visualized planes if intervals between values passed into Sliceomatic in xmesh/ymesh/zmesh variables are less than 1. I believe this is the same bug spotted by Lukas Kortmann.

Can fix by:

1. Change in ~/sliceomatic/private/slicomaticsetdata.m

Replacing

d.xmesh = nan;

d.ymesh = nan;

d.zmesh = nan;

with

d.xmesh = 1:size(d.data,2);

d.ymesh = 1:size(d.data,1);

d.zmesh = 1:size(d.data,3);

2. Change in ~/sliceomatic/sliceomatic.m

Replacing

if round(apos(1,1))~=round(pos(1,1))

with

if interp1(d.xmesh, d.xmesh, apos(1,1), 'nearest')~=interp1(d.xmesh, d.xmesh, pos(1,1), 'nearest')

And replacing 2 instances of

if round(apos(1,2))~=round(pos(1,2))

with

if interp1(d.ymesh, d.ymesh, apos(1,2), 'nearest')~=interp1(d.ymesh, d.ymesh, pos(1,2), 'nearest')

and

if interp1(d.zmesh, d.zmesh, apos(1,2), 'nearest')~=interp1(d.zmesh, d.zmesh, pos(1,2), 'nearest')

in the respective order

3. Change in ~/sliceomatic/sliceomatic.m

Replacing

xi=round(X);

with

xi=interp1(d.xmesh, d.xmesh, X, 'nearest');

And replacing

yi=round(Y);

with

yi=interp1(d.ymesh, d.ymesh, Y, 'nearest');

And replacing

zi=round(Z);

with

zi=interp1(d.zmesh, d.zmesh, Z, 'nearest');

Duncan LFor Matlab 2019b, works following advice of Vinh.

Very slick applet!

Found a bug where moving the arrow sliders won't move visualized planes if xmesh/ymesh/zmesh variables are less than 1.

Can fix by:

1. Change in ~/sliceomatic/private/slicomaticsetdata.m

Replacing

d.xmesh = nan;

d.ymesh = nan;

d.zmesh = nan;

with

d.xmesh = 1:size(d.data,2);

d.ymesh = 1:size(d.data,1);

d.zmesh = 1:size(d.data,3);

2. Change in ~/sliceomatic/sliceomatic.m

Replacing

if round(apos(1,1))~=round(pos(1,1))

with

if interp1(d.xmesh, d.xmesh, apos(1,1), 'nearest')~=interp1(d.xmesh, d.xmesh, pos(1,1), 'nearest')

And replacing 2 instances of

if round(apos(1,2))~=round(pos(1,2))

with

if interp1(d.ymesh, d.ymesh, apos(1,2), 'nearest')~=interp1(d.ymesh, d.ymesh, pos(1,2), 'nearest')

and

if interp1(d.zmesh, d.zmesh, apos(1,2), 'nearest')~=interp1(d.zmesh, d.zmesh, pos(1,2), 'nearest')

in the respective order

3. Change in ~/sliceomatic/sliceomatic.m

Replacing

xi=round(X);

with

xi=interp1(d.xmesh, d.xmesh, X, 'nearest');

And replacing

yi=round(Y);

with

yi=interp1(d.ymesh, d.ymesh, Y, 'nearest');

And replacing

zi=round(Z);

with

zi=interp1(d.zmesh, d.zmesh, Z, 'nearest');

Kamran GasimovDaniel TheobaldFor Matlab 2018b

I follow the advice of Vinh and still get the error on line 54 and 203 when using my data vector (y) : >> sliceomatic(y)

However, the sample data works from the command window with no input variables : >>sliceomatic

Nikita GourianovFollow Vinh's suggestions and it'll work on Matlab R2017b. Oh, and if nothing appears once you start visualising and you don't understand why: click on the Iso surface controller and move the slider around. You need to actually define the parameters of the visualisation before anything shows up.

Omar IdrissHello everyone!! I have a problem when I want to copy slimatic in figure the following error is displayed:

Error using get

The ErrorMessage property has been removed. At the command line, use MException.last instead.

Error in sliceomatic (line 827)

disp(get(0,'errormessage'));

Error while evaluating Menu Callback.

Can someone help me !!

Eric PetersonLi Chentake the advice of Vinh and now the program works for R2018a

Ollie HelpsHow do I import an stl?

Eze AhanonuNote that you need to download the sliceomatic and hline_vline packages from the matlab file exchange. Along with the solutions given by Vinh, you will need to update the name of the 'update_SliceOMatic' called in analyze_series8 to matched the case sensitivity.

Onder OnakI have been getting the following error:

Error using matlab.graphics.axis.Axes/set

Error setting property 'NextPlot' of class 'Axes':

'new' is not a valid value. Use one of these values: 'add' | 'replace' |

'replacechildren' | 'replaceall'.

Devin CortesLukas KortmannI have found a problem: With small-scale data, the sliders only produce slices at specific values with too big steps in between. This is reproducible by running the example, but scaling down the axes:

x = (-2:.2:2)/1000; y = (-2:.25:2)/1000; z = (-2:.16:2)./1000;

[X,Y,Z] = meshgrid(x,y,z);

v = X .* exp(-X.^2 - Y.^2 - Z.^2);

Appears in both R2014a and R2017b.

I don't understand the code well enough to find the cause, but I suspect there is a minimum stepsize defined somewhere.

Sarah FarthingI'm having problems with using this on R2018a.

Error using get

The ErrorMessage property has been removed. At the command line, use MException.last instead.

Error in sliceomatic (line 825)

disp(get(0,'errormessage'));

Error while evaluating Axes ButtonDownFcn.

and

Error using axes

Value must be a 1x2 vector of numeric type in which the second element is

larger than the first and may be Inf

Error in sliceomaticfigure (line 45)

d.axmain = axes('units','normal','pos',[.2 .2 .6 .6],'box','on',...

Error in sliceomatic (line 200)

d = sliceomaticfigure(d,xmesh,ymesh,zmesh);

mechECan I get a diagonal slice using it. All the three different vertices should join to make a diagonal surface

LucVery nice work!

Thank you.

The possibility to export a slice (cross-section) to a new figure window would be a nice addition. :-)

Siu Kei Lamworks in R2017a after following the modification suggested by Vinh Le-Van. Thanks all.

Hamidreza HeydarianDoes not work on R2014b and R2017a. I got this error:

Error using axes

Value must be a 1x2 vector of numeric type in which the second element is larger than the first and may be Inf

Error in sliceomaticfigure (line 54)

d.axmain = axes('units','normal','pos',[.2 .2 .6 .6],'box','on',...

Error in sliceomatic (line 203)

d = sliceomaticfigure(d);

bh dhouhabh dhouhaerror in sliceomaticmotion :(

peng sunthank U very much!

ilhem ouerghuidon't work in matlab2016b :(

VinhI got it work on R2016a following Justas and Rajiv sugesstion, with a minor modification. For the sake of completeness, I resume here:

1. Change in ~\private\sliceomaticfigure.m

Replacing

set(gcf,'nextplot','new');

set(gca,'nextplot','new');

with

set(gcf,'nextplot','add');

set(gca,'nextplot','add');

2. Change in ~\private\sliceomaticmotion.m

Replacing

d.motionmetaslice = line('parent',d.axmain,...

'vis','off',...

'linestyle','--',...

'marker','none',...

'linewidth',2,...

'erasemode','xor','clipping','off');

with

d.motionmetaslice = animatedline('parent',d.axmain,...

'vis','off',...

'linestyle','--',...

'marker','none',...

'linewidth',2,...

'clipping','off');

3. In ~\private\sliceomaticmotion.m

Replacing

set(d.motionmetaslice,'visible','on',...

'xdata',xdata,'ydata',ydata,'zdata',zdata);

with

addpoints(d.motionmetaslice,xdata,ydata,zdata);

drawnow

min liI haven't see any data in box windows, when I type the 'sliceomatic()' in the commond line.

why ?

maurizio fediI suggest the changes indicate by Justas, which allow the code to work in MATLAB 16b!!

Luca AmerioThe idea behind this piece of code is simply awesome. The code however need to be seriously adapted to the latest versions of MATLAB.

I spent one day trying to fix it, but still the changes required are deeply inside the code.

I would really love to see a new version working with MATLAB 2016b

Francesca TurcoIt doesn't show any data in the GUI, even using the examples provided in the source... At least not in matlab2016b. I tried changing the lines suggested by Rajiv but still nothing. It crashed my matlab session when I dragged the figure...

Francesca TurcoRajiv BoddedaFollowing Justas suggestion, I got it to work on R2016a

Change this in ~\private\sliceomaticfigure.m

set(gcf,'nextplot','new');

set(gca,'nextplot','new');

to

set(gcf,'nextplot','add');

set(gca,'nextplot','add');

go to ~\private\sliceomaticmotion.m

d.motionmetaslice = line('parent',d.axmain,...

'vis','off',...

'linestyle','--',...

'marker','none',...

'linewidth',2,...

'erasemode','xor','clipping','off');

and replace line with animatedline and remove the property erasemode (and option xor).

Finally, add this at the end:

addpoints(d.motionmetaslice,xdata,ydata,zdata);

drawnow

danielone badass app

crest Wanggood!

Abdur Rehmandhaba indiaZhouping weiwhen i run the example:

[x,y,z] = meshgrid(-2:.2:2, -2:.25:2, -2:.16:2);

v = x .* exp(-x.^2 - y.^2 - z.^2);

sliceomatic(v)

I got following message:

Warning: The EraseMode property is no longer supported and will error in a future release. Use the ANIMATEDLINE function for animating lines and

points instead of EraseMode 'none'. Removing instances of EraseMode set to 'normal', 'xor', and 'background' has minimal impact.

> In sliceomatic\private\sliceomaticmotion at 30

and just coordinate axes but no contents shown. I'm running on matlab R2014b

kai liLukas KortmannIf you want to slice surface data in the form of z(x,y) instead of volumetric data in the form of v(x,y,z) like sliceomatic expects, you can convert it like this (with 2 z values z1 and z2, they get dummy values so you can see them in the volume):

% normalise z on [1:resolution]

z1norm = round( (z1-min(min(z1)))/(max...(max(z1))-min(min(z1))) * (resolution-1) + 1 );

z2norm = round( (z2-min(min(z2)))/(max...(max(z2))-min(min(z2))) * (resolution-1) + 1);

v = zeros...(resolution,resolution,resolution);

for y = 1:resolution

for x = 1:resolution

v(x,y,1:z1norm(x,y)) = 0.5;

v(x,y,1:z2norm(x,y)) = ...

v(x,y,1:z2norm(x,y)) + 1;

end

end

sliceomatic(v)

Lukas KortmannAndrea LibriYaroslavawesome!

Yilun GongFetenDear all,

I am using on matlab R2015b Linux mint.

Could you help me to avoid this error:

Reference to non-existent field 'toolbar'.

Error in figmenus>OverrideStickyUserPreferences (line 449)

set(d.toolbar,'visible',prefs.anntoolbar_Checked)

Error in figmenus (line 105)

d = OverrideStickyUserPreferences(d);

Error in sliceomaticfigure (line 136)

d = figmenus(d);

Error in sliceomatic (line 203)

d = sliceomaticfigure(d);

Error in analyze_series8 (line 69)

sliceomatic(double(D))

JustasGot it to work on R2015a by:

changing (in ~\private\sliceomaticfigure.m)

set(gcf,'nextplot','new');

set(gca,'nextplot','new');

to

set(gcf,'nextplot','add');

set(gca,'nextplot','add');

and replacing (in ~\private\sliceomaticmotion.m)

d.motionmetaslice = line('parent',d.axmain,...

'vis','off',...

'linestyle','--',...

'marker','none',...

'linewidth',2,...

'erasemode','xor','clipping','off');

with

d.motionmetaslice = line('parent',d.axmain,...

'vis','off',...

'linestyle','--',...

'marker','none',...

'linewidth',2,...

'delete','true','clipping','off');

'erasemode' was giving errors, 'xor' was giving error when closing window.

The program is 5/5!

Thalles LeiteThanks for the code, it's exactly what I was searching for, but I had the same problem as Alex.

"Error using matlab.graphics.axis.Axes/set

While setting the 'NextPlot' property of Axes:

'new' is not a valid value. Use one of these values: 'add' | 'replace' | 'replacechildren'."

Am I doing something wrong?

Conlan KirkPrecisely what I needed, similar to FEA and CFD volume plots. Would be nice if you could do a volume cut (where the cut would show the volume below/above a certain value) in addition to the surface cut, but it works for showing the sensitivity of my function to the input variables. Excellent work.

AlexWhile running the example:

[x,y,z] = meshgrid(-2:.2:2, -2:.25:2, -2:.16:2);

v = x .* exp(-x.^2 - y.^2 - z.^2);

sliceomatic(v)

I receive all these errors:

Error using matlab.graphics.axis.Axes/set

While setting the 'NextPlot' property of Axes:

'new' is not a valid value. Use one of these values: 'add' | 'replace' | 'replacechildren'.

Error in sliceomaticfigure (line 162)

set(gca,'nextplot','new');

Error in sliceomatic (line 203)

d = sliceomaticfigure(d);

Reference to non-existent field 'motionmetaslice'.

Error in sliceomaticmotion (line 29)

if isempty(d.motionmetaslice)

Error while evaluating Figure WindowButtonMotionFcn

Reference to non-existent field 'motionmetaslice'.

Error in sliceomaticmotion (line 29)

if isempty(d.motionmetaslice)

Error while evaluating Figure WindowButtonMotionFcn

Reference to non-existent field 'motionmetaslice'.

Error in sliceomaticmotion (line 29)

if isempty(d.motionmetaslice)

Error while evaluating Figure WindowButtonMotionFcn

Reference to non-existent field 'motionmetaslice'.

if isempty(d.motionmetaslice)

Error while evaluating Figure WindowButtonMotionFcn

Reference to non-existent field 'motionmetaslice'.

if isempty(d.motionmetaslice)

Error while evaluating Figure WindowButtonMotionFcn

Reference to non-existent field 'motionmetaslice'.

if isempty(d.motionmetaslice)

Error while evaluating Figure WindowButtonMotionFcn

Reference to non-existent field 'motionmetaslice'.

if isempty(d.motionmetaslice)

Error while evaluating Figure WindowButtonMotionFcn

Reference to non-existent field 'motionmetaslice'.

if isempty(d.motionmetaslice)

Error while evaluating Figure WindowButtonMotionFcn

Reference to non-existent field 'motionmetaslice'.

if isempty(d.motionmetaslice)

Error while evaluating Figure WindowButtonMotionFcn

Reference to non-existent field 'motionmetaslice'.

if isempty(d.motionmetaslice)

Error while evaluating Figure WindowButtonMotionFcn

DGMsorry about the one-star.

if i could take it back, i would.

DGMDGMjesus this site is broken.

anyway, i was just trying to give a good review but can't seem to get that across.

SHERRYcool

Rey Kelvin PeraltaI am new in matlab. How do i use sliceomatic? how to install? where in matlab folder do i extract?

Peng DaiInesVery useful. Thank you.

I would like to change the color scale of the 3D plot, which normally uses the max,min values of the plotted dataset. I managed to change the range of values in the colorbar by modifying the function "isocontrols.m", however it does not seem to apply to the 3D plot it self.

Thanks in advance for your help and suggestions.

sarathanks

it is very helpful

lauraGreat application! Just one question: how can I export also the colour bar, e.g. if I want to modify the writings on the figure and save it in .eps format?

jerryvery dramatic contribution!

RifatVery helpful and easy to use application. Just put your 3D grid and you are good to go!

Emmanuel FarhiAbsolutely marvelous contribution.

Sneha NidhiVery Helpful

Sneha Nidhizhang zhenuseful!

leilaHow can I see the black voxel in the volume, all the zero-value voxels are invisible! :(, please guide me, thanks.

felixhi,

my variable v equals 50x50x50 dimension with values for each point. I just plotted

sliceomatic1p0(v);

the whole sliceomatic tool, which is great-thx a lot-, showed up except my variable v with datas. the dice was empty. did i do smth wrong?

moha softi am a bignner

wang ning??? Undefined function or method 'sliceomatic' for input arguments of type 'uint8'. what's wrong? how to solve it?

ning thanks

Alex GoughJacob KirkensgaardI have a problem with sliceomatic on OSX 10.6.2, matlab v. 7.10.0 (R2010a). When I start up the program I am in cursor mode and am able to control the slice buttons etc., but if I go to rotate-mode I can't get back to cursor-mode - the little arrow is simply missing from the annotation toolbar... Or am I missing something?

Harinee A.Scan anyone tell me how this works.. can we import images in this..

Edgar GuevaraReally nice job!

poornimai have some dicom images. can anyone tell me how can i view these dicom images?

ucd puriseems nie, i will try to ue it

neftirini isabelcan someone help me, with how do i call it on matlab...i am a new user, and i didnt manage to add it to the toolbox...

Jim Harasi have a series of mri silces, dicom files , and i want to import them. is this possible? if so, a little how-to guide would certainly be appreciated.

Chau Tran KimWonderful

Liu Xuefengexcellent

Ruwan Ranaweeragreat work!

andi setiawanvery good

vinay paiJohn FranklinFantastic work! This is pretty slick. I was going to complain about the interface taking up too much room, but then I noticed the option to remove interface visibility and the ability to copy to a "clean" figure. Really nice.

Yashavantha BSvery useful tool..

Dinesh Appyauseful tool for volume data

Daniel Simões-LopesAlthogth it's not bug-free, suits me well!

A very nice GUI application for volume visualization.

Vinay Dvery useful

Matt CremaReally great interactive tool for quick exploration of volume data.

Thanks.

Nick ClarkFDTD sorry - long day :)

Nick ClarkThis is awsome! Helping me no end with FTDT acoustic simulation

Mirza KamaludeenThis is an excellent tool, which can be used to compare results obtained from sterelogy

Larry VelascoThanks to the Sliceomatic people.. This software is great, it has helped me a lot for my PHD, where I have been working with FEM aand FDTD ... I now can visualise all my 3D data in a very good way..

Thanks a lot,

Vinay DVery handy

Jesper PedersenI have to re-rate this piece of software. It is fantastic, and in a newer version it is in fact possible to use the actual coordinates of the data.

Jesper PedersenNice GUI and program. However, it is very, very annoying that one cannot use the actual coordinates of the data.

Fu-Sung WangI'm impressed by this great demonstration.

Shira RubinThis is a fantastic tool!

But - how is it possible to use the actual coordinates of the data? This would really make it perfect.

senthil kumarIT IS VERY USFULL FOR ALL SIMULATION PURPOSE

Krishnakumar VenkateswaranThis is a great tool. Excellent tool for people like me who work on confocal imaging. Works for me without any problem.

Binevia karolygreat but all the time crashes, that's unbeliveble, the author should try harder...

Torbjørn HergumA great tool - for as long as it works. It frequently crashes matlab with a "segmentation fault". I'm running matlab on Linux RedHat 9.

Andreas LoeschGreat :)

one wish: show the gradient in the field (quiverplot or something like that)

@Jimmy -> the right mouse button on the Arrow is your frient

Jimmy PagelGreat code!

just one request: can you please add a way

to remove a slice as well.

Marco CannellaFantastic. You can analize 3D data in a fast and simple way.

Gordon CooperThis is excellent ! We have incorporated it into our geophysics teaching.

Adam van EekerenNice tool to look at 3D-data!

Only one concern: it is possible to place a slice controller outside a slice...by doing that, it is not possible to remove it anymore!

Dhaval Shahvery good tool.

maurizio fediFantastic tool to manage 3D data.

only a problem: why one cannot use actual coordinates?

Peter Kraalvery nice tool! very handy for soil profiles I must say. too bad axis dimensions are hard to edit. tip: for good isosurfaces, replace all 'unwanted' values with the same value.

ChrisA VERY nice tool for quickly surveying a 3-d dataset.

I found the interface intuitive as well. One question though...Am I missing a way to remove slices from the display once they are created?

Gexcellent, especially due to lack of alternatives.

Evan WestwoodExcellent way to look at 3-D data and a great template for learning about how to image 3-D data in Matlab. Note that right-clicking on arrows or surfaces to get the contextmenu options only works if you have nothing checked in the uppermost section of the figure's Tools menu.

James HalmerI dont understand it

Peter Volegov