📄 mia_gui.m
字号:
CurrentSlice = round(handles.scaninfo2.num_of_slice/2);
CurrentImgIdx = handles.scaninfo2.num_of_slice*(handles.scaninfo2.Frames-1)+CurrentSlice;
end
CurrentImage = ...
handles.imaVOL2(:,:,handles.scaninfo2.num_of_slice*(handles.scaninfo2.Frames-1)+CurrentSlice);
handles.VolMax2 = double(max(handles.imaVOL2(:)));
handles.VolMin2 = double(min(handles.imaVOL2(:)));
CurrentImageMinMax = [min(CurrentImage(:)) max(CurrentImage(:)) ];
if handles.scaninfo2.float % imaVOL type is float
handles.decimal_prec2 = 2;
else
handles.decimal_prec2 = 0;
end
%Create the RGB image
Initial_cmap = gray(handles.ColorRes);
CurrentImage_RGB = ...
CreateRGBImage(CurrentImage,CurrentImageMinMax,handles.ColorRes,Initial_cmap);
% set the figure renderer property to OPENGL enabling the transparency
set(handles.mia_figure1,'renderer','opengl');
handles.openglinfo.miafigure_useOpenGL = 1;
% inititate the ImaAxes figure
axes(handles.ImaAxes);
set(handles.hcb,'buttonDownFcn','mia_gui(''SetImageContrast'',gcbo,[],guidata(gcbo))');
hold on;
% show the image
ImaHandler = image(CurrentImage_RGB);
% if image format (x*y) of imaVOl is not equal to imaVOL2 then
% the images of imaVOL2 has to fit to the previously generated imaVOL's image
if handles.scaninfo2.imfm(1) ~= handles.scaninfo.imfm(1)
set(ImaHandler,'XData',[1 handles.scaninfo.imfm(1)]);
set(ImaHandler,'YData',[1 handles.scaninfo.imfm(2)]);
end
handles.ImaHandler2 = ImaHandler;
set(handles.ImaHandler2,'Tag','MainImage2');
% set the transparency
set(ImaHandler,'AlphaData',0.5);
%Create the initial colorbar
col=Initial_cmap;
r=col(:,1);g=col(:,2);b=col(:,3);
CMapImgRes=[1:handles.ColorRes];
CMapImg=cat(3,r(CMapImgRes),g(CMapImgRes),b(CMapImgRes));
axes(handles.Cmap2Axes);
set(handles.Cmap2Axes,'visible','on');
hcb = image(CMapImg);
handles.hcb2 = hcb;
set(handles.hcb2,'tag','ColorbarImage2');
set(handles.Cmap2Axes,'Xticklabel',{});
set(handles.Cmap2Axes,'Ydir','normal');
set(handles.Cmap2Axes,'YaxisLocation','right');
Yticks = linspace(0,handles.ColorRes,5);
set(handles.Cmap2Axes,'Ytick',Yticks);
set(handles.Cmap2Axes,'Yticklabel',num2cell(Yticks));
%set(handles.Cmap2Axes,'Ylim',[0 64]);
handles.NumOfYtickOfColorbar2 = length(get(handles.Cmap2Axes,'Yticklabel'));
hold on;
handles.ColormapIn2 = Initial_cmap;
newlabels = num2cell(round(linspace(handles.VolMin2,handles.VolMax2,handles.NumOfYtickOfColorbar2)))';
set(handles.Cmap2Axes,'Yticklabel',newlabels);
handles.CurrentSlice2 = CurrentSlice;
handles.CurrentFrame2 = handles.scaninfo2.Frames;
handles.CurrentImgIdx2 = CurrentImgIdx;
set(handles.CurrentFrameEdit,'String',handles.CurrentFrame2);
set(handles.CurrentSliceEdit,'String',handles.CurrentSlice2);
% initiate the ColorBar Sliders
set(handles.ColorBarMax2Slider,'Min',handles.VolMin2);
set(handles.ColorBarMax2Slider,'Max',handles.VolMax2);
set(handles.ColorBarMin2Slider,'Min',handles.VolMin2);
set(handles.ColorBarMin2Slider,'Max',handles.VolMax2);
set(handles.ColorBarMax2Slider,'Value',CurrentImageMinMax(2));
set(handles.ColorBarMin2Slider,'Value',CurrentImageMinMax(1));
%initiate the Transparency Sliders
set(handles.TransparencySlider,'Min',0);
set(handles.TransparencySlider,'Max',1);
set(handles.TransparencySlider,'Value',0.5);
% Update handles structure
guidata(hObject, handles);
% initiate the mia_pixval function
%mia_pixval(handles.ImaHandler,'on');
% --------------------------------------------------------------------
function Open2DICOMDIRmain_Callback(hObject, eventdata, handles)
% hObject handle to Open2DICOMDIRmain (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Open2DICOMDIRfromNew_Callback(hObject, eventdata, handles)
% hObject handle to Open2DICOMDIRfromNew (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Open2DICOMDIRfromCurrent_Callback(hObject, eventdata, handles)
% hObject handle to Open2DICOMDIRfromCurrent (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function CloseImagesMenuItem_Callback(hObject, eventdata, handles)
% hObject handle to CloseImagesMenuItem (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if isfield(handles,'FileNames')
handles = ClearImages(handles);
% Update handles structure
guidata(hObject, handles);
end
% ------------------------------------
%--------------------------------
function handlesout = ClearImages(handles,clear_option)
% clear the all image and variable on the main gui
%
%if 3Dcursor is being opened
if get(handles.ThreeDcursortogglebutton,'value')
delete(handles.D3CursorFigData.FigHandlerX);
delete(handles.D3CursorFigData.FigHandlerY);
delete(handles.D3CursorFigData.FigHandlerZ);
handles = rmfield(handles,'D3CursorFigData');
%set(handles.ThreeDcursor2togglebutton,'enable','on');
end
if isfield(handles,'FileNames')
if nargin == 1
clear_option = 0;
end
% delete ROI lines if exists and refresh the handle
for i =1: handles.scaninfo(1).num_of_slice
for j=1:handles.ROINumOfColor
if ~isempty(handles.ROI(i,j).BW )
handles.ROI(i,j).BW = [];
handles.ROI(i,j).xi = [];
handles.ROI(i,j).yi = [];
delete(handles.Lines(i,j).lh);
handles.Lines(i,j).lh = [];
end
end
end
% delete the TAC values for VOIs
for j=1:handles.ROINumOfColor
handles.VOI(j).tac = [];
handles.VOI(j).tacstd = [];
handles.VOI(j).tacmin = [];
handles.VOI(j).tacmax = [];
handles.VOI(j).tacvolume = [];
end
% DeleteAllROIMenuItem_Callback(handles.mia_figure1, [], handles);
% current_appdata = getappdata(handles.mia_figure1);
% handles = current_appdata.UsedByGUIData_m;
% delete the pixvalbar, the image and the colorbar
mia_pixval(handles.ImaHandler,'off');
if clear_option == 1;
% clear_option = 1 corresponds
% the "clear" before interpolation
guidata(handles.mia_figure1, handles);
handlesout = handles;
set(handles.hcb,'buttonDownFcn','mia_gui(''SetImageContrast'',gcbo,[],guidata(gcbo))');
return;
end
delete(handles.ImaHandler);
delete(handles.hcb);
% delete the most important fields
handles = rmfield(handles,'ImaHandler');
handles = rmfield(handles,'FileNames');
handles = rmfield(handles,'imaVOL');
handles = rmfield(handles,'scaninfo');
handles = rmfield(handles,'hcb');
if(isfield(handles,'inputpath'));
handles = rmfield(handles,'inputpath');
end
set(handles.CmapAxes,'visible','off');
set(handles.ImaListbox,'string',{});
end
% delete the most important fields for the 2.file
if (isfield(handles,'FileNames2'))
delete(handles.ImaHandler2);
delete(handles.hcb2);
handles = rmfield(handles,'ImaHandler2');
handles = rmfield(handles,'FileNames2');
handles = rmfield(handles,'imaVOL2');
handles = rmfield(handles,'scaninfo2');
handles = rmfield(handles,'hcb2');
set(handles.Cmap2Axes,'visible','off');
set(handles.ImaList2box,'string',{});
end
% "clear" the ImageAxes and input boxes
axes(handles.ImaAxes);
hold off;
image(zeros(256,256,3));
axis off;
set(handles.RenderingLevelEdit,'String',[]);
set(handles.RenderingLevel2Edit,'String',[]);
set(handles.CurrentFrameEdit,'String',[]);
set(handles.CurrentSliceEdit,'String',[]);
% turn off the Frametime and framelength info boxes
set(handles.CurrentFrameLengthEdit,'visible','off');
set(handles.CurrentFrameLengthText,'visible','off');
set(handles.CurrentFrameTimeEdit,'visible','off');
set(handles.CurrentFrameTimeText,'visible','off');
set(handles.FrameSlider,'visible','off');
set(handles.DynFrameMovie,'enable','off');
set(handles.SaveDynFramesAsAvi,'enable','off');
set(handles.SumFrames,'enable','off');
set(handles.SUV_normalization,'checked','off');
set(handles.Normalization,'checked','off');
set(handles.Interpolate,'checked','off');
if ~(clear_option == 2);
% clear before load a new file
% when clear_option = 2, DICOMDIR infos will not be deleted
set(handles.OpenDICOMDIRfromCurrent,'enable','off');
set(handles.Open2DICOMDIRfromCurrent,'enable','off');
end
handles.imaVOLtmpinterp = [];
% turn on the pixval button if it was not on
if ~get(handles.MeasureTogglebutton,'value')
set(handles.MeasureTogglebutton,'value',1)
% if get(handles.ZoomTogglebutton,'value')
% set(handles.ZoomTogglebutton,'value',0);
% mia_zoompan('stop');
% handles.zoom = 0;
% set(handles.ROIbutton,'enable','on');
% end
if get(handles.ImProfileTogglebutton,'value')
mia_improfile('stop');
set(handles.ImProfileTogglebutton,'value',0);
set(handles.ROIbutton,'enable','on');
ImageProfileHandler = findobj('name','Image Profile');
delete(ImageProfileHandler);
end
if get(handles.DetailRectangleButton,'value')
set(handles.DetailRectangleButton,'value',0);
RectangleHandler = findobj('tag','miarectangle');
draggable(RectangleHandler,'off');
pause(2);
delete(findobj('name','Detail Rectangle'));
axes(handles.ImaAxes);
set(handles.ROIbutton,'enable','off');
delete(RectangleHandler);
end
end
% disabled the controls for 2nd image file
miaControlSetup(2,handles);
% set the figure renderer property back to normal if
% OPENGL was enabled
if handles.openglinfo.miafigure_useOpenGL;
set(handles.mia_figure1,'renderer','painter');
handles.openglinfo.miafigure_useOpenGL = 0;
end
% Update handles structure
guidata(handles.mia_figure1, handles);
handlesout = handles;
% --- Executes on button press in ROIbutton.
function ROIbutton_Callback(hObject, eventdata, handles)
% hObject handle to ROIbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if not(isfield(handles,'FileNames'));return;end%return if no file was opened
if ~handles.zoom
%turns off interactive display of information about image pixels
mia_pixval(handles.ImaHandler,'off');
end
axes(handles.ImaAxes);
set(handles.hcb,'buttonDownFcn','mia_gui(''SetImageContrast'',gcbo,[],guidata(gcbo))');
if ~isempty(handles.ROI(handles.CurrentSlice,handles.CurrentROIColor).BW )
handles.ROI(handles.CurrentSlice,handles.CurrentROIColor ).BW = [];
handles.ROI(handles.CurrentSlice,handles.CurrentROIColor ).xi = [];
handles.ROI(handles.CurrentSlice,handles.CurrentROIColor ).yi = [];
delete(handles.Lines(handles.CurrentSlice,handles.CurrentROIColor).lh);
handles.Lines(handles.CurrentSlice,handles.CurrentROIColor).lh = [];
end
%set(get(handles.ImaAxes,'children'),'EraseMode','normal');
[BW,xi,yi] = roipoly;
handles.ROI(handles.CurrentSlice,handles.CurrentROIColor).BW = 1;
%if isfield(handles,'FileNames2')
% matsize = handles.scaninfo2.imfm(1);
%else
% matsize = handles.scaninfo.imfm(1);
%end
matsize1 = double(handles.scaninfo.imfm(1));
matsize2 = double(handles.scaninfo.imfm(2));
% setting the normalized coordinates of ROI
handles.ROI(handles.CurrentSlice,handles.CurrentROIColor).xi = xi/matsize1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -