Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
GUI imshow and Slider

Subject: GUI imshow and Slider

From: Jonas Bota

Date: 4 Apr, 2008 08:51:03

Message: 1 of 9

Hi
I am trying to visualize MRI image in matlab gui. I
designed it and have got images as I wished. I have one
sliders with max value is 6 for six slices of image.
My problem is how and where can I call the slider function
that can change current image slice to the image that fits
the current slider value?

Thanks Jonas

Subject: GUI imshow and Slider

From: Vihang Patil

Date: 4 Apr, 2008 11:43:02

Message: 2 of 9

"Jonas Bota" <bekaluyirdan@yahoo.com> wrote in message
<ft4q5n$1of$1@fred.mathworks.com>...
> Hi
> I am trying to visualize MRI image in matlab gui. I
> designed it and have got images as I wished. I have one
> sliders with max value is 6 for six slices of image.
> My problem is how and where can I call the slider
function
> that can change current image slice to the image that
fits
> the current slider value?
>
> Thanks Jonas

Hello
I think this submission on the FEX fits your requirement
http://www.mathworks.com/matlabcentral/fileexchange/loadFil
e.do?objectId=2256&objectType=file

HTH
Vihang

Subject: GUI imshow and Slider

From: ImageAnalyst

Date: 5 Apr, 2008 00:34:53

Message: 3 of 9

On Apr 4, 4:51=A0am, "Jonas Bota" <bekaluyir...@yahoo.com> wrote:
> Hi
> I am trying to visualize MRI image in matlab gui. I
> designed it and have got images as I wished. I have one
> sliders with max value is 6 for six slices of image.
> My problem is how and where can I call the slider function
> that can change current image slice to the image that fits
> the current slider value?
>
> Thanks Jonas

Jonas:
In GUIDE, right click on the slider, and select the item that says to
view the callback function. It will put you into the macro source
code editor. In that function it will tell you how to get the value
of the slider. You have to convert this number into a slice number
for your volume image. Then you have to pass this number into another
function that will read and display the slice, e.g. something like
DisplaySlice(fullFileName, sliceNumber);
or
DisplaySlice(image3DArray, sliceNumber)
That function (which you need to write) should display the selected
slice in an axes in your GUIDE figure.
Post back if you still don't understand.
Regards,
ImageAnalyst

Subject: GUI imshow and Slider

From: Jonas Bota

Date: 8 Apr, 2008 13:22:42

Message: 4 of 9


Hi ImageAnalys

Hi
I have two axes one for modulus( magnitude) image if image
type==0 and the other to velocity(phase) image……
When I assign slider values both for slice and phase
sliders it is possible to plot the images. But I want Gui
automatically change the slice and the phase when the user
pushes and use the current slider value. How and where
can I call my current sliders value?
I hope you understand my Q
Jonas

My slider call back functions assigned like this
function slice_slider_Callback(hObject, eventdata, handles)
sliceNumber = get(hObject,'Value')
and the same to phase_ slider_callback
phaseNumber = get(hObject,'Value')

% My data from inputFiles_listbox after almost processed
for k=1: sliceNumber*phasePhaseNumber*2 ;
    if (dataRL(k).image_type == 0)
        data_magnitudeRL(:,:,dataRL(k).phase,dataRL
(k).slice) = dataRL(k).data';
    else
        data_phaseRL(:,:,dataRL(k).phase,dataRL(k).slice) =
dataRL(k).data';
    end
end

%m= 100;
  m = sliceNumber*PhaseNumber
magnitude_imageRL = data_magnitudeRL(:,:,m);
magnitudeImage = abs(magnitude_imageRL./max
(magnitude_imageRL(:)));
handles.magnitudeImage = magnitudeImage;
 image_phaseRL = data_phaseRL(:,:,m);
 phaseImageRL = (image_phaseRL./max(image_phaseRL(:)));
 handles.phaseImageRL = phaseImageRL;
 %
clc;
% magnitude image on first axes
axes(handles.axes1);%gives focus to first axes
imshow(handles.magnitudeImage);
colormap(gray);
zoom on;

% velocity or phase image on the second axes
handles.current_data = handles.phaseImageRL;
axes(handles.axes2);%gives focus to second axes
 imshow(handles.current_data,[]);
 colormap(gray);
 zoom on;


ImageAnalyst <imageanalyst@mailinator.com> wrote in message
<996880bd-c746-44d5-b4c3-
bb7bfbac21db@f63g2000hsf.googlegroups.com>...
> On Apr 4, 4:51=A0am, "Jonas Bota"
<bekaluyir...@yahoo.com> wrote:
> > Hi
> > I am trying to visualize MRI image in matlab gui. I
> > designed it and have got images as I wished. I have one
> > sliders with max value is 6 for six slices of image.
> > My problem is how and where can I call the slider
function
> > that can change current image slice to the image that
fits
> > the current slider value?
> >
> > Thanks Jonas
>
> Jonas:
> In GUIDE, right click on the slider, and select the item
that says to
> view the callback function. It will put you into the
macro source
> code editor. In that function it will tell you how to
get the value
> of the slider. You have to convert this number into a
slice number
> for your volume image. Then you have to pass this number
into another
> function that will read and display the slice, e.g.
something like
> DisplaySlice(fullFileName, sliceNumber);
> or
> DisplaySlice(image3DArray, sliceNumber)
> That function (which you need to write) should display
the selected
> slice in an axes in your GUIDE figure.
> Post back if you still don't understand.
> Regards,
> ImageAnalyst

Subject: GUI imshow and Slider

From: Jonas Bota

Date: 8 Apr, 2008 13:35:21

Message: 5 of 9


Hi ImageAnalys

Hi
I have two axes one for modulus( magnitude) image if image
type==0 and the other to velocity(phase) image……
When I assign slider values both for slice and phase
sliders it is possible to plot the images. But I want Gui
automatically change the slice and the phase when the user
pushes and use the current slider value. How and where
can I call my current sliders value?
I hope you understand my Q
Jonas

My slider call back functions assigned like this
function slice_slider_Callback(hObject, eventdata, handles)
sliceNumber = get(hObject,'Value')
and the same to phase_ slider_callback
phaseNumber = get(hObject,'Value')

% My data from inputFiles_listbox after almost processed
for k=1: sliceNumber*phasePhaseNumber*2 ;
    if (dataRL(k).image_type == 0)
        data_magnitudeRL(:,:,dataRL(k).phase,dataRL
(k).slice) = dataRL(k).data';
    else
        data_phaseRL(:,:,dataRL(k).phase,dataRL(k).slice) =
dataRL(k).data';
    end
end

%m= 100;
  m = sliceNumber*PhaseNumber
magnitude_imageRL = data_magnitudeRL(:,:,m);
magnitudeImage = abs(magnitude_imageRL./max
(magnitude_imageRL(:)));
handles.magnitudeImage = magnitudeImage;
 image_phaseRL = data_phaseRL(:,:,m);
 phaseImageRL = (image_phaseRL./max(image_phaseRL(:)));
 handles.phaseImageRL = phaseImageRL;
 %
clc;
% magnitude image on first axes
axes(handles.axes1);%gives focus to first axes
imshow(handles.magnitudeImage);
colormap(gray);
zoom on;

% velocity or phase image on the second axes
handles.current_data = handles.phaseImageRL;
axes(handles.axes2);%gives focus to second axes
 imshow(handles.current_data,[]);
 colormap(gray);
 zoom on;


ImageAnalyst <imageanalyst@mailinator.com> wrote in message
<996880bd-c746-44d5-b4c3-
bb7bfbac21db@f63g2000hsf.googlegroups.com>...
> On Apr 4, 4:51=A0am, "Jonas Bota"
<bekaluyir...@yahoo.com> wrote:
> > Hi
> > I am trying to visualize MRI image in matlab gui. I
> > designed it and have got images as I wished. I have one
> > sliders with max value is 6 for six slices of image.
> > My problem is how and where can I call the slider
function
> > that can change current image slice to the image that
fits
> > the current slider value?
> >
> > Thanks Jonas
>
> Jonas:
> In GUIDE, right click on the slider, and select the item
that says to
> view the callback function. It will put you into the
macro source
> code editor. In that function it will tell you how to
get the value
> of the slider. You have to convert this number into a
slice number
> for your volume image. Then you have to pass this number
into another
> function that will read and display the slice, e.g.
something like
> DisplaySlice(fullFileName, sliceNumber);
> or
> DisplaySlice(image3DArray, sliceNumber)
> That function (which you need to write) should display
the selected
> slice in an axes in your GUIDE figure.
> Post back if you still don't understand.
> Regards,
> ImageAnalyst

Subject: GUI imshow and Slider

From: Jonas Bota

Date: 8 Apr, 2008 13:39:34

Message: 6 of 9


Hi ImageAnalys

Hi
I have two axes one for modulus( magnitude) image if image
type==0 and the other to velocity(phase) image……
When I assign slider values both for slice and phase
sliders it is possible to plot the images. But I want Gui
automatically change the slice and the phase when the user
pushes and use the current slider value. How and where
can I call my current sliders value?
I hope you understand my Q
Jonas

My slider call back functions assigned like this
function slice_slider_Callback(hObject, eventdata, handles)
sliceNumber = get(hObject,'Value')
and the same to phase_ slider_callback
phaseNumber = get(hObject,'Value')

% My data from inputFiles_listbox after almost processed
for k=1: sliceNumber*phasePhaseNumber*2 ;
    if (dataRL(k).image_type == 0)
        data_magnitudeRL(:,:,dataRL(k).phase,dataRL
(k).slice) = dataRL(k).data';
    else
        data_phaseRL(:,:,dataRL(k).phase,dataRL(k).slice) =
dataRL(k).data';
    end
end

%m= 100;
  m = sliceNumber*PhaseNumber
magnitude_imageRL = data_magnitudeRL(:,:,m);
magnitudeImage = abs(magnitude_imageRL./max
(magnitude_imageRL(:)));
handles.magnitudeImage = magnitudeImage;
 image_phaseRL = data_phaseRL(:,:,m);
 phaseImageRL = (image_phaseRL./max(image_phaseRL(:)));
 handles.phaseImageRL = phaseImageRL;
 %
clc;
% magnitude image on first axes
axes(handles.axes1);%gives focus to first axes
imshow(handles.magnitudeImage);
colormap(gray);
zoom on;

% velocity or phase image on the second axes
handles.current_data = handles.phaseImageRL;
axes(handles.axes2);%gives focus to second axes
 imshow(handles.current_data,[]);
 colormap(gray);
 zoom on;


ImageAnalyst <imageanalyst@mailinator.com> wrote in message
<996880bd-c746-44d5-b4c3-
bb7bfbac21db@f63g2000hsf.googlegroups.com>...
> On Apr 4, 4:51=A0am, "Jonas Bota"
<bekaluyir...@yahoo.com> wrote:
> > Hi
> > I am trying to visualize MRI image in matlab gui. I
> > designed it and have got images as I wished. I have one
> > sliders with max value is 6 for six slices of image.
> > My problem is how and where can I call the slider
function
> > that can change current image slice to the image that
fits
> > the current slider value?
> >
> > Thanks Jonas
>
> Jonas:
> In GUIDE, right click on the slider, and select the item
that says to
> view the callback function. It will put you into the
macro source
> code editor. In that function it will tell you how to
get the value
> of the slider. You have to convert this number into a
slice number
> for your volume image. Then you have to pass this number
into another
> function that will read and display the slice, e.g.
something like
> DisplaySlice(fullFileName, sliceNumber);
> or
> DisplaySlice(image3DArray, sliceNumber)
> That function (which you need to write) should display
the selected
> slice in an axes in your GUIDE figure.
> Post back if you still don't understand.
> Regards,
> ImageAnalyst

Subject: GUI imshow and Slider

From: ImageAnalyst

Date: 8 Apr, 2008 16:17:06

Message: 7 of 9

On Apr 8, 9:35 am, "Jonas Bota" <bekaluyir...@yahoo.com> wrote:
> Hi ImageAnalys
>
> Hi
> I have two axes one for modulus( magnitude) image if image
> type==0 and the other to velocity(phase) image......
> When I assign slider values both for slice and phase
> sliders it is possible to plot the images. But I want Gui
> automatically change the slice and the phase when the user
> pushes and use the current slider value. How and where
> can I call my current sliders value?
> I hope you understand my Q
> Jonas
>
> My slider call back functions assigned like this
> function slice_slider_Callback(hObject, eventdata, handles)
> sliceNumber = get(hObject,'Value')
> and the same to phase_ slider_callback
> phaseNumber = get(hObject,'Value')
>
> % My data from inputFiles_listbox after almost processed
> for k=1: sliceNumber*phasePhaseNumber*2 ;
> if (dataRL(k).image_type == 0)
> data_magnitudeRL(:,:,dataRL(k).phase,dataRL
> (k).slice) = dataRL(k).data';
> else
> data_phaseRL(:,:,dataRL(k).phase,dataRL(k).slice) =
> dataRL(k).data';
> end
> end
>
> %m= 100;
> m = sliceNumber*PhaseNumber
> magnitude_imageRL = data_magnitudeRL(:,:,m);
> magnitudeImage = abs(magnitude_imageRL./max
> (magnitude_imageRL(:)));
> handles.magnitudeImage = magnitudeImage;
> image_phaseRL = data_phaseRL(:,:,m);
> phaseImageRL = (image_phaseRL./max(image_phaseRL(:)));
> handles.phaseImageRL = phaseImageRL;
> %
> clc;
> % magnitude image on first axes
> axes(handles.axes1);%gives focus to first axes
> imshow(handles.magnitudeImage);
> colormap(gray);
> zoom on;
>
> % velocity or phase image on the second axes
> handles.current_data = handles.phaseImageRL;
> axes(handles.axes2);%gives focus to second axes
> imshow(handles.current_data,[]);
> colormap(gray);
> zoom on;
>
> ImageAnalyst <imageanal...@mailinator.com> wrote in message
>
> <996880bd-c746-44d5-b4c3-
> bb7bfbac2...@f63g2000hsf.googlegroups.com>...
>
>
>
> > On Apr 4, 4:51=A0am, "Jonas Bota"
> <bekaluyir...@yahoo.com> wrote:
> > > Hi
> > > I am trying to visualize MRI image in matlab gui. I
> > > designed it and have got images as I wished. I have one
> > > sliders with max value is 6 for six slices of image.
> > > My problem is how and where can I call the slider
> function
> > > that can change current image slice to the image that
> fits
> > > the current slider value?
>
> > > Thanks Jonas
>
> > Jonas:
> > In GUIDE, right click on the slider, and select the item
> that says to
> > view the callback function. It will put you into the
> macro source
> > code editor. In that function it will tell you how to
> get the value
> > of the slider. You have to convert this number into a
> slice number
> > for your volume image. Then you have to pass this number
> into another
> > function that will read and display the slice, e.g.
> something like
> > DisplaySlice(fullFileName, sliceNumber);
> > or
> > DisplaySlice(image3DArray, sliceNumber)
> > That function (which you need to write) should display
> the selected
> > slice in an axes in your GUIDE figure.
> > Post back if you still don't understand.
> > Regards,
> > ImageAnalyst- Hide quoted text -
>
> - Show quoted text -
-----------------------------------------------------------------------------------------
Jonas:
I'm not sure I understand your question because it looks like you
answered it yourself. You set the values in your callback function,
like you showed in the code. The callback functions get called
everytime someone interacts with the sliders. Then you use the values
in code elsewhere, again, like you showed. So what's the question?
Are you unsure of how to get the values out of the callback functions
so that other functions can use them? The GUI automatically calls the
callback function, and your code in there sets the vaiables, so your
statement "But I want Gui automatically change the slice and the phase
when the user pushes and use the current slider value." is being done
- so no problem there. Then you state "How and where can I call my
current sliders value?" but you show code where you're doing exactly
that. So again, all I can think is that you don't know how to get the
values out of the callback function. Is that correct? If so, you can
use handles, a UserData property, or global, or maybe some other ways.

Regards,
ImageAnalyst

Subject: GUI imshow and Slider

From: Jonas Bota

Date: 9 Apr, 2008 08:00:18

Message: 8 of 9

ImageAnalyst <imageanalyst@mailinator.com> wrote in message
<e1caa0d1-b8d0-49f4-980e-
c86e2e038a46@l42g2000hsc.googlegroups.com>...
> On Apr 8, 9:35 am, "Jonas Bota" <bekaluyir...@yahoo.com>
wrote:
> > Hi ImageAnalys
> >
> > Hi
> > I have two axes one for modulus( magnitude) image if
image
> > type==0 and the other to velocity(phase) image......
> > When I assign slider values both for slice and phase
> > sliders it is possible to plot the images. But I want
Gui
> > automatically change the slice and the phase when the
user
> > pushes and use the current slider value. How and where
> > can I call my current sliders value?
> > I hope you understand my Q
> > Jonas
> >
> > My slider call back functions assigned like this
> > function slice_slider_Callback(hObject, eventdata,
handles)
> > sliceNumber = get(hObject,'Value')
> > and the same to phase_ slider_callback
> > phaseNumber = get(hObject,'Value')
> >
> > % My data from inputFiles_listbox after almost processed
> > for k=1: sliceNumber*phasePhaseNumber*2 ;
> > if (dataRL(k).image_type == 0)
> > data_magnitudeRL(:,:,dataRL(k).phase,dataRL
> > (k).slice) = dataRL(k).data';
> > else
> > data_phaseRL(:,:,dataRL(k).phase,dataRL
(k).slice) =
> > dataRL(k).data';
> > end
> > end
> >
> > %m= 100;
> > m = sliceNumber*PhaseNumber
> > magnitude_imageRL = data_magnitudeRL(:,:,m);
> > magnitudeImage = abs(magnitude_imageRL./max
> > (magnitude_imageRL(:)));
> > handles.magnitudeImage = magnitudeImage;
> > image_phaseRL = data_phaseRL(:,:,m);
> > phaseImageRL = (image_phaseRL./max(image_phaseRL(:)));
> > handles.phaseImageRL = phaseImageRL;
> > %
> > clc;
> > % magnitude image on first axes
> > axes(handles.axes1);%gives focus to first axes
> > imshow(handles.magnitudeImage);
> > colormap(gray);
> > zoom on;
> >
> > % velocity or phase image on the second axes
> > handles.current_data = handles.phaseImageRL;
> > axes(handles.axes2);%gives focus to second axes
> > imshow(handles.current_data,[]);
> > colormap(gray);
> > zoom on;
> >
> > ImageAnalyst <imageanal...@mailinator.com> wrote in
message
> >
> > <996880bd-c746-44d5-b4c3-
> > bb7bfbac2...@f63g2000hsf.googlegroups.com>...
> >
> >
> >
> > > On Apr 4, 4:51=A0am, "Jonas Bota"
> > <bekaluyir...@yahoo.com> wrote:
> > > > Hi
> > > > I am trying to visualize MRI image in matlab gui. I
> > > > designed it and have got images as I wished. I have
one
> > > > sliders with max value is 6 for six slices of image.
> > > > My problem is how and where can I call the slider
> > function
> > > > that can change current image slice to the image
that
> > fits
> > > > the current slider value?
> >
> > > > Thanks Jonas
> >
> > > Jonas:
> > > In GUIDE, right click on the slider, and select the
item
> > that says to
> > > view the callback function. It will put you into the
> > macro source
> > > code editor. In that function it will tell you how to
> > get the value
> > > of the slider. You have to convert this number into a
> > slice number
> > > for your volume image. Then you have to pass this
number
> > into another
> > > function that will read and display the slice, e.g.
> > something like
> > > DisplaySlice(fullFileName, sliceNumber);
> > > or
> > > DisplaySlice(image3DArray, sliceNumber)
> > > That function (which you need to write) should display
> > the selected
> > > slice in an axes in your GUIDE figure.
> > > Post back if you still don't understand.
> > > Regards,
> > > ImageAnalyst- Hide quoted text -
> >
> > - Show quoted text -
> ----------------------------------------------------------
-------------------------------
> Jonas:
> I'm not sure I understand your question because it looks
like you
> answered it yourself. You set the values in your
callback function,
> like you showed in the code. The callback functions get
called
> everytime someone interacts with the sliders. Then you
use the values
> in code elsewhere, again, like you showed. So what's the
question?
> Are you unsure of how to get the values out of the
callback functions
> so that other functions can use them? The GUI
automatically calls the
> callback function, and your code in there sets the
vaiables, so your
> statement "But I want Gui automatically change the slice
and the phase
> when the user pushes and use the current slider value."
is being done
> - so no problem there. Then you state "How and where
can I call my
> current sliders value?" but you show code where you're
doing exactly
> that. So again, all I can think is that you don't know
how to get the
> values out of the callback function. Is that correct?
If so, you can
> use handles, a UserData property, or global, or maybe
some other ways.
>
> Regards,
> ImageAnalyst

Hi ImageAnalyst

As I guess you understood my Q. The problem is when I try
to get value from call-back function for example
handles.sliceNumber = sliceNumber
handles.phaseNumber = phaseNumber
m = handles.sliceNumber *handles.phaseNumber
and push the start button to plot the image, I gets the
following error.

??? Reference to non-existent field 'sliceNumber'.

Error in ==> MRI_visualization>start_pushbutton_Callback at
301
  m = handles.sliceNumber*handles.phaseNumber

Error in ==> gui_mainfcn at 75
        feval(varargin{:});

Error in ==> MRI_visualization at 44
    gui_mainfcn(gui_State, varargin{:});

??? Error while evaluating uicontrol Callback.

How can solve it?
Thanks Jonas

Subject: GUI imshow and Slider

From: Jonas Bota

Date: 9 Apr, 2008 17:28:02

Message: 9 of 9

Hi ImageAnalyst

As I guess you understood my Q. The problem is when I try
to get value from call-back function for example
handles.sliceNumber = sliceNumber
handles.phaseNumber = phaseNumber
m = handles.sliceNumber *handles.phaseNumber
and push the start button to plot the image, I gets the
following error.

??? Reference to non-existent field 'sliceNumber'.

Error in ==> MRI_visualization>start_pushbutton_Callback at
301
  m = handles.sliceNumber*handles.phaseNumber

Error in ==> gui_mainfcn at 75
        feval(varargin{:});

Error in ==> MRI_visualization at 44
    gui_mainfcn(gui_State, varargin{:});

??? Error while evaluating uicontrol Callback.

How can solve it?
Thanks Jonas

"Jonas Bota" <bekaluyirdan@yahoo.com> wrote in message
<ftht2i$ltf$1@fred.mathworks.com>...
> ImageAnalyst <imageanalyst@mailinator.com> wrote in
message
> <e1caa0d1-b8d0-49f4-980e-
> c86e2e038a46@l42g2000hsc.googlegroups.com>...
> > On Apr 8, 9:35 am, "Jonas Bota"
<bekaluyir...@yahoo.com>
> wrote:
> > > Hi ImageAnalys
> > >
> > > Hi
> > > I have two axes one for modulus( magnitude) image if
> image
> > > type==0 and the other to velocity(phase) image......
> > > When I assign slider values both for slice and phase
> > > sliders it is possible to plot the images. But I want
> Gui
> > > automatically change the slice and the phase when the
> user
> > > pushes and use the current slider value. How and
where
> > > can I call my current sliders value?
> > > I hope you understand my Q
> > > Jonas
> > >
> > > My slider call back functions assigned like this
> > > function slice_slider_Callback(hObject, eventdata,
> handles)
> > > sliceNumber = get(hObject,'Value')
> > > and the same to phase_ slider_callback
> > > phaseNumber = get(hObject,'Value')
> > >
> > > % My data from inputFiles_listbox after almost
processed
> > > for k=1: sliceNumber*phasePhaseNumber*2 ;
> > > if (dataRL(k).image_type == 0)
> > > data_magnitudeRL(:,:,dataRL(k).phase,dataRL
> > > (k).slice) = dataRL(k).data';
> > > else
> > > data_phaseRL(:,:,dataRL(k).phase,dataRL
> (k).slice) =
> > > dataRL(k).data';
> > > end
> > > end
> > >
> > > %m= 100;
> > > m = sliceNumber*PhaseNumber
> > > magnitude_imageRL = data_magnitudeRL(:,:,m);
> > > magnitudeImage = abs(magnitude_imageRL./max
> > > (magnitude_imageRL(:)));
> > > handles.magnitudeImage = magnitudeImage;
> > > image_phaseRL = data_phaseRL(:,:,m);
> > > phaseImageRL = (image_phaseRL./max(image_phaseRL
(:)));
> > > handles.phaseImageRL = phaseImageRL;
> > > %
> > > clc;
> > > % magnitude image on first axes
> > > axes(handles.axes1);%gives focus to first axes
> > > imshow(handles.magnitudeImage);
> > > colormap(gray);
> > > zoom on;
> > >
> > > % velocity or phase image on the second axes
> > > handles.current_data = handles.phaseImageRL;
> > > axes(handles.axes2);%gives focus to second axes
> > > imshow(handles.current_data,[]);
> > > colormap(gray);
> > > zoom on;
> > >
> > > ImageAnalyst <imageanal...@mailinator.com> wrote in
> message
> > >
> > > <996880bd-c746-44d5-b4c3-
> > > bb7bfbac2...@f63g2000hsf.googlegroups.com>...
> > >
> > >
> > >
> > > > On Apr 4, 4:51=A0am, "Jonas Bota"
> > > <bekaluyir...@yahoo.com> wrote:
> > > > > Hi
> > > > > I am trying to visualize MRI image in matlab gui.
I
> > > > > designed it and have got images as I wished. I
have
> one
> > > > > sliders with max value is 6 for six slices of
image.
> > > > > My problem is how and where can I call the slider
> > > function
> > > > > that can change current image slice to the image
> that
> > > fits
> > > > > the current slider value?
> > >
> > > > > Thanks Jonas
> > >
> > > > Jonas:
> > > > In GUIDE, right click on the slider, and select the
> item
> > > that says to
> > > > view the callback function. It will put you into
the
> > > macro source
> > > > code editor. In that function it will tell you how
to
> > > get the value
> > > > of the slider. You have to convert this number
into a
> > > slice number
> > > > for your volume image. Then you have to pass this
> number
> > > into another
> > > > function that will read and display the slice, e.g.
> > > something like
> > > > DisplaySlice(fullFileName, sliceNumber);
> > > > or
> > > > DisplaySlice(image3DArray, sliceNumber)
> > > > That function (which you need to write) should
display
> > > the selected
> > > > slice in an axes in your GUIDE figure.
> > > > Post back if you still don't understand.
> > > > Regards,
> > > > ImageAnalyst- Hide quoted text -
> > >
> > > - Show quoted text -
> > --------------------------------------------------------
--
> -------------------------------
> > Jonas:
> > I'm not sure I understand your question because it
looks
> like you
> > answered it yourself. You set the values in your
> callback function,
> > like you showed in the code. The callback functions
get
> called
> > everytime someone interacts with the sliders. Then you
> use the values
> > in code elsewhere, again, like you showed. So what's
the
> question?
> > Are you unsure of how to get the values out of the
> callback functions
> > so that other functions can use them? The GUI
> automatically calls the
> > callback function, and your code in there sets the
> vaiables, so your
> > statement "But I want Gui automatically change the
slice
> and the phase
> > when the user pushes and use the current slider value."
> is being done
> > - so no problem there. Then you state "How and where
> can I call my
> > current sliders value?" but you show code where you're
> doing exactly
> > that. So again, all I can think is that you don't know
> how to get the
> > values out of the callback function. Is that correct?
> If so, you can
> > use handles, a UserData property, or global, or maybe
> some other ways.
> >
> > Regards,
> > ImageAnalyst
>
> Hi ImageAnalyst
>
> As I guess you understood my Q. The problem is when I
try
> to get value from call-back function for example
> handles.sliceNumber = sliceNumber
> handles.phaseNumber = phaseNumber
> m = handles.sliceNumber *handles.phaseNumber
> and push the start button to plot the image, I gets the
> following error.
>
> ??? Reference to non-existent field 'sliceNumber'.
>
> Error in ==> MRI_visualization>start_pushbutton_Callback
at
> 301
> m = handles.sliceNumber*handles.phaseNumber
>
> Error in ==> gui_mainfcn at 75
> feval(varargin{:});
>
> Error in ==> MRI_visualization at 44
> gui_mainfcn(gui_State, varargin{:});
>
> ??? Error while evaluating uicontrol Callback.
>
> How can solve it?
> Thanks Jonas
>
>

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us