File Exchange

## Sliceomatic

version 1.1.0.1 (35.7 KB) by
Volume slice visualization gui

Updated 01 Sep 2016

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.

### Cite As

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

Tobias Weingärtner

So here is a hint, for all absolute beginners on matlab like me :-)

to prepare a user-defined number of "2D -images"/"2D-matrices" as a 3D-dataset to view it with sliceomatic
I now used the "cat" command.

to arrange multiple 2D matrices along the third dimension and store it in the variable "v1":
v1 = cat(3,A1,A2,A3,...,An)

then to plot it in slicomatic use the command:
sliceomatic(v1)

This is certainly just one possibility to get a 3D dataset out of single 2D data, but it is the first which I find out by reading the documentation.

https://de.mathworks.com/help/matlab/ref/double.cat.html?s_tid=srchtitle

Tobias Weingärtner

The showed functions of slicomatic are perfectly match my needs for the data analysis in my field.
But I'm a bleeding beginner with matlab. So I hope I get some help from here.
In the lab I can generate elemental maps (exportable as 2D "grayscale" matrix).
I do this for diffrent layers of my sample while I shoot it with a Ar-Ionbeam.
So we get a 2D matrix for example every 10nm in depth.
Now I want to recombinate for example ten 2D matrices (256x256 pixels) to a 3D voxles stack.
Then import or plot it into the slicomatic an analyze the data, generate new slices out of that recombinated 3D dataset.

I use R2020b.
Slicomatic starts without erros by following the steps below, and a small change by myself.
I have imported the 2D data as "256x256 double" in my workspace.
But at this point I stucked.

in the files there is a hint: But that don't really help me
"
% Customized Graphics:
% -------------------
%
% that may be, you can use the following technique:
%
% 1) click on a control arrow
% 2) use gco to get the data for that object
% slice = getappdata(gco,'arrowslice')
% 3) use GET to get the cdata and position data which you can use

A step by step data import howto would be perfect for a newbie like me :-)

Elena Novoselova

Mulu Beka

hello, I am 5th year biomedical engineering student and now I am doing my research on image processing .So, is there any one who tell me about how to calculate the volume of gray matter and white matter of brain mri image?

alok dhaundiyal

Thanks, mate

Duncan L

For 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 L

For 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 Gasimov

Daniel Theobald

For 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 Gourianov

Follow 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 Idriss

Hello 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'));

Can someone help me !!

Eric Peterson

Li Chen

take the advice of Vinh and now the program works for R2018a

Ollie Helps

How do I import an stl?

Eze Ahanonu

Note 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 Onak

I 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 Cortes

Lukas Kortmann

I 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 Farthing

I'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);

mechE

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

Luc

Very nice work!
Thank you.

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

Siu Kei Lam

works in R2017a after following the modification suggested by Vinh Le-Van. Thanks all.

Hamidreza Heydarian

Does 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 dhouha

bh dhouha

error in sliceomaticmotion :(

peng sun

thank U very much!

ilhem ouerghui

don't work in matlab2016b :(

Vinh

I 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

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
drawnow

min li

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

maurizio fedi

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

Luca Amerio

The 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 Turco

It 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 Turco

Rajiv Boddeda

Following Justas suggestion, I got it to work on R2016a

Change this in ~\private\sliceomaticfigure.m

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

to

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:

drawnow

daniel

crest Wang

good!

Abdur Rehman

dhaba india

Zhouping wei

when 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 li

Lukas Kortmann

If 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 Kortmann

Andrea Libri

Yaroslav

awesome!

Yilun Gong

Feten

Dear all,
I am using on matlab R2015b Linux mint.
Could you help me to avoid this error:
Reference to non-existent field 'toolbar'.

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

d = OverrideStickyUserPreferences(d);

Error in sliceomaticfigure (line 136)

Error in sliceomatic (line 203)
d = sliceomaticfigure(d);

Error in analyze_series8 (line 69)
sliceomatic(double(D))

Justas

Got it to work on R2015a by:

changing (in ~\private\sliceomaticfigure.m)

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

to

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 Leite

Thanks 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 Kirk

Precisely 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.

Alex

While 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)

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'.

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'.

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'.

Error in sliceomaticmotion (line 29)
if isempty(d.motionmetaslice)

Error while evaluating Figure WindowButtonMotionFcn

DGM

if i could take it back, i would.

DGM

DGM

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

SHERRY

cool

Rey Kelvin Peralta

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

Peng Dai

Ines

Very 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.

sara

thanks

laura

Great 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?

jerry

very dramatic contribution!

Rifat

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

Emmanuel Farhi

Absolutely marvelous contribution.

Sneha Nidhi

Sneha Nidhi

zhang zhen

useful!

leila

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

felix

hi,
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 soft

i 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 Gough

Jacob Kirkensgaard

I 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.S

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

Edgar Guevara

Really nice job!

poornima

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

ucd puri

seems nie, i will try to ue it

neftirini isabel

can 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 Haras

i 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 Kim

Wonderful

Liu Xuefeng

excellent

Ruwan Ranaweera

great work!

andi setiawan

very good

vinay pai

John Franklin

Fantastic 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 BS

very useful tool..

Dinesh Appya

useful tool for volume data

Daniel Simões-Lopes

Althogth it's not bug-free, suits me well!
A very nice GUI application for volume visualization.

Vinay D

very useful

Matt Crema

Really great interactive tool for quick exploration of volume data.

Thanks.

Nick Clark

FDTD sorry - long day :)

Nick Clark

This is awsome! Helping me no end with FTDT acoustic simulation

Mirza Kamaludeen

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

Larry Velasco

Thanks 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 D

Very handy

Jesper Pedersen

I 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 Pedersen

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

Fu-Sung Wang

I'm impressed by this great demonstration.

Shira Rubin

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

senthil kumar

IT IS VERY USFULL FOR ALL SIMULATION PURPOSE

Krishnakumar Venkateswaran

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

Binevia karoly

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

Torbjørn Hergum

A 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 Loesch

Great :)
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 Pagel

Great code!
to remove a slice as well.

Marco Cannella

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

Gordon Cooper

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

Nice 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 Shah

very good tool.

maurizio fedi

Fantastic tool to manage 3D data.
only a problem: why one cannot use actual coordinates?

Peter Kraal

very 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.

Chris

A 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?

G

excellent, especially due to lack of alternatives.

Evan Westwood

Excellent 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 Halmer

I dont understand it

Peter Volegov

##### MATLAB Release Compatibility
Created with R14SP1
Compatible with any release
##### Platform Compatibility
Windows macOS Linux