Skip to content

Commit

Permalink
Merge pull request #610 from schorschinho/develop
Browse files Browse the repository at this point in the history
Release v.2.5.0
  • Loading branch information
HJZollner authored Apr 7, 2023
2 parents 514cff2 + 02b2c22 commit d984da5
Show file tree
Hide file tree
Showing 258 changed files with 7,546 additions and 2,335 deletions.
4 changes: 2 additions & 2 deletions GUI/Osprey.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
logoFcn = @()imread('osprey.png', 'BackgroundColor', gui.colormap.Background);
logoBanner = uiw.utility.loadIcon(logoFcn);
% Here the intro banner is created
gui.d = uiw.dialog.About('Name', 'Osprey','Version','2.4.0','Date', 'August 8, 2022',...
gui.d = uiw.dialog.About('Name', 'Osprey','Version','2.5.0','Date', 'April 7, 2023',...
'Timeout', 3,'CustomText', 'Osprey is provided by Johns Hopkins University.',...
'ContactInfo', '[email protected]','LogoCData', logoBanner);

Expand Down Expand Up @@ -74,7 +74,7 @@
set(gui.Buttons, 'ButtonSize', [300 60]);
% Create Job
gui.CreateJob = uicontrol('Parent', gui.Buttons,'Style','PushButton','String','Create Job','ForegroundColor', gui.colormap.Foreground,...
'TooltipString', 'Create a OspreyJob .m-file');
'TooltipString', 'Create a OspreyJob .json-file');
set(gui.CreateJob,'Units','Normalized','Position',[0.1 0.9 0.8 0.08], 'FontSize', 16, 'FontName', gui.font, 'FontWeight', 'Bold');
set(gui.CreateJob,'Callback',{@onCreateJob});
% JobFile input button
Expand Down
40 changes: 29 additions & 11 deletions GUI/OspreyGUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
gui.controls.act_y = 1;
gui.controls.act_z = 1;
gui.controls.act_basis = 1;
gui.overview.Selected.Spec = 1;
%Names for each selection
gui.load.Names.Spec = {'metabolites'};
%Inital number of datasets
Expand All @@ -155,7 +156,11 @@
if strcmp(sprintf('\n'),MRSCont.raw{1,gui.controls.Selected}.seq(end)) %Clean up Sequence Name if needed
gui.load.Names.Seq = MRSCont.raw{1,gui.controls.Selected}.seq(1:end-1);
else
gui.load.Names.Seq = MRSCont.raw{1,gui.controls.Selected}.seq;
if iscell(MRSCont.raw{1,gui.controls.Selected}.seq)
gui.load.Names.Seq = MRSCont.raw{1,gui.controls.Selected}.seq{1,1};
else
gui.load.Names.Seq = MRSCont.raw{1,gui.controls.Selected}.seq
end
end
else
if MRSCont.flags.isUnEdited
Expand Down Expand Up @@ -200,10 +205,9 @@
end
end

if gui.controls.nExperiments > 1
gui.info.nXvoxels = gui.controls.nExperiments;
gui.info.nExperiments = gui.controls.nExperiments;
end
gui.info.nXvoxels = gui.controls.nExperiments;
gui.info.nExperiments = gui.controls.nExperiments;

if MRSCont.flags.didProcess %Get variables regarding the processing
gui.process.Number = length(fieldnames(MRSCont.processed));
gui.info.nYvoxels = MRSCont.processed.metab{1, 1}.subspecs;
Expand Down Expand Up @@ -272,7 +276,10 @@
%Version check and updating log file
MRSCont.flags.isGUI = 1;
outputFolder = MRSCont.outputFolder;


%Add cosmetics
MRSCont.opts.cosmetics.LB = 0;
MRSCont.opts.cosmetics.Zoom = 2.75;
%% Create the overall figure
gui.figure = figure('Name', 'Osprey', 'Tag', 'Osprey', 'NumberTitle', 'off', 'Visible', 'on','Menu', 'none',...
'ToolBar', 'none', 'HandleVisibility', 'on', 'Renderer', 'painters', 'Color', gui.colormap.Background);
Expand Down Expand Up @@ -413,7 +420,10 @@
'ForegroundColor',gui.colormap.Foreground, 'HighlightColor',gui.colormap.Foreground, 'ShadowColor',gui.colormap.Foreground,'Tag','SubjectListPanel');
gui.layout.fileList = MRSCont.files(1,:);
if ~MRSCont.flags.moved
[~, ~] = osp_detDataType(MRSCont);
try
[~, ~] = osp_detDataType(MRSCont);
catch
end
end
SepFileList = cell(1,MRSCont.nDatasets(1));
gui.layout.RedFileList = cell(1,MRSCont.nDatasets(1));
Expand Down Expand Up @@ -537,10 +547,18 @@
close(gui.controls.waitbar);
%% Here we add callback listeners triggered on selection changes
set(gui.layout.tabs,'SelectionChangedFcn',{@osp_SelectionChangedFcn,gui});
set(gui.layout.rawTab, 'SelectionChangedFcn',{@osp_RawTabChangeFcn,gui});
set(gui.layout.proTab,'SelectionChangedFcn',{@osp_ProTabChangeFcn,gui});
set(gui.layout.fitTab, 'SelectionChangedFcn',{@osp_FitTabChangeFcn,gui});
set(gui.layout.quantifyTab, 'SelectionChangedFcn',{@osp_QuantTabChangeFcn,gui});
if MRSCont.flags.didLoad
set(gui.layout.rawTab, 'SelectionChangedFcn',{@osp_RawTabChangeFcn,gui});
end
if MRSCont.flags.didProcess
set(gui.layout.proTab,'SelectionChangedFcn',{@osp_ProTabChangeFcn,gui});
end
if MRSCont.flags.didFit
set(gui.layout.fitTab, 'SelectionChangedFcn',{@osp_FitTabChangeFcn,gui});
end
if MRSCont.flags.didQuantify
set(gui.layout.quantifyTab, 'SelectionChangedFcn',{@osp_QuantTabChangeFcn,gui});
end
set(gui.layout.ListBox,'Callback', {@osp_onListSelection,gui},'KeyPressFcn',{@osp_WindowKeyDown,gui}, 'KeyReleaseFcn', {@osp_WindowKeyUp,gui});

end
Expand Down
6 changes: 3 additions & 3 deletions GUI/osp_OverviewTabChangedFcn.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ function osp_OverviewTabChangedFcn(src,~,gui)
switch NewValue
case 1
osp_updateSpecsOvWindow(gui);
set(gui.controls.pop_specsOvPlot, 'value',gui.process.Selected)
set(gui.controls.pop_specsOvPlot, 'value',gui.overview.Selected.Spec)
case 2
splt_string = strsplit(gui.controls.pop_specsOvPlot.String{gui.process.Selected});
splt_string = strsplit(gui.controls.pop_specsOvPlot.String{gui.overview.Selected.Spec});
if length(splt_string) > 1
if strcmp(splt_string{2},'ref') || strcmp(splt_string{2},'w')
gui.process.Selected = find(contains(gui.controls.pop_meanOvPlot.String,splt_string{2}));
Expand All @@ -39,7 +39,7 @@ function osp_OverviewTabChangedFcn(src,~,gui)
end
end
osp_updatemeanOvWindow(gui);
set(gui.controls.pop_meanOvPlot, 'value',gui.process.Selected)
set(gui.controls.pop_meanOvPlot, 'value',gui.overview.Selected.Spec)
case 3
set(gui.layout.overviewTab, 'selection', 3);
case 4
Expand Down
18 changes: 13 additions & 5 deletions GUI/osp_ProTabChangeFcn.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@ function osp_ProTabChangeFcn(src,~,gui)
% User selected tab refreshs plot
gui.process.Selected = src.Selection;

if MRSCont.processed.(gui.process.Names{gui.process.Selected}){gui.controls.Selected}.dims.extras > 0
gui.info.nXvoxels = MRSCont.processed.(gui.process.Names{gui.process.Selected}){gui.controls.Selected}.sz(MRSCont.processed.(gui.process.Names{gui.process.Selected}){gui.controls.Selected}.dims.extras);
if isfield(MRSCont,'processed')
if MRSCont.processed.(gui.process.Names{gui.process.Selected}){gui.controls.Selected}.dims.extras > 0
gui.info.nXvoxels = MRSCont.processed.(gui.process.Names{gui.process.Selected}){gui.controls.Selected}.sz(MRSCont.processed.(gui.process.Names{gui.process.Selected}){gui.controls.Selected}.dims.extras);
else
gui.info.nXvoxels = 1;
end
else
gui.info.nXvoxels = 1;
end
end
gui.controls.act_x = 1;
if MRSCont.processed.(gui.process.Names{gui.process.Selected}){gui.controls.Selected}.dims.subSpecs > 0
gui.info.nYvoxels = MRSCont.processed.(gui.process.Names{gui.process.Selected}){gui.controls.Selected}.sz(MRSCont.processed.(gui.process.Names{gui.process.Selected}){gui.controls.Selected}.dims.subSpecs);
if isfield(MRSCont,'processed')
if MRSCont.processed.(gui.process.Names{gui.process.Selected}){gui.controls.Selected}.dims.subSpecs > 0
gui.info.nYvoxels = MRSCont.processed.(gui.process.Names{gui.process.Selected}){gui.controls.Selected}.sz(MRSCont.processed.(gui.process.Names{gui.process.Selected}){gui.controls.Selected}.dims.subSpecs);
else
gui.info.nYvoxels = MRSCont.nDatasets(2);
end
else
gui.info.nYvoxels = MRSCont.nDatasets(2);
end
Expand Down
216 changes: 109 additions & 107 deletions GUI/osp_Toolbox_Check.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,123 +32,125 @@
% 2020-05-15: First version of the code.
%% % 1. SAVE OSPREY VERSION%%%
%%% 1. SAVE OSPREY VERSION%%%
OspreyVersion = 'Osprey 2.4.0';
OspreyVersion = 'Osprey 2.5.0';
fprintf(['Timestamp %s ' OspreyVersion ' ' Module '\n'], datestr(now,'mmmm dd, yyyy HH:MM:SS'));
hasSPM = 1; % For the compiled GUI
%% % 2. GET SPMPATH AND TOOLBOXES%%%
warning('off','MATLAB:javaclasspath:jarAlreadySpecified');
addons = matlab.addons.installedAddons;
available = cellstr(table2cell(addons(:,1)));
for tl = 1 : size(addons,1)
try
matlab.addons.enableAddon(addons.Name{tl});
catch
if ~(ismcc || isdeployed)
warning('off','MATLAB:javaclasspath:jarAlreadySpecified');
addons = matlab.addons.installedAddons;
available = cellstr(table2cell(addons(:,1)));
for tl = 1 : size(addons,1)
try
matlab.addons.enableAddon(addons.Name{tl});
catch
end
end
end
addons = matlab.addons.installedAddons;
lic = strcmp({'Enabled'}, addons.Properties.VariableNames);
if ~isempty(lic)
enabled = table2cell(addons(:,lic==1));
else
enabled = table2cell(addons(:,1));
end

[settingsFolder,~,~] = fileparts(which('OspreySettings.m'));
allFolders = strsplit(settingsFolder, filesep);
ospFolder = strjoin(allFolders(1:end-1), filesep); % parent folder (= Osprey folder)

% Get SPM folder and check if SPM12 is installed
spmversion = fileparts(which(fullfile('spm.m')));
if isempty(spmversion)
hasSPM = 0;
elseif strcmpi(spmversion(end-3:end),'spm8')
available{end+1} = 'SPM8';
enabled{end+1} = false;
hasSPM = 0;
else
available{end+1} = 'SPM12';
enabled{end+1} = true;
hasSPM = 1;
end

