⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mia_gui.m

📁 医学图像处理matlab工具箱
💻 M
📖 第 1 页 / 共 5 页
字号:
hold on;
handles.ColormapIn1 = Initial_cmap;
newlabels = num2cell(fixround(linspace(handles.VolMin,handles.VolMax,handles.NumOfYtickOfColorbar),handles.decimal_prec))';
set(handles.CmapAxes,'Yticklabel',newlabels);
set(handles.CmapAxes,'Tag','CmapAxes');
handles.zoom = 0;
refresh;
%set(ImaHandler,'EraseMode','xor');
%set(get(handles.ImaAxes,'children'),'EraseMode','none');
%
%set the current slice and frame indexes
%
handles.CurrentSlice = CurrentSlice;
handles.CurrentFrame = handles.scaninfo.Frames;
handles.CurrentImgIdx = CurrentImgIdx;
set(handles.CurrentFrameEdit,'String',handles.CurrentFrame);
set(handles.CurrentSliceEdit,'String',handles.CurrentSlice);
if handles.scaninfo.Frames > 1 % dynamic scan
    if handles.scaninfo.num_of_slice == 1 %in case of planar scan (echo, angio ..) turn on the  
        set(handles.DynFrameMovie,'enable','on'); % movie options
        set(handles.SaveDynFramesAsAvi,'enable','on');
    end
    set(handles.SumFrames,'enable','on');
    set(handles.CurrentFrameLengthEdit,'visible','on');
	set(handles.CurrentFrameLengthText,'visible','on');
	set(handles.CurrentFrameTimeEdit,'visible','on');
	set(handles.CurrentFrameTimeText,'visible','on');
    set(handles.CurrentFrameTimeEdit,'String', ...
        sprintf('%1.2f',handles.scaninfo.tissue_ts(handles.CurrentFrame)/60));%min
    set(handles.CurrentFrameLengthEdit,'String', ...
        sprintf('%1.2f',handles.scaninfo.frame_lengths(handles.CurrentFrame)/60));%min
    set(handles.FrameSlider,'visible','on');
    %
	% initiate the Frame Slider
	%
	set(handles.FrameSlider,'Min',1); 
	set(handles.FrameSlider,'Max',handles.scaninfo.Frames);
	set(handles.FrameSlider,'value',handles.scaninfo.Frames);
	set(handles.FrameSlider,'SliderStep',...
        [1/(handles.scaninfo.Frames - 1) 10/(handles.scaninfo.Frames - 1)] );
    
end
%
% initiate the ColorBar Sliders
%
set(handles.ColorBarMaxSlider,'Min',handles.VolMin); 
set(handles.ColorBarMaxSlider,'Max',handles.VolMax);
set(handles.ColorBarMinSlider,'Min',handles.VolMin); 
set(handles.ColorBarMinSlider,'Max',handles.VolMax);
set(handles.ColorBarMaxSlider,'Value',CurrentImageMinMax(2));
set(handles.ColorBarMinSlider,'Value',CurrentImageMinMax(1));
%
% inititate the ROI,VOI parameters
%
handles.ROI = [];
handles.ROI(handles.scaninfo.num_of_slice,handles.ROINumOfColor).BW = [];
handles.ROI(handles.scaninfo.num_of_slice,handles.ROINumOfColor).xi = [];
handles.ROI(handles.scaninfo.num_of_slice,handles.ROINumOfColor).yi = [];
handles.Lines(handles.scaninfo.num_of_slice,handles.ROINumOfColor).lh = [];
handles.VOI(handles.ROINumOfColor).tac = [];
handles.VOI(handles.ROINumOfColor).tacstd = [];
handles.VOI(handles.ROINumOfColor).tacmin = [];
handles.VOI(handles.ROINumOfColor).tacmax = [];
handles.VOI(handles.ROINumOfColor).tacvolume = [];     
%
% delete the inputpath if supplied at startup  
%
if(isfield(handles,'inputpath'));
    handles = rmfield(handles,'inputpath');
end
%
%set the menu items if necessary
%
if handles.scaninfo.Frames == 1
    set(handles.SumFrames,'enable','off');
else
    set(handles.SumFrames,'enable','on');
end
%
% set the 3D controls to be on in case of 3D imaVOL
%
if handles.scaninfo.num_of_slice > 1;
    miaControlSetup(0,handles);
    %
	% initiate the Slice Slider
	%
	set(handles.SliceSlider,'Min',1); 
	set(handles.SliceSlider,'Max',handles.scaninfo.num_of_slice);
	set(handles.SliceSlider,'value',CurrentSlice);
	set(handles.SliceSlider,'SliderStep',...
        [1/(handles.scaninfo.num_of_slice-1) 10/(handles.scaninfo.num_of_slice-1)] );
elseif handles.scaninfo.num_of_slice == 1
    miaControlSetup(2,handles);
end 


%
% initiate the mia_pixval function
%
axes(handles.ImaAxes);
global gVOIpixval;
if strcmp(char(fextension),'.mnc') 
    gVOIpixval.xypixsize(1) = handles.scaninfo.pixsize(2);
    gVOIpixval.xypixsize(2) = handles.scaninfo.pixsize(1);
else
    gVOIpixval.xypixsize = handles.scaninfo.pixsize;
end
gVOIpixval.CurrentImage = CurrentImage;
gVOIpixval.xLim = get(handles.ImaAxes,'XLim');
gVOIpixval.yLim = get(handles.ImaAxes,'YLim');
mia_pixval(handles.ImaHandler,'on');

% Update handles structure
%
guidata(hObject, handles);

% --------------------------------------------------------------------
function OpenDICOMDIRmain_Callback(hObject, eventdata, handles)
% hObject    handle to OpenDICOMDIRmain (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function OpenDICOMDIRfromNew_Callback(hObject, eventdata, handles)
% hObject    handle to OpenDICOMDIRfromNew (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% if previous imaVOL is currently being opened delete and set 
% the appropriate objects
if isfield(handles,'FileNames')
    handles = ClearImages(handles,2);
    drawnow;
    set(handles.mia_figure1,'keyPressFcn','mia_gui(''mia_figure1_KeyPressFcn'',gcbo,[],guidata(gcbo))');
end

[dcmSeries, dcmPatient, SeriesList, SeriesListNumInfo] = loaddcmdir;
if isempty(dcmSeries);
    disp('No DICOM Series was selected!');
    return;
end
handles.dcmdir = [];
handles.dcmdir.dcmSeries = dcmSeries;
handles.dcmdir.dcmPatient = dcmPatient;
handles.dcmdir.SeriesList = SeriesList;
handles.dcmdir.SeriesListNumInfo = SeriesListNumInfo;
handles.DICOMDIRmenu_1Selected = 1;
set(handles.OpenDICOMDIRfromCurrent,'enable','on');

% Update handles structure
guidata(hObject, handles);

% Run the OpenFileMenuItem to load the selected dcm series
OpenImageFilemenuItem_Callback(handles.OpenImageFilemenuItem, [], handles);

% --------------------------------------------------------------------
function OpenDICOMDIRfromCurrent_Callback(hObject, eventdata, handles)
% hObject    handle to OpenDICOMDIRfromCurrent (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,2);
    drawnow;
    set(handles.mia_figure1,'keyPressFcn','mia_gui(''mia_figure1_KeyPressFcn'',gcbo,[],guidata(gcbo))');
end

dcmPatient = handles.dcmdir.dcmPatient;
SeriesList = handles.dcmdir.SeriesList;
SeriesListNumInfo = handles.dcmdir.SeriesListNumInfo;
dicomdirpath = handles.dcmdir.dcmSeries.dicomdirpath;
handles.DICOMDIRmenu_1Selected = 1;

% create popupmenu for dicomseries
global dcmdirlistVal;
dcmdirlistVal = 0;
dcmdirlistfh = figure('menubar','none','NumberTitle','off','name','DICOMDIR info');
lbh = uicontrol('Style','listbox','Position',[10 60 520 340],'tag','dcmdirlist_popupmenu');
set(lbh,'string',SeriesList);
OKCallback = 'global dcmdirlistVal; dcmdirlistVal = get(findobj(''tag'',''dcmdirlist_popupmenu''),''value''); delete(findobj(''name'',''DICOMDIR info''));';
CancelCallback = 'delete(findobj(''name'',''DICOMDIR info''));';
OK_h = uicontrol('Style', 'pushbutton', 'String', 'OK','Position', [440 10 80 30], 'Callback', OKCallback);
Cancel_h = uicontrol('Style', 'pushbutton', 'String', 'Cancel','Position', [340 10 80 30], 'Callback', CancelCallback);

uiwait(dcmdirlistfh);

if dcmdirlistVal == 0;
    disp('No DICOM Series was selected!');
    return;
end

% create the outputs
dcmSeriesPath = dcmPatient(SeriesListNumInfo(dcmdirlistVal).PatientNum). ...
    Study(SeriesListNumInfo(dcmdirlistVal).StudyNum). ...
    Series(SeriesListNumInfo(dcmdirlistVal).SeriesNum). ...
    ImagePath;
dcmSeries.Path = [dicomdirpath, filesep, dcmSeriesPath, filesep];
dcmSeries.dicomdirpath = dicomdirpath;
dcmSeries.Images = dcmPatient(SeriesListNumInfo(dcmdirlistVal).PatientNum). ...
    Study(SeriesListNumInfo(dcmdirlistVal).StudyNum). ...
    Series(SeriesListNumInfo(dcmdirlistVal).SeriesNum). ...
    ImageNames;
handles.dcmdir.dcmSeries = dcmSeries;

% Update handles structure
guidata(hObject, handles);

% Run the OpenFileMenuItem to load the selected dcm series
OpenImageFilemenuItem_Callback(handles.OpenImageFilemenuItem, [], handles);

% --------------------------------------------------------------------
function Open2ndImageFilemenuItem_Callback(hObject, eventdata, handles)
% hObject    handle to Open2ndImageFilemenuItem (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 % 1st file should be opened first

% if this is not the first file opening, use the handles.dirname as startup_dir to uigetfiles.m 
if isfield(handles,'dirname')
    if ispc
        [FilesSelected2, dir_path2] = uigetfiles( ...
            '*.img;*.mnc;*.dcm;*.v;*.ima;*.cub;*.mat','Select image files',handles.dirname);
    else
        [FilesSelected2, dir_path2] = uigetfiles2('Start', '*.*', handles.dirname);
    end
else
    if ispc
        [FilesSelected2, dir_path2] = uigetfiles(...
            '*.img;*.mnc;*.dcm;*.v;*.ima;*.cub;*.mat','Select image files');
    else
        [FilesSelected2, dir_path2] = uigetfiles2('Start', '*.*');
    end
end

if isempty(FilesSelected2); return; end
miaControlSetup(1,handles);

% if previous imaVOL2 is currently being opened delete the appropriate
% objects
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');
end 

handles.FileNames2 = sortrows(FilesSelected2');
handles.dirname2 = dir_path2;
%
% identify the file type :mnc or ima, and
% load the appropriate imaVOL
%
[fpath,fname,fextension,fversion] = fileparts(char(handles.FileNames2(1)));
handles.fextension2 = char(fextension);
handles.fname2 = char(fname);
if strcmp(char(fextension),'.ima')
    num_of_files = size(handles.FileNames2,1);
	for i=1:num_of_files
        filelist(i).name = char(handles.FileNames2(i));
	end
	filelist = filelist';
    filename=[];jobinfo=1;
    [handles.imaVOL2, handles.scaninfo2, handles.fileheader2] = loadvaxima(filename,jobinfo,filelist,handles.dirname2);
elseif strcmp(char(fextension),'.mnc')
    [handles.imaVOL2, handles.scaninfo2] = loadminc([handles.dirname2,char(handles.FileNames2(1))]);
elseif strcmp(char(fextension),'.dcm') | strcmp(char(fextension),'')
    [handles.imaVOL2, handles.scaninfo2] = loaddcm(handles.FileNames2,handles.dirname2);
elseif strcmp(lower(char(fextension)),'.v')
    [handles.imaVOL2, handles.scaninfo2] = loadecat([handles.dirname2,char(handles.FileNames2(1))]);
elseif strcmp(char(fextension),'.img')
    [handles.imaVOL2, handles.scaninfo2] = loadanalyze([handles.dirname2,char(handles.FileNames2(1))]);
elseif strcmp(char(fextension),'.cub')
    [handles.imaVOL2, handles.scaninfo2] = loadcube([handles.dirname2,char(handles.FileNames2(1))]);
elseif strcmp(char(fextension),'.mat')
    [handles.imaVOL2, handles.scaninfo2] = loadmat([handles.dirname2,char(handles.FileNames2(1))]);
else
    hm = msgbox(['No image file was selected. The supported files are: ',...
    '*.img;*.mnc;*.dcm;*.v;*.ima;*.cub;*.mat'],'mia Info' );
    return; 
end
if isempty(handles.imaVOL2)% error during file opening
    hm = msgbox('Error during the file opening. For details See the Matlab Command Window','mia Info' );
    return;
end
%
% if size(imaVOL2) ~= size(imaVOL) then imaVOL2 should transfrom to the
% imaVOL voxelspace 
%
VOLsizeRel = size(handles.imaVOL,1) ~= size(handles.imaVOL2);
if VOLsizeRel(1) | VOLsizeRel(2) | VOLsizeRel(3) 
    button = questdlg(['The 2nd image dimensions does not fit to the 1st. ones. ', ...
     'Do you want to put them into same coordinate system?'], ...
	'mia info','Yes','No','No');
	if strcmp(button,'Yes')
        object_out = PutIntoSameVoxelSpace(handles.imaVOL,handles.scaninfo.pixsize, ...
            handles.imaVOL2,handles.scaninfo2.pixsize,handles.mia_figure1);
        handles.imaVOL2 = object_out;
        handles.scaninfo2.pixsize = handles.scaninfo.pixsize;
        handles.scaninfo2.imfm = handles.scaninfo.imfm;
        handles.scaninfo2.num_of_slice = handles.scaninfo.num_of_slice;
	end
end


set(handles.ImaList2box,'String',handles.FileNames2,...
	'Value',1);

if isfield(handles,'FileNames')
    CurrentSlice = handles.CurrentSlice;
    CurrentImgIdx= handles.CurrentImgIdx;
else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -