✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab完整代码及仿真定制内容点击👇
🔥 内容介绍
在医学影像领域,MRI(磁共振成像)是一种常见的诊断工具,广泛应用于脑肿瘤的检测和分析。然而,准确地分割脑肿瘤仍然是一项具有挑战性的任务。近年来,基于监督学习的方法在脑肿瘤分割中取得了显著的进展。本文将介绍一种基于监督学习的多模态MRI脑肿瘤分割方法,该方法利用来自超体素的纹理特征,以提高分割的准确性和稳定性。
在传统的MRI脑肿瘤分割方法中,常常使用像素级的特征来进行分割。然而,这种方法容易受到噪声和图像不均匀性的影响,导致分割结果不准确。为了克服这些问题,我们提出了一种基于超体素的纹理特征的方法。超体素是指由相邻像素组成的三维体素块,它能够提供更丰富的局部信息。通过提取超体素的纹理特征,我们可以更好地捕捉到脑肿瘤的形态和纹理特征,从而提高分割的准确性。
在我们的方法中,我们首先从多个MRI模态中提取超体素的纹理特征。这些模态可以包括T1加权、T2加权和增强后的T1加权图像。然后,我们使用这些特征来训练一个监督学习模型,例如支持向量机(SVM)或卷积神经网络(CNN)。通过训练模型,我们可以学习到脑肿瘤的特征表示和分割决策边界。最后,我们将训练好的模型应用于新的MRI图像,进行脑肿瘤的分割。
与传统方法相比,我们的方法具有以下优势。首先,通过使用超体素的纹理特征,我们可以更好地捕捉到脑肿瘤的细微变化,提高分割的准确性。其次,我们的方法可以同时利用多个MRI模态的信息,从而提供更全面的特征表示。此外,我们的方法是基于监督学习的,可以通过大量的训练样本来学习到更准确的模型。最后,我们的方法可以在实时性要求不高的情况下进行脑肿瘤分割,为医生提供更准确的诊断结果。
然而,我们的方法也存在一些挑战和限制。首先,超体素的纹理特征提取需要大量的计算资源和存储空间。其次,我们的方法对MRI图像的质量和分辨率要求较高,对于低质量或低分辨率的图像可能无法达到理想的分割效果。此外,我们的方法还需要大量的训练样本来学习模型,这可能对于一些医疗机构来说是一项挑战。
总之,基于监督学习的多模态MRI脑肿瘤分割方法,利用来自超体素的纹理特征,是一种提高分割准确性和稳定性的有效方法。尽管存在一些挑战和限制,但随着技术的不断发展和数据的积累,我们相信这种方法将在未来的医学诊断中发挥重要作用,为医生提供更准确的脑肿瘤分析结果。
📣 部分代码
function varargout = MP3(varargin)
% MP3 MATLAB code for MP3.fig
% MP3, by itself, creates a new MP3 or raises the existing
% singleton*.
%
% H = MP3 returns the handle to a new MP3 or the handle to
% the existing singleton*.
%
% MP3('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MP3.M with the given input arguments.
%
% MP3('Property','Value',...) creates a new MP3 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before MP3_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to MP3_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help MP3
% Last Modified by GUIDE v2.5 17-Jun-2021 14:19:22
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @MP3_OpeningFcn, ...
'gui_OutputFcn', @MP3_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before MP3 is made visible.
function MP3_OpeningFcn(hObject, ~, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to MP3 (see VARARGIN)
% Choose default command line output for MP3
handles.output = hObject;
% Add path to all the files in the MATLAB search path
p = mfilename('fullpath');
warning off
rmpath(genpath(fileparts(p)))
warning on
addpath(genpath(fileparts(p)),'-begin');
% init stuct/variables
handles.VOIs = {'Other'};
handles.histo = {'Other'}; %{'Pimo', 'ColIV', 'Tc+I_cerveau', 'Tc+I_ref'};
handles.resolution = [1 64 112 128 192 256 384 512 3000];
handles.colors ={'b', 'g', 'm', 'c', 'r', 'k', 'y', 'navy',...
'u1','turquoise','slateblue', 'springgreen', 'maroon',...
'purple', 'u2', 'olive', 'u3','chartreuse', 'u4', 'sky',...
'u5', 'orange', 'u6', 'u7', 'u8', 'gray'};
load(which('rgb_color_table.mat'), 'num');
handles.colors_rgb = num;
handles.colormap = get(handles.MP3_colormap_popupmenu,'String');
handles.markers ={'o','s', 'd', 'p', 'h', '+', '*', 'x'};
table_data(1,1) = {'Voxel values'};
set(handles.MP3_table_pixel_values, 'Data', table_data);
set(handles.MP3_table1, 'Data', {'', '', '', '', ''});
handles.table1.cluster = [];
handles.table1.cluster_row = [];
handles.mode = 1;
handles.view_mode = 'Axial';
set(handles.MP3_scans_button, 'ForegroundColor', [1 0 0])
set(handles.MP3_scans_button, 'Value', 1)
handles.display_option.view_pixel_on_map = 0;
handles.display_option.view_pixel_on_plot = 0;
handles.display_option.view_plot = 1;
handles.display_option.manual_contrast = 0;
set(handles.MP3_menu_view_plot, 'Check', 'on');
for i=1:4
stri = num2str(i);
set(eval(['handles.MP3_data', stri, '_echo_slider']), 'Visible', 'off');
set(eval(['handles.MP3_data', stri, '_expt_slider']), 'Visible', 'off');
end
set(handles.MP3_PRM_slider_trans, 'Visible', 'off');
% add MRIManager.jar to the classpath (dynamic classpath)
[filepath,name,ext] = fileparts(which('MRIManager.jar'));
javaclasspath(fullfile(filepath,[name,ext]));
% save the java skin used
handles.original_Java_LookAndFeel = javax.swing.UIManager.getLookAndFeel;
handles.original_Java_LookAndFeel = sprintf('%s',handles.original_Java_LookAndFeel);
handles.original_Java_LookAndFeel = split(handles.original_Java_LookAndFeel,' - ');
handles.original_Java_LookAndFeel = extractBefore(handles.original_Java_LookAndFeel{end},']');
handles.original_Java_LookAndFeel = ['[LookAndFeel] ',handles.original_Java_LookAndFeel];
% A = javax.swing.UIManager.getLookAndFeel;
% char(A.getClass) % 'class com.jgoodies.looks.plastic.Plastic3DLookAndFeel' Replace class by [LookAndFeel]
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes MP3 wait for user response (see UIRESUME)
% uiwait(handles.MP3_GUI);
% --- Outputs from this function are returned to the command line.
function varargout = MP3_OutputFcn(~, ~, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes when user attempts to close MP3_GUI.
function MP3_GUI_CloseRequestFcn(hObject, eventdata, handles)
% hObject handle to MP3_GUI (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, 'database')
delete(hObject);
if ~isempty(findobj('type', 'figure', 'name', 'MP3 pipeline Manager'))
close((findobj('type', 'figure', 'name', 'MP3 pipeline Manager')));
end
return
else
DBFilename = [handles.database.Properties.UserData.MP3_data_path, handles.database.Properties.UserData.db_filename];
SavedDB = load(DBFilename, 'database');
Diff = setdiff(SavedDB.database, handles.database);
if isempty(Diff)
delete(hObject);
if ~isempty(findobj('type', 'figure', 'name', 'MP3 pipeline Manager'))
close((findobj('type', 'figure', 'name', 'MP3 pipeline Manager')));
end
return
end
end
% Hint: delete(hObject) closes the figure
selection = questdlg('Before leaving, do you want to save your database?',...
'Warning',...
'Yes','No','Yes');
if isempty(selection)
return
end
switch selection
case 'Yes'
MP3_menu_save_database_Callback(hObject, eventdata, handles)
end
if ~isempty(findobj('type', 'figure', 'name', 'MP3 pipeline Manager'))
close((findobj('type', 'figure', 'name', 'MP3 pipeline Manager')));
end
delete(hObject);
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over MP3_slider_slice.
function MP3_slider_slice_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to MP3_slider_slice (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles = guidata(hObject);
if ~isfield(handles, 'data_loaded') && ~isfield(handles, 'data_selected_for_PRM')
return
end
Slice_min = get(hObject,'Min');
Slice_max = get(hObject,'Max');
Position = get(hObject,'Position');
SliderBarWidth = Position(3)/Slice_max;
set(hObject,'UserData',[Slice_min Slice_max SliderBarWidth]);
cp = get(handles.MP3_GUI,'CurrentPoint');
newValue = round((cp(1,1))/SliderBarWidth);
if newValue == get(handles.MP3_slider_slice,'Value')
return
elseif newValue > Slice_max
newValue = Slice_max;
elseif newValue < Slice_min
newValue = Slice_min;
end
set(handles.MP3_slider_slice,'Value',newValue);
MP3_update_axes(hObject, eventdata, handles)
%
% set(handles.MP3_GUI,'WindowButtonMotionFcn',{@MP3_slider_on_move,handles})
% set(handles.MP3_GUI,'WindowButtonUpFcn',{@MP3_slider_release_click,handles})
% --- Executes during object creation, after setting all properties.
function MP3_slider_slice_CreateFcn(hObject, ~, ~)
% hObject handle to MP3_slider_slice (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on selection change in MP3_name_list.
function MP3_name_list_Callback(hObject, eventdata, ~)
% hObject handle to MP3_name_list (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns MP3_name_list contents as cell array
% contents{get(hObject,'Value')} returns selected item from MP3_name_list
handles = guidata(hObject);
if ~isfield(handles, 'database')
return
end
set(handles.MP3_time_points_list, 'Value', 1);
set(handles.MP3_scans_list, 'Value', 1);
set(handles.MP3_file_list, 'Value', 1);
MP3_update_database_display(hObject, eventdata, handles);
% --- Executes during object creation, after setting all properties.
function MP3_name_list_CreateFcn(hObject, ~, ~)
% hObject handle to MP3_name_list (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in MP3_scans_list.
function MP3_scans_list_Callback(hObject, eventdata, handles)
% hObject handle to MP3_scans_list (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns s_list contents as cell array
% contents{get(hObject,'Value')} returns selected item from MP3_scans_list
if ~isfield(handles, 'database')
return
end
if numel(get(handles.MP3_name_list, 'Value')) >1 || numel(get(handles.MP3_time_points_list, 'Value')) > 1
return
end
set(handles.MP3_file_list, 'Value', 1);
guidata(hObject, handles);
MP3_update_database_display(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function MP3_scans_list_CreateFcn(hObject, ~, ~) %#ok<*DEFNU>
% hObject handle to MP3_scans_list (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function MP3_update_database_display(hObject, eventdata, handles)
% handles = guidata(gcf, findobj('Tag', 'MP3_GUI'));
handles = guidata(handles.MP3_GUI);
if ~isfield(handles, 'database')
return
end
if isempty(handles.database)
% if the table is empty, clear all lists
set(handles.MP3_name_list, 'String', '', 'Value', 1);
set(handles.MP3_time_points_list, 'String', '', 'Value', 1);
set(handles.MP3_scans_list, 'String', '', 'Value', 1);
set(handles.MP3_file_list, 'String', '', 'Value', 1);
return
end
patient_id = get(handles.MP3_name_list, 'Value');
id_listing = unique(handles.database.Patient,'stable');
set(handles.MP3_name_list, 'String', char(id_listing));
if numel(patient_id)~= 1
return
end
Patient_filter = handles.database.Patient== id_listing(patient_id);
tp_listing = unique(handles.database.Tp(Patient_filter),'stable');
% check if the new time point listing is not shorter than the old one. If
% so update MP3_time_points_list 'Value'
if numel(tp_listing) < get(handles.MP3_time_points_list, 'Value')
set(handles.MP3_time_points_list, 'String', char(tp_listing), 'Value', numel(tp_listing));
else
set(handles.MP3_time_points_list, 'String', char(tp_listing));
end
time_point = get(handles.MP3_time_points_list, 'Value');
if get(handles.MP3_scans_button, 'Value') == 1 %display parameters list
is_scan = handles.database.Type == 'Scan';
tp_filter = handles.database.Tp== tp_listing(time_point);
sequence_listing = handles.database.SequenceName(Patient_filter & tp_filter & is_scan);
% check if the sequence listing is not shorter than the old one. If
% so update MP3_scans_list 'Value'
if numel(sequence_listing) < get(handles.MP3_scans_list, 'Value')
set(handles.MP3_scans_list, 'String', char(sequence_listing), 'Value', numel(sequence_listing));
else
set(handles.MP3_scans_list, 'String', char(sequence_listing));
end
scan = get(handles.MP3_scans_list, 'Value');
file_text= cell(1, numel(sequence_listing(scan)));
for i=1:numel(sequence_listing(scan))
sequence_filter = handles.database.SequenceName== sequence_listing(scan(i));
file_text(i) = cellstr(handles.database.Filename(Patient_filter & tp_filter & sequence_filter & is_scan));
end
set(handles.MP3_file_list, 'String', file_text);
elseif get(handles.MP3_VOIs_button, 'Value') == 1 %display VOIs list
is_ROI = handles.database.Type == 'ROI' | handles.database.Type == 'Cluster';
tp_filter = handles.database.Tp== tp_listing(time_point);
sequence_listing = handles.database.SequenceName(Patient_filter & tp_filter & is_ROI);
if isempty(sequence_listing)
set(handles.MP3_scans_list, 'String', '');
return
end
scan = get(handles.MP3_scans_list, 'Value');
set(handles.MP3_scans_list, 'String', char(sequence_listing));
file_text= cell(1, numel(sequence_listing(scan)));
for i=1:numel(sequence_listing(scan))
sequence_filter = handles.database.SequenceName== sequence_listing(scan(i));
if sum(Patient_filter & tp_filter & sequence_filter & is_ROI) == 1
file_text(i) = cellstr(handles.database.Filename(Patient_filter & tp_filter & sequence_filter & is_ROI));
else
% in case there are more than two entries in the database --> delete the extra one(s)
indexes = find(Patient_filter & tp_filter & sequence_filter & is_ROI);
handles.database(indexes(2:end),:)=[];
guidata(hObject, handles)
return
end
end
set(handles.MP3_file_list, 'String', file_text);
elseif get(handles.MP3_Others_button, 'Value') == 1 %display the "Other" tag list
% warndlg('not coded yet', 'Warning');
List_of_types = unique(handles.database.Type);
List_of_types = List_of_types( ~sum(List_of_types == {'Scan', 'ROI', 'Cluster'}, 2));
is_scan = sum(handles.database.Type == List_of_types',2);
tp_filter = handles.database.Tp== tp_listing(time_point);
sequence_listing = handles.database.SequenceName(Patient_filter & tp_filter & is_scan);
if isempty(sequence_listing)
set(handles.MP3_scans_list, 'String', '');
return
end
% check if the sequence listing is not shorter than the old one. If
% so update MP3_scans_list 'Value'
if numel(sequence_listing) < get(handles.MP3_scans_list, 'Value')
set(handles.MP3_scans_list, 'String', char(sequence_listing), 'Value', numel(sequence_listing));
else
set(handles.MP3_scans_list, 'String', char(sequence_listing));
end
scan = get(handles.MP3_scans_list, 'Value');
file_text= cell(1, numel(sequence_listing(scan)));
for i=1:numel(sequence_listing(scan))
sequence_filter = handles.database.SequenceName== sequence_listing(scan(i));
file_text(i) = cellstr(handles.database.Filename(Patient_filter & tp_filter & sequence_filter & is_scan));
end
set(handles.MP3_file_list, 'String', file_text);
end
% Update the groupname
MP3_show_group_Callback(hObject, eventdata, handles)
% if the pipeline Manager is open, update the information : patient selected
% update the 'String' of MP3_pipeline_pushMP3Selection and MP3_pipeline_pushMP3TPSelection push button
if ~isempty(findobj('type', 'figure', 'name', 'MP3 pipeline Manager'))
% Get the hObject of MP3_pipeline
h = findobj('Tag', 'MP3_pipeline_manager_GUI');
% Get the handles of MP3_pipeline
data = guidata(h);
% Update the handles of MP3_pipeline by stocking the latest version of
% MP3 handles.
data.MP3_data = handles;
% Don't touch the original eventdata, just in case.
eventdata2 = eventdata;
%Update the MP3_pipeline tmp_database
[h, ~, data] = MP3_pipeline('UpdateTmpDatabase', h, eventdata2, data);
[~, ~, data] = MP3_pipeline('MP3_pipeline_UpdateTables', h, eventdata2, data);
clear('eventdata2')
guidata(h, data)
end
if ~isempty(findobj('Tag', 'MP3_pipeline_pushMP3Selection'))
data_selected = finddata_selected(handles);
if size(char(handles.database.Patient(data_selected)),1) > 1
return
else
set(findobj('Tag', 'MP3_pipeline_pushMP3Selection'), 'String', [char(handles.database.Patient(data_selected(1))) '-' char(handles.database.Tp(data_selected(1))) ' only'])
set(findobj('Tag', 'MP3_pipeline_pushMP3TPSelection'), 'String', ['All time point of :' char(handles.database.Patient(data_selected(1)))])
end
end
% --- Executes on selection change in MP3_time_points_list.
function MP3_time_points_list_Callback(hObject, eventdata, handles)
% hObject handle to MP3_time_points_list (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns MP3_time_points_list contents as cell array
% contents{get(hObject,'Value')} returns selected item from MP3_time_points_list
if ~isfield(handles, 'database')
return
end
set(handles.MP3_scans_list, 'Value', 1);
set(handles.MP3_file_list, 'Value', 1);
guidata(hObject, handles);
if numel(get(handles.MP3_time_points_list, 'Value')) >1 ||...
numel(get(handles.MP3_name_list, 'Value')) >1
else
MP3_update_database_display(hObject, eventdata, handles)
end
% --- Executes during object creation, after setting all properties.
function MP3_time_points_list_CreateFcn(hObject, ~, ~)
% hObject handle to MP3_time_points_list (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in MP3_file_list.
function MP3_file_list_Callback(~, ~, ~)
% hObject handle to MP3_file_list (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns MP3_file_list contents as cell array
% contents{get(hObject,'Value')} returns selected item from MP3_file_list
% --- Executes during object creation, after setting all properties.
function MP3_file_list_CreateFcn(hObject, ~, ~)
% hObject handle to MP3_file_list (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --------------------------------------------------------------------
function MP3_rename_name_Callback(hObject, eventdata, handles)
% hObject handle to MP3_rename_name (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, 'database')
return
end
data_selected = finddata_selected(handles);
if numel(data_selected) >1
warndlg('Please select only one Patient', 'Warning');
return
end
name_option = [cellstr(unique(handles.database.Patient(handles.database.Type == 'Scan')))''Other']';
[new_Patient_name, ok1] = listdlg('PromptString','Select the new scan name:',...
'Name', 'Select a Name',...
'SelectionMode','single',...
'ListSize', [400 300],...
'ListString',name_option);
if ok1 == 0
return
end
if strcmp('Other',name_option(new_Patient_name)) == 1
NewPatient = inputdlg('Name of the new Scan ', 'Question?', 1, {''});
if isempty(NewPatient)
return
end
else
NewPatient =name_option(new_Patient_name);
end
%% update the database with the new name
% but first check if the new scan name does not exist for this patient and
% time point
if find(handles.database.Patient == handles.database.Patient(data_selected) &...
handles.database.Tp == handles.database.Tp(data_selected) & ...
handles.database.SequenceName == NewPatient) > 0
msgbox('A Scan with the same name already exist for this patient at this time point') ;
return
end
idx_scan_to_rename = find(handles.database.Patient == handles.database.Patient(data_selected));
for i=1:numel(idx_scan_to_rename)
new_nii_filename = strrep(cellstr(handles.database.Filename(idx_scan_to_rename(i))), cellstr(handles.database.Patient(idx_scan_to_rename(i))), NewPatient);
% rename the scan file
if exist(fullfilename(handles, idx_scan_to_rename(i), '.nii'), 'file') == 0
warning_text = sprintf('##$ This file no not exist\n##$ %s',...
fullfilename(handles, idx_scan_to_rename(i), '.nii'));
msgbox(warning_text, 'rename file warning') ;
elseif exist(string(strcat(cellstr(handles.database.Path(idx_scan_to_rename(i))),new_nii_filename{:},'.nii')), 'file') == 2
msgbox('The new .nii file exist already!!') ;
else
movefile(fullfilename(handles, idx_scan_to_rename(i), '.nii'), strcat(char(handles.database.Path(idx_scan_to_rename(i))),new_nii_filename{:},'.nii'), 'f')
if exist(fullfilename(handles, idx_scan_to_rename(i), '.json'), 'file') == 2
movefile(fullfilename(handles, idx_scan_to_rename(i), '.json'), strcat(char(handles.database.Path(idx_scan_to_rename(i))),new_nii_filename{:},'.json'), 'f');
end
end
% update the Filename field in the table
handles.database.Patient(idx_scan_to_rename(i)) = NewPatient;
handles.database.Filename(idx_scan_to_rename(i)) = new_nii_filename;
end
% save the structure
guidata(hObject, handles);
set(handles.MP3_name_list, 'Value', 1);
% update graph and display
MP3_update_database_display(hObject, eventdata, handles);
% Save database
MP3_menu_save_database_Callback(hObject, eventdata, handles)
function MP3_remove_name_Callback(hObject, eventdata, handles)
% hObject handle to MP3_remove_name (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, 'database')
return
end
%data_selected = finddata_selected(handles);
patient_seleted = get(handles.MP3_name_list, 'String');
patient_name = patient_seleted(get(handles.MP3_name_list, 'Value'),:);
%patient_name = unique(handles.database.Patient(data_selected));
user_response = questdlg(['Do you want to delete every data of ' cellstr(patient_name)']', 'Warning', 'Yes', 'No', 'Cancel', 'Cancel');
if strcmp(user_response, 'Cancel') || strcmp(user_response, 'No') || isempty(user_response)
return
end
nii_index = [];
for i=1:size(patient_name,1)
nii_index = [nii_index' find(handles.database.Patient == categorical(cellstr(patient_name(i,:))))']';
end
MP3_remove_scan(hObject, eventdata, handles, nii_index)
% --------------------------------------------------------------------
function MP3_name_right_click_Callback(hObject, eventdata, handles)
% hObject handle to MP3_name_right_click (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, 'database')
return
end
% patient_num = get(handles.MP3_name_list, 'Value');
% omit_obj = findobj(handles.MP3_name_right_click, 'Label', 'Omit');
% set(omit_obj, 'Checked', 'off');
% if numel(patient_num) ==1 && ~isempty(handles.database(patient_num).group)
% group_name = handles.database(patient_num).group;
% if handles.database(patient_num).omit == 1
% set(omit_obj, 'Checked', 'on');
% end
% end
%
% show_menu_obj = findobj(handles.MP3_name_right_click, 'Label', 'Show');
% delete(get(show_menu_obj, 'Children')) %remove the 'old' show menu
%
% group = reshape({handles.database.group},1,[]);
% group_list = unique(group);
% %group_list = unique(group(1:2:end));
%
% if ~isfield(handles, 'database_all') || numel(handles.database_all) == numel(handles.database)
% for i = 1:numel(group_list)
% uimenu(show_menu_obj, 'Label', group_list{i},...
% 'Callback', @(hObject,eventdata)MP3('MP3_show_group_submenu',hObject,eventdata,guidata(hObject)));
% end
% else
% uimenu(show_menu_obj, 'Label', 'all',...
% 'Callback', @(hObject,eventdata)MP3('MP3_show_group_submenu',hObject,eventdata,guidata(hObject)));
% end
% guidata(hObject, handles);
%
% function MP3_show_group_submenu(hObject, eventdata, handles)
%
% show = get(hObject, 'Label');
% if strcmp('all', show)
% database_tmp = handles.database_all;
% for i = 1:numel(handles.database)
% name_size = numel(handles.database(i).name);
% match_name = find(strncmp(handles.database(i).name, {database_tmp.name}', name_size) ==1);
% if numel(match_name) >1
% for j =1:numel(match_name)
% if numel(handles.database(match_name(j)).name) == name_size;
% tmp = match_name(j);
% end
% end
% match_name = tmp;
% end
% database_tmp(match_name) = handles.database(i);
% end
% handles.database = database_tmp;
% handles= rmfield(handles, 'database_all');
% else
% n = 1;
% for i=1:numel(handles.database)
% if strncmp(show, handles.database(i).group, numel(show)) == 1 &&...
% numel(show) == numel(handles.database(i).group)
% database_tmp(n) = handles.database(i);
% n=n+1;
% end
% end
% handles.database_all = handles.database;
% handles.database = database_tmp;
% end
% set(handles.MP3_name_list, 'Value', 1);
% set(handles.MP3_time_points_list, 'Value', 1);
% guidata(handles.MP3_GUI, handles);
% MP3_update_database_display(hObject, eventdata, handles);
% --------------------------------------------------------------------
function MP3_open_database_ClickedCallback(hObject, eventdata, handles)
% hObject handle to MP3_open_database (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, 'database')
selection = questdlg('Have you saved the present database?',...
'Warning',...
'Yes','No','Yes');
switch selection
case 'No'
return
end
end
path_root=pwd;
%[filename, pathname]=uigetfile('*.mat','Open Mat File','MultiSelect','off');
selpath = uigetdir(path_root,'Select the project''s folder you want to open');
pathname = selpath;
%listfiles = what(selpath)
filename = 'MP3_database.mat';
if pathname == 0
return
else
if exist(fullfile(pathname, filename)) ~= 2
% The former name of MP3 is MIA. The following lines allow to open
% old projects with the new software.
if exist(fullfile(pathname, 'MIA_database.mat')) ~= 2
errordlg('The folder you selected might be corrupt. Please select a folder containing a MP3_database.mat file.', 'Cannot open project');
return
else
movefile(fullfile(pathname, 'MIA_database.mat'), fullfile(pathname, filename));
end
end
cd(pathname);
if ~strcmp(class(filename),'double') %#ok<STISA>
%reset everything
handles = MP3_clear_data(hObject, eventdata, handles);
set(handles.MP3_name_list, 'Value', 1);
set(handles.MP3_time_points_list, 'Value', 1);
set(handles.MP3_scans_button, 'Value', 1);
set(handles.MP3_scans_list, 'Value', 1);
database = load(filename);
handles.database = database.database;
set(handles.MP3_name_list, 'String', handles.database.Properties.UserData.db_filename)
% update database path (in case the directory has moved)
handles.database.Properties.UserData.db_filename = filename;
new_patient_directory = strcat(pathname, filesep);
handles.database.Properties.UserData.MP3_data_path = new_patient_directory;
handles.database.Properties.UserData.MP3_Raw_data_path = [new_patient_directory, 'Raw_data', filesep];
handles.database.Properties.UserData.MP3_ROI_path = [new_patient_directory, 'ROI_data', filesep];
handles.database.Properties.UserData.MP3_Derived_data_path = [new_patient_directory, 'Derived_data', filesep];
handles.database.Properties.UserData.PSOM_path = [new_patient_directory, 'PSOM', filesep];
handles.database.Properties.UserData.MP3_Others_data_path = [new_patient_directory, 'Others_data', filesep];
% update the path in the table
%handles.database.Path(handles.database.Type == 'Scan') = handles.database.Properties.UserData.MP3_Raw_data_path;
if ~isempty(handles.database)
handles.database.Path(handles.database.IsRaw == '0' & handles.database.Type == 'Scan',:) = handles.database.Properties.UserData.MP3_Derived_data_path ;
handles.database.Path(handles.database.IsRaw == '1' & handles.database.Type == 'Scan',:) = handles.database.Properties.UserData.MP3_Raw_data_path;
handles.database.Path(handles.database.Type == 'Mfile',:) = handles.database.Properties.UserData.MP3_Others_data_path;
handles.database.Path(handles.database.Type == 'ROI') = handles.database.Properties.UserData.MP3_ROI_path;
handles.database.Path(handles.database.Type == 'Cluster') = handles.database.Properties.UserData.MP3_ROI_path;
end
guidata(hObject, handles);
end
cd(path_root);
end
MP3_update_figureName(hObject, eventdata, handles)
guidata(hObject, handles);
MP3_update_database_display(hObject, eventdata, handles);
% --------------------------------------------------------------------
function MP3_time_points_right_click_Callback(~, ~, ~)
% hObject handle to MP3_time_points_right_click (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function MP3_rename_time_point_Callback(hObject, eventdata,handles)
% hObject handle to MP3_rename_time_point (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, 'database')
return
end
data_selected = finddata_selected(handles);
if numel(data_selected) >1
warndlg('Please select only one Time point', 'Warning');
return
end
name_option = [cellstr(unique(handles.database.Tp(handles.database.Type == 'Scan')))' 'Other']';
[new_TP_name, ok1] = listdlg('PromptString','Select the new scan name:',...
'Name', 'Select a Name',...
'SelectionMode','single',...
'ListSize', [400 300],...
'ListString',name_option);
if ok1 == 0
return
end
if strcmp('Other',name_option(new_TP_name)) == 1
NewTp = inputdlg('Name of the new Scan ', 'Question?', 1, {''});
else
NewTp =name_option(new_TP_name);
end
%% update the database with the new name
% but first check if the new scan name does not exist for this patient and
% time point
% faire le ROI vs SCAN
if find(handles.database.Patient == handles.database.Patient(data_selected) &...
handles.database.Tp == handles.database.Tp(data_selected) & ...
handles.database.SequenceName == NewTp) > 0
msgbox('A Scan with the same name already exist for this patient at this time point') ;
return
end
idx_scan_to_rename = find(handles.database.Patient == handles.database.Patient(data_selected) & handles.database.Tp == handles.database.Tp(data_selected));
for i=1:numel(idx_scan_to_rename)
new_nii_filename = strrep(cellstr(handles.database.Filename(idx_scan_to_rename(i))), cellstr(handles.database.Tp(idx_scan_to_rename(i))), NewTp);
% rename the scan file
if exist(fullfilename(handles, idx_scan_to_rename(i), '.nii'), 'file') == 0 && exist(fullfilename(handles, idx_scan_to_rename(i), '.nii.gz'), 'file') == 0
warning_text = sprintf('##$ This file no not exist\n##$ %s',...
fullfilename(handles, idx_scan_to_rename(i), '.nii'));
msgbox(warning_text, 'rename file warning') ;
elseif exist(string(strcat(cellstr(handles.database.Path(idx_scan_to_rename(i))),new_nii_filename{:},'.nii')), 'file') == 2
msgbox('The new .nii file exist already!!') ;
else
if exist(fullfilename(handles, idx_scan_to_rename(i), '.nii'), 'file') == 2
movefile(fullfilename(handles, idx_scan_to_rename(i), '.nii'), strcat(char(handles.database.Path(idx_scan_to_rename(i))),new_nii_filename{:},'.nii'), 'f')
end
if exist(fullfilename(handles, idx_scan_to_rename(i), '.nii.gz'), 'file') == 2
movefile(fullfilename(handles, idx_scan_to_rename(i), '.nii.gz'), strcat(char(handles.database.Path(idx_scan_to_rename(i))),new_nii_filename{:},'.nii.gz'), 'f')
end
if exist(fullfilename(handles, idx_scan_to_rename(i), '.json'), 'file') == 2
movefile(fullfilename(handles, idx_scan_to_rename(i), '.json'), strcat(char(handles.database.Path(idx_scan_to_rename(i))),new_nii_filename{:},'.json'), 'f');
end
end
% update the Filename field in the table
handles.database.Tp(idx_scan_to_rename(i)) = NewTp;
handles.database.Filename(idx_scan_to_rename(i)) = new_nii_filename;
end
% save the structure
guidata(hObject, handles);
%% update graph and display
MP3_update_database_display(hObject, eventdata, handles);
% save database
MP3_menu_save_database_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function MP3_rename_scan_Callback(hObject, eventdata, handles)
% hObject handle to MP3_rename_scan (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, 'database') || isempty(get(handles.MP3_scans_list, 'String'))
return
end
data_selected = finddata_selected(handles);
if numel(data_selected) >1
warndlg('Please select only one scan', 'Warning');
return
end
if get(handles.MP3_scans_button, 'Value')
name_option = [cellstr(unique(handles.database.SequenceName(handles.database.Type == 'Scan')))' 'Other']';
elseif get(handles.MP3_VOIs_button, 'Value')
name_option = [cellstr(unique(handles.database.SequenceName(handles.database.Type == 'ROI')))' 'Other']';
elseif get(handles.MP3_Others_button_button, 'Value')
name_option = [cellstr(unique(handles.database.SequenceName(handles.database.Type ~= 'Scan' & handles.database.Type ~= 'ROI')))' 'Other']';
end
[new_scan_name, ok1] = listdlg('PromptString','Select the new scan name:',...
'Name', 'Select a Name',...
'SelectionMode','single',...
'ListSize', [400 300],...
'ListString',name_option);
if ok1 == 0
return
end
if strcmp('Other',name_option(new_scan_name)) == 1
newparameter = inputdlg('Name of the new Scan ', 'Question?', 1, {''});
else
newparameter =name_option(new_scan_name);
end
%% update the database with the new name
% but first check if the new scan name does not exist for this patient and
% time point
% faire le ROI vs SCAN
if find(handles.database.Patient == handles.database.Patient(data_selected) &...
handles.database.Tp == handles.database.Tp(data_selected) & ...
handles.database.SequenceName == newparameter) > 0
msgbox('A Scan with the same name already exist for this patient at this time point') ;
return
end
new_nii_filename = strrep(cellstr(handles.database.Filename(data_selected)), cellstr(handles.database.SequenceName(data_selected)), newparameter);
% rename the scan file
if exist(fullfilename(handles, data_selected, '.nii'), 'file') == 0 && exist(fullfilename(handles, data_selected, '.nii.gz'), 'file') == 0
warning_text = sprintf('##$ This file no not exist\n##$ %s',...
fullfilename(handles, data_selected, '.nii'));
msgbox(warning_text, 'rename file warning') ;
elseif exist(string(strcat(cellstr(handles.database.Path(data_selected)),new_nii_filename{:},'.nii')), 'file') == 2
msgbox('The new .nii file exist already!!') ;
else
if exist(fullfilename(handles, data_selected, '.nii'), 'file') == 2
movefile(fullfilename(handles, data_selected, '.nii'), strcat(char(handles.database.Path(data_selected)),new_nii_filename{:},'.nii'), 'f')
end
if exist(fullfilename(handles, data_selected, '.nii.gz'), 'file') == 2
movefile(fullfilename(handles, data_selected, '.nii.gz'), strcat(char(handles.database.Path(data_selected)),new_nii_filename{:},'.nii.gz'), 'f')
end
% rename json file if needed
if exist(fullfilename(handles, data_selected, '.json'), 'file') == 2
movefile(fullfilename(handles, data_selected, '.json'), strcat(char(handles.database.Path(data_selected)),new_nii_filename{:},'.json'), 'f');
end
% rename mat file if needed
if exist(fullfilename(handles, data_selected, '.mat'), 'file') == 2
movefile(fullfilename(handles, data_selected, '.mat'), strcat(char(handles.database.Path(data_selected)),new_nii_filename{:},'.mat'), 'f');
end
end
% update the Filename field in the table
handles.database.SequenceName(data_selected) = newparameter;
handles.database.Filename(data_selected) = new_nii_filename;
% save the structure
guidata(hObject, handles);
%% update graph and display
MP3_update_database_display(hObject, eventdata, handles);
% Save database
MP3_menu_save_database_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function MP3_remove_scan_Callback(hObject, eventdata, handles)
% hObject handle to MP3_remove_scan (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, 'database')
return
end
nii_index = finddata_selected(handles);
user_response = questdlg('Do you want to delete these data ??', 'Warning', 'Yes', 'No', 'Cancel', 'Cancel');
if strcmp(user_response, 'Cancel') || strcmp(user_response, 'No') || isempty(user_response)
return
end
MP3_remove_scan(hObject, eventdata, handles, nii_index)
% --------------------------------------------------------------------
function MP3_remove_time_point_Callback(hObject, eventdata, handles)
% hObject handle to MP3_remove_time_point (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, 'database')
return
end
data_selected = finddata_selected(handles);
Time_point_selected = unique(handles.database.Tp(data_selected));
patient_selected = unique(handles.database.Patient(data_selected));
user_response = questdlg(['Do you want to delete every data of ' char(Time_point_selected) '??'], 'Warning', 'Yes', 'No', 'Cancel', 'Cancel');
if strcmp(user_response, 'Cancel') || strcmp(user_response, 'No')
return
end
nii_index = find(handles.database.Patient == patient_selected & handles.database.Tp == Time_point_selected);
MP3_remove_scan(hObject, eventdata, handles, nii_index)
% --------------------------------------------------------------------
function MP3_ScanVoi_right_click_Callback(~, ~, ~)
% hObject handle to MP3_ScanVoi_right_click (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function MP3_update_figureName(~, ~, handles)
num_timepoint = 0;
patient_listing = unique(handles.database.Patient);
for i=1:numel(patient_listing)
num_timepoint = num_timepoint+ numel(unique(handles.database.Tp(handles.database.Patient == patient_listing(i))));
end
Name_soft = 'Medical software for Processing multi-Parametric image Pipelines (Grenoble Institute of neurosciences - France)';
Spl = strsplit(handles.database.Properties.UserData.MP3_data_path, filesep);
Name_Projet = Spl{end-1};
%old_title = get(handles.MP3_GUI, 'Name');
title = [Name_soft, ' ; Projet : ', Name_Projet, ' ; ', num2str(numel(patient_listing)),...
' patients and ', num2str(num_timepoint), ' ','time points'];
set(handles.MP3_GUI, 'Name', title);
function handles = MP3_update_handles_parameters_VOIs(handles)
% parameters_list = [];
% Voi_list = [];
% for patient=1:numel(handles.database)
% for time_point = 1:numel(handles.database(patient).day)
% parameters_list = [parameters_list handles.database(patient).day(time_point).parameters];
% Voi_list = [Voi_list handles.database(patient).day(time_point).VOIs];
% end
% end
% handles.VOIs = [unique(Voi_list) 'Other'];
VOIs_list = {};
for i=1:numel(handles.database)
for j = 1:numel(handles.database(i).day)
VOIs_list = [VOIs_list handles.database(i).day(j).VOIs];
end
end
handles.VOIs = [unique(VOIs_list), 'Other'];
guidata(handles.MP3_GUI, handles);
function MP3_load_axes_Callback(hObject, eventdata, handles)
if get(handles.MP3_Others_button, 'Value') == 1
warndlg('Such files cannot be display in MP3','Warning');
return
end
% by default this slider is hidded
set(handles.MP3_PRM_slider_trans, 'Visible', 'off');
if ~isfield(handles, 'database') || isempty(handles.database)
return
end
% MP3 cannot load scan(s) if multiple patients are selected
if numel(get(handles.MP3_name_list, 'Value')) > 1
warndlg('Please select only 1 patient before loading scan(s)','Warning');
return
end
scan = get(handles.MP3_scans_list, 'Value');
% Load VOIs
if handles.mode == 2 && numel(scan) > 1
if get(handles.MP3_scans_button, 'Value') == 1
warndlg('Please select only 1 Scan when using the longitudinal view mode','Warning');
elseif get(handles.MP3_VOIs_button, 'Value') == 1
warndlg('Please select only 1 VOI when using the longitudinal view mode','Warning');
end
return
end
if get(handles.MP3_VOIs_button, 'Value') && isfield(handles, 'data_loaded') || ...
get(handles.MP3_scans_button, 'Value') && isfield(handles, 'data_selected_for_PRM')
handles = MP3_load_VOIs(hObject, eventdata, handles);
MP3_update_axes(hObject, eventdata, handles)
return
elseif get(handles.MP3_VOIs_button, 'Value') && ~isfield(handles, 'data_loaded')
warndlg('Please load a scan first','Warning');
return
end
handles = MP3_clear_data(hObject, eventdata, handles);
% display a waiting symbol
set(handles.MP3_GUI, 'pointer', 'watch');
% Load Scans
if handles.mode == 1
handles = MP3_load_axes_single(hObject, eventdata, handles);
else
handles = MP3_load_axes_PRM(hObject, eventdata, handles);
% if all conditions are not present --> return
if ~isfield(handles, 'data_loaded')
return
end
list_day = ['-1', string(handles.data_loaded.info_data_loaded.Tp)'];
set(handles.MP3_PRM_ref_popupmenu, 'String', list_day', 'Value', 2);
%set MP3_PRM_slider
set(handles.MP3_PRM_slider_tp, 'Max', handles.data_loaded.number_of_scan);
set(handles.MP3_PRM_slider_tp,'Value',1);
set(handles.MP3_PRM_slider_tp,'Min',1);
set(handles.MP3_PRM_slider_tp,'Visible', 'on');
set(handles.MP3_PRM_slider_tp,'SliderStep',[1/(handles.data_loaded.number_of_scan-1) min(5/(handles.data_loaded.number_of_scan-1),1)]);
end
drawnow;
MP3_update_axes(hObject, eventdata, handles)
set(handles.MP3_GUI, 'pointer', 'arrow');
%toc(tstart)
function handles = MP3_load_VOIs(hObject, ~, handles)
data_selected = finddata_selected(handles);
handles.data_loaded.info_data_loaded(handles.data_loaded.info_data_loaded.Type == 'ROI',:) =[];
if isfield(handles.data_loaded, 'ROI')
handles.data_loaded= rmfield(handles.data_loaded, 'ROI');
handles.data_loaded= rmfield(handles.data_loaded, 'number_of_ROI');
end
if isfield(handles.data_displayed, 'ROI')
handles.data_displayed= rmfield(handles.data_displayed, 'ROI');
end
handles.data_loaded.info_data_loaded(handles.data_loaded.info_data_loaded.Type == 'Cluster',:) =[];
if isfield(handles.data_loaded, 'Cluster')
handles.data_loaded= rmfield(handles.data_loaded, 'Cluster');
handles.data_loaded= rmfield(handles.data_loaded, 'number_of_Cluster');
end
if isfield(handles.data_displayed, 'Cluster')
handles.data_displayed= rmfield(handles.data_displayed, 'Cluster');
end
handles.data_loaded.number_of_ROI = 0;
handles.data_loaded.number_of_Cluster = 0;
for i = 1:numel(data_selected)
if ~exist(fullfilename(handles, data_selected(i), '.nii'), 'file') && exist(fullfilename(handles, data_selected(i), '.nii.gz'), 'file')
gunzip(fullfilename(handles, data_selected(i), '.nii.gz'));
assert(exist(fullfilename(handles, data_selected(i), '.nii'), 'file')==2)
delete(fullfilename(handles, data_selected(i), '.nii.gz'))
end
fid_nii=fopen(fullfilename(handles, data_selected(i), '.nii'),'r');
if fid_nii>0
fclose(fid_nii);
% scan_of_reference = get(handles.MP3_orientation_space_popupmenu, 'Value');
if strcmp(char(handles.database(data_selected(i),:).Type), 'ROI')
%% read and load the nii file
handles.data_loaded.number_of_ROI = handles.data_loaded.number_of_ROI+1;
handles.data_loaded.ROI(handles.data_loaded.number_of_ROI).V = spm_vol(char(fullfilename(handles, data_selected(i), '.nii')));
% handles.data_loaded.ROI(i).nii = read_volume(handles.data_loaded.ROI(i).V, handles.data_loaded.Scan(scan_of_reference).V,3, handles.view_mode);
% handles.data_loaded.ROI(i).nii(handles.data_loaded.ROI(i).nii>0) = 1;
handles.data_loaded.info_data_loaded = [handles.data_loaded.info_data_loaded; handles.database(data_selected(i),:)];
elseif strcmp(char(handles.database(data_selected(i),:).Type), 'Cluster')
set(handles.MP3_PRM_slider_trans, 'Visible', 'on');
%% read and load the nii file
handles.data_loaded.number_of_Cluster = handles.data_loaded.number_of_Cluster+1;
handles.data_loaded.Cluster(handles.data_loaded.number_of_Cluster).V = spm_vol(char(fullfilename(handles, data_selected(i), '.nii')));
% handles.data_loaded.ROI(i).nii = read_volume(handles.data_loaded.ROI(i).V, handles.data_loaded.Scan(scan_of_reference).V,3, handles.view_mode);
% handles.data_loaded.ROI(i).nii(handles.data_loaded.ROI(i).nii>0) = 1;
handles.data_loaded.info_data_loaded = [handles.data_loaded.info_data_loaded; handles.database(data_selected(i),:)];
end
else
warndlg('something wrong with the data. Nii or json file is missing','Warning');
return
end
guidata(hObject, handles);
end
function handles = MP3_load_axes_single(hObject, ~, handles)
data_selected = finddata_selected(handles);
if numel(data_selected) > 4 % select only the 4 first scan
data_selected = data_selected(1:4);
end
for i = 1:numel(data_selected)
if ~exist(fullfilename(handles, data_selected(i), '.nii'), 'file') && exist(fullfilename(handles, data_selected(i), '.nii.gz'), 'file')
gunzip(fullfilename(handles, data_selected(i), '.nii.gz'));
assert(exist(fullfilename(handles, data_selected(i), '.nii'), 'file')==2)
delete(fullfilename(handles, data_selected(i), '.nii.gz'))
end
fid_nii=fopen(fullfilename(handles, data_selected(i), '.nii'),'r');
fid_json=fopen(fullfilename(handles, data_selected(i), '.json'),'r');
if fid_nii>0 && fid_json>0
fclose(fid_nii);
fclose(fid_json);
%% read and load the json file
handles.data_loaded.Scan(i).json = spm_jsonread(fullfilename(handles, data_selected(i), '.json'));
%% read and load the nii file
handles.data_loaded.Scan(i).V =spm_vol(fullfilename(handles, data_selected(i), '.nii'));
else
warndlg('something wrong with the data. Nii of json file is missing','Warning');
return
end
clear new
end
set(handles.MP3_patient_information_title, 'String', [char(unique(handles.database.Patient(data_selected))) '_' char(unique(handles.database.Tp(data_selected)))]);
set(handles.MP3_orientation_space_popupmenu, 'String', char(unique(handles.database.SequenceName(data_selected),'stable')), 'Value', 1);
if numel(data_selected) > 1
set(handles.MP3_orientation_space_popupmenu, 'Visible', 'on');
set(handles.MP3_orientation_space_text, 'Visible', 'on');
else
set(handles.MP3_orientation_space_popupmenu, 'Visible', 'off');
set(handles.MP3_orientation_space_text, 'Visible', 'off');
end
handles.data_loaded.number_of_scan = numel(data_selected);
handles.data_loaded.info_data_loaded = handles.database(data_selected,:);
guidata(hObject, handles);
if ~isempty(findobj('type', 'figure', 'name', 'FileHistory')) && length(handles.data_loaded.Scan) == 1
% Get the hObject of MP3_pipeline
h = findobj('type', 'figure', 'name', 'FileHistory');
% Get the handles of MP3_pipeline
data = guidata(h);
% Update the handles of MP3_pipeline by stocking the latest version of
% MP3 handles.
data.MP3_data = handles;
% Don't touch the original eventdata, just in case.
%Update the MP3_pipeline tmp_database
data.FileHistory_JobsListbox.Value = 1;
[h,data] = FileHistory('UpdateJobsList', h, data);
%[~, ~, data] = MP3_pipeline('MP3_pipeline_UpdateTables', h, eventdata2, data);
guidata(h, data)
elseif ~isempty(findobj('type', 'figure', 'name', 'FileHistory'))
close(findobj('type', 'figure', 'name', 'FileHistory'))
end
function handles = MP3_load_axes_PRM(hObject, ~, handles)
% PRM mode i.e. need to open the one parameter (diffusion
% or perfusion or...) for every time point
data_selected = finddata_selected(handles);
if numel(data_selected) ~= 1
warndlg('In longitudinal view mode you can open only on scan!!', 'Warning');
return
end
% find indice of the same scan name across each time point to the selected
% patient
data_to_load = find(handles.database.Patient == handles.database.Patient(data_selected) &...
handles.database.SequenceName == handles.database.SequenceName(data_selected));
[~, idx] =sort(handles.database.Tp(data_to_load));
data_to_load = data_to_load(idx);
if numel(data_to_load) <2
warndlg(strcat({'Need more than one '}, char(handles.database.SequenceName(data_selected)), ' scan to run the longitudinal view mode') ,'Warning');
return
end
⛳️ 运行结果
🔗 参考文献
[1] 方玲玲,王欣.基于超体素的多模态MRI脑肿瘤分割方法:CN202011276427.6[P].CN112435261A[2023-09-19].
[2] 郭桦.基于深度学习与多模态MRI图像的脑肿瘤分割方法研究[D].电子科技大学,2019.