try
addons = matlab.addons.installedAddons;
lic = strcmp({'Enabled'}, addons.Properties.VariableNames);
if ~isempty(lic)
available(find(cellfun(@(a)~isempty(a)&&a<1,enabled)), :) = [];
end

%%% 3. CHECK AVAILABILTY %%%
switch Module
case 'OspreyGUI'
ModuleString = 'fully run \bfOsprey';
neededGlobal = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox','SPM12'};
neededSpecific = {'Widgets Toolbox', 'GUI Layout Toolbox'};
case 'OspreyProcess'
ModuleString = 'run \bfOspreyProcess';
neededGlobal = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox','SPM12'};
neededSpecific = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox'};
case 'OspreyFit'
ModuleString = 'run \bfOspreyFit';
neededGlobal = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox','SPM12'};
neededSpecific = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox'};
case 'OspreyCoreg'
ModuleString = 'run \bfOspreyCoreg';
neededGlobal = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox','SPM12'};
neededSpecific = {'SPM12'};
case 'OspreySeg'
ModuleString = 'run \bfOspreySeg';
neededGlobal = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox','SPM12'};
neededSpecific = {'SPM12'};
otherwise
ModuleString = ['run \bf' Module];
neededGlobal = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox','SPM12'};
neededSpecific = cellstr({});
enabled = table2cell(addons(:,lic==1));
else
enabled = table2cell(addons(:,1));
end

%To account for the re-naming of new downloads of the Widget Toolbox
%for Matlab versions earlier than 2020b, while maintaining
%functionality for older downloads, we need to check for all naming
%conventions of the Widgets Toolbox HZ
for tb = 1 : length(available)
if contains(available{tb},'Widgets Toolbox')
available{tb} = 'Widgets Toolbox';
[settingsFolder,~,~] = fileparts(which('OspreySettings.m'));
allFolders = strsplit(settingsFolder, filesep);
ospFolder = strjoin(allFolders(1:end-1), filesep); % parent folder (= Osprey folder)

% Get SPM folder and check if SPM12 is installed
spmversion = fileparts(which(fullfile('spm.m')));
if isempty(spmversion)
hasSPM = 0;
elseif strcmpi(spmversion(end-3:end),'spm8')
available{end+1} = 'SPM8';
enabled{end+1} = false;
hasSPM = 0;
else
available{end+1} = 'SPM12';
enabled{end+1} = true;
hasSPM = 1;
end

try
if ~isempty(lic)
available(find(cellfun(@(a)~isempty(a)&&a<1,enabled)), :) = [];
end

%%% 3. CHECK AVAILABILTY %%%
switch Module
case 'OspreyGUI'
ModuleString = 'fully run \bfOsprey';
neededGlobal = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox','SPM12'};
neededSpecific = {'Widgets Toolbox', 'GUI Layout Toolbox'};
case 'OspreyProcess'
ModuleString = 'run \bfOspreyProcess';
neededGlobal = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox','SPM12'};
neededSpecific = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox'};
case 'OspreyFit'
ModuleString = 'run \bfOspreyFit';
neededGlobal = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox','SPM12'};
neededSpecific = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox'};
case 'OspreyCoreg'
ModuleString = 'run \bfOspreyCoreg';
neededGlobal = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox','SPM12'};
neededSpecific = {'SPM12'};
case 'OspreySeg'
ModuleString = 'run \bfOspreySeg';
neededGlobal = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox','SPM12'};
neededSpecific = {'SPM12'};
otherwise
ModuleString = ['run \bf' Module];
neededGlobal = {'Optimization Toolbox', 'Statistics and Machine Learning Toolbox','SPM12'};
neededSpecific = cellstr({});
end
end
missingSpecific = setdiff(neededSpecific,available);
missing = setdiff(neededGlobal,available);

%%% 4. CREATE WARNING MESSAGES %%%
if ~ToolChecked
warningMsg = cellstr({});
warning_count = 1;
if ~isempty(missing) || ~isempty(missingSpecific)
opts.Interpreter = 'tex';
opts.WindowStyle = 'modal';
warningMsg{1} = ['The following toolboxes are missing to ' ModuleString '\rm:'];
for i = 1 : length(missing)
warningMsg{i+1} = ['\bf' missing{i} '\rm'];

%To account for the re-naming of new downloads of the Widget Toolbox
%for Matlab versions earlier than 2020b, while maintaining
%functionality for older downloads, we need to check for all naming
%conventions of the Widgets Toolbox HZ
for tb = 1 : length(available)
if contains(available{tb},'Widgets Toolbox')
available{tb} = 'Widgets Toolbox';
end
warning_count = warning_count +length(missing) + 1;
warningMsg{warning_count} = ['Please install them to ' ModuleString '\rm'];
warning_count = warning_count + 1;
if ~isempty(missingSpecific)
warningMsg{warning_count} = ['The following toolboxes are missing to run ' Module ':'];
warningc = ['Please install and include the following toolboxes to use ' Module ':'];
for i = 1 : length(missingSpecific)
warningMsg{warning_count + i} = ['\bf' missingSpecific{i} '\rm'];
warningc = [warningc ' ' missingSpecific{i}];
end
missingSpecific = setdiff(neededSpecific,available);
missing = setdiff(neededGlobal,available);

%%% 4. CREATE WARNING MESSAGES %%%
if ~ToolChecked
warningMsg = cellstr({});
warning_count = 1;
if ~isempty(missing) || ~isempty(missingSpecific)
opts.Interpreter = 'tex';
opts.WindowStyle = 'modal';
warningMsg{1} = ['The following toolboxes are missing to ' ModuleString '\rm:'];
for i = 1 : length(missing)
warningMsg{i+1} = ['\bf' missing{i} '\rm'];
end
warningMsg{warning_count + length(missingSpecific) + 1} = ['Please install them to use \bf' Module '\rm'];
warning_count = warning_count +length(missing) + 1;
warningMsg{warning_count} = ['Please install them to ' ModuleString '\rm'];
warning_count = warning_count + 1;
if ~isempty(missingSpecific)
warningMsg{warning_count} = ['The following toolboxes are missing to run ' Module ':'];
warningc = ['Please install and include the following toolboxes to use ' Module ':'];
for i = 1 : length(missingSpecific)
warningMsg{warning_count + i} = ['\bf' missingSpecific{i} '\rm'];
warningc = [warningc ' ' missingSpecific{i}];
end
warningMsg{warning_count + length(missingSpecific) + 1} = ['Please install them to use \bf' Module '\rm'];
warndlg(warningMsg,'Missing Toolboxes',opts);
error(warningc);
end
warndlg(warningMsg,'Missing Toolboxes',opts);
error(warningc);
end
warndlg(warningMsg,'Missing Toolboxes',opts);
end
end
end

catch %If the MATLAB version pre-dates the inmplementation of matlab.addons.installedAddons
warningMsg = cellstr({});
warningMsg{1} = 'Your current MATLAB version does not allow the automated toolbox check. We assume that all required toolboxes are available.';
warndlg(warningMsg,'Automated toolbox check not working.',opts);
end
warning('on','MATLAB:javaclasspath:jarAlreadySpecified');

catch %If the MATLAB version pre-dates the inmplementation of matlab.addons.installedAddons
warningMsg = cellstr({});
warningMsg{1} = 'Your current MATLAB version does not allow the automated toolbox check. We assume that all required toolboxes are available.';
warndlg(warningMsg,'Automated toolbox check not working.',opts);
end
warning('on','MATLAB:javaclasspath:jarAlreadySpecified');
end
end
Loading

0 comments on commit d984da5

Please sign in to comment.