je voudrais convertir en python:%%
% BiofilmQ
%
% Copyright (c) 2020 Raimo Hartmann, Hannah Jeckel, and Eric Jelli <<PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>>
% Copyright (c) 2020 Drescher-lab, Max Planck Institute for Terrestrial Microbiology, Marburg, Germany
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program.  If not, see <http://www.gnu.org/licenses/>.
%
%%


function varargout = BiofilmQ(varargin)



gui_Singleton = 0;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @BiofilmQ_OpeningFcn, ...
    'gui_OutputFcn',  @BiofilmQ_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

function goOn = triggerSplashScreen(instance)
try
    
    s = getappdata(0,'aeSplashHandle');
    
    goOn = 1;
    
    create_s = 0;
    try
        if isempty(s)
            create_s = 1;
        end
    end
    
    if (create_s && instance == 0) || instance == 1
        if isdeployed
            aniSeq = arrayfun(@(x) sprintf('splash%02d.png', x), 1:24, 'UniformOutput', false);
        else
            animation = dir(fullfile(pwd, 'includes', 'layout', 'splashScreen', 'animation', '*.png'));
            aniSeq = cellfun(@(x, y) fullfile(x, y), repmat({fullfile(pwd, 'includes', 'layout', 'splashScreen', 'animation')}, 1, numel({animation.name})), {animation.name}, 'UniformOutput', false);
        end
        
        s = SplashScreen('BiofilmQ', aniSeq,...
            'ProgressBar', 'on', ...
            'ProgressPosition', 62, ...
            'ProgressRatio', 0.0 );
        
        
        setappdata(0,'aeSplashHandle',s) 
    end
end

function BiofilmQ_OpeningFcn(hObject, eventdata, handles, varargin)

fprintf('=== BiofilmQ - The Biofilm Segmentation Toolbox ===\n')
fprintf('Copyright (c) 2016-2019 by Raimo Hartmann\n');
fprintf('Copyright (c) 2018-2019 by Hannah Jeckel\n');
fprintf('Copyright (c) 2018-2019 by Eric Jelli\n');
fprintf('  Max Planck Institute for Terrestrial Microbiology, Marburg\n');
fprintf('  Philipps Universitaet, Marburg\n');
fprintf('Loading... ');

handles.output = hObject;

currentDir = fileparts(mfilename('fullpath'));
chdir(currentDir);

if ~isdeployed
    addpath(genpath(fullfile(currentDir, 'includes')));
    addpath(currentDir);
else
   if ~exist(fullfile(currentDir, 'includes'), 'dir')
       mkdir(fullfile(currentDir, 'includes'));
   end
   
   if ~exist(fullfile(currentDir, 'includes', 'temp'), 'dir')
       mkdir(fullfile(currentDir, 'includes', 'temp'));
   end
end

toggleBusyPointer(handles, true)


if ~isToolboxAvailable('Image Processing Toolbox')
    msgbox('"Image Processing Toolbox" is required.', 'Toolbox missing', 'error', 'modal');
    delete(f);
end

if ~isToolboxAvailable('Parallel Computing Toolbox')
    msgbox('No "Parallel Computing Toolbox" found. Processing will be very slow.', 'Toolbox missing', 'warn', 'modal');
end

if ~isToolboxAvailable('Curve Fitting Toolbox')
    msgbox('No "Curve Fitting Toolbox" found. Some tasks might not work.', 'Toolbox missing', 'warn', 'modal');
end

handles.java = [];
handles.settings.selectedFile = [];
handles.settings.GUIDisabled = false;
handles.settings.GUIDisabledVisualization = false;
handles.settings.databases = {'stats', 'globalMeasurements'};
handles.settings.databaseNames = {'singleObject', 'global'};
handles.settings.showMsgs = 1;
handles.settings.figureSize = [1715 1100];
handles.settings.channelColors = [1 0 0; 0 1 0; 0 0 1; 1 1 0; 0 1 1; 1 0 1];
handles.settings.padding = 8;
handles.settings.spacing = 8;
handles.settings.objectHeight = 22;
handles.settings.pathGUI = currentDir;
handles.settings.displayMode = '';
handles.settings.useDefaultSettingsOnDirectoryChange = true;

if ismac
    handles.settings.tabLocations = 'top';
else
    handles.settings.tabLocations = 'left';
end

triggerSplashScreen(1);
handles.splashScreenHandle = getappdata(0,'aeSplashHandle');
set(handles.splashScreenHandle,'ProgressRatio', 0.05)



setappdata(0, 'hMain', gcf);

try delete(fullfile(currentDir, 'includes', 'temp', '*')); end

handles = tidyGUIHandles(handles);

if isdeployed
    handles.settings.declumpingMethodImages = { ...
        imread('gridding.png'), ...
        imread('none.png')};
else
    handles.settings.declumpingMethodImages = { ...
        imread(fullfile(currentDir, 'includes', 'help', 'gridding.png')), ...
        imread(fullfile(currentDir, 'includes', 'help', 'none.png'))};
end


imagesc(handles.settings.declumpingMethodImages{1}, 'Parent', handles.axes.axes_declumpingMethod);
box(handles.axes.axes_declumpingMethod, 'off');

try
    axis(handles.axes.axes_declumpingMethod, 'tight', 'equal', 'off')
end

cellParametersCalculate =...
    {'Filter objects', false, 'Click to see options', [], [], 'None', [],...
    'Use the filter option to flag objects, which shall be excluded from the data (for instance background objects). After filtering, objects not within the indicated range are excluded from further analysis, but only deleted, if you perform the task <i>"Remove objects which did not pass filtering"</i>. To perform this second step is highly recommended to reduce file sizes. Only those parameters are available for filtering which have been calculated, yet. To extend the list of available filtering parameters, execute "Calculate object parameters" twice.', ...
    'usage/parameter_calculation.html#filter-objects';...
    'Remove objects which did not pass filtering', false, '', [], [], 'None', [],...
    'Delete objects from the dataset, which have been flagged by the filtering module <i>"Filter objects"</i>.', ...
    'usage/parameter_calculation.html#remove-objects-which-did-not-pass-filtering';...
    'Remove objects on the image border', false, '', [], [], 'None', [],...
    'Remove objects which are intersecting with the crop rectangle (in case the image was cropped) or the image border.', ...
    'usage/parameter_calculation.html#remove-objects-on-the-image-border';...
    'Remove object parameters, option: parameters', false, '', 'char', 'Please enter the parameters (separated by comma) which shall no longer be associated with each object.', 'None', [],...
    'Remove unused/unwanted parameters from the dataset for instance to decrease the file size.', ...
    'usage/parameter_calculation.html#remove-object-parameters';...
    'Surface properties, option: range [vox]', false, 3, 'numeric', 'Enter a range value [in vox].',  'Surface_LocalRoughness, Surface_PerSubstrateArea, Surface_LocalThickness, Biofilm_MeanThickness (global), Biofilm_Roughness (global), Biofilm_OuterSurface (global)', [],...
    'Calculate surface properties per cube object. For the local roughness the amount of surface area around the centroid in a specified range is calculated (local roughness in terms of surface per volume). In addition cubes with identical x and y center positions are merged into a pillar. For each pillar the surface area per pillar base area and the local thickness in terms of local height [in um] is calculated.', ...
    'usage/parameter_calculation.html#surface-properties';...
    'Substrate area', false, '', 'numeric', 'Please enter the index at which the substrate is located in your tif stack.','Architecture_LocalSubstrateArea, Biofilm_SubstrateArea', [],...
    'Calculate area at which the biofilm is attached to the substrate. The substrate is assumed to be the brightest layer of cells in the field of view. If you wish to specify a different substrate index, please insert it in the text field.', ...
    'usage/parameter_calculation.html#substrate-area';...
    'Global biofilm properties', false, '', [], [], 'Biofilm_AspectRatio_HeightToLength Biofilm_AspectRatio_HeightToWidth, Biofilm_AspectRatio_LengthToWidth, Biofilm_BaseEccentricity, Biofilm_BaseArea [in um^2], Biofilm_Volume [in um^3]', [],...
    'Calculate global biofilm properties: aspect ratios, base area, base eccentricity (based on ellipsoidal fit) and total biofilm volume.', ...
    'usage/parameter_calculation.html#global-biofilm-properties';...
    'Convexity', false, '', [], [], 'Shape_Convexity', [],...
    'Calculate the convexity of each object. The convexity can be slightly above one for convex objects due to interpolation.', ...
    'usage/parameter_calculation.html';... 
    'Distance to center biofilm', false, '', [], [], 'Distance_ToBiofilmCenterOfMass [in um], Distance_ToBiofilmCenterAtSubstrate [in um] </b>(distance to the center at the bottom of the biofilm)', [],...
    'Calculate the distance to the center of mass of the biofilm and the distance to the center of the biofilm (which is the center of mass projected to the bottom of the biofilm).', ...
    'usage/parameter_calculation.html#distance-to-center-of-biofilm';...
    'Distance to surface, option: resolution [vox]', false, 2, 'numeric', 'Enter the smoothing range [in vox] to estimate the global biofilm shape.', 'distanceToSurface [in um]', [],...
    'Estimate the distance to the <i>upper</i> biofilm outer surface for each object.', ...
    'usage/parameter_calculation.html#distance-to-surface';...
    'Distance to specific object, option: object ID', false, '', 'numeric', 'Enter the ID of the specific object the centroid-to-centroid distance shall be measured to.', 'distanceToCell_(ID) [in um]', [],...
    'Calculate the distance to a specific object.', ...
    'usage/parameter_calculation.html#distance-to-specific-object';...
    'Local density, option: range [vox]', false, 3, 'numeric', 'Enter the range for the calculation of the local density [in um].', 'Architecture_LocalNumberDensity_(range), Architecture_LocalDensity_(range)', [],...
    'Calculate the local number density (number of cells/sphere of indicated diameter) and the local density (occupied volume fraction). Please note that the local number density is not corrected for image edge effects, whereas the local density is corrected.', ...
    'usage/parameter_calculation.html#local-density';...
    'Fluorescence properties', false, 'Click to see options', [], [], 'This module can measure a vast amount of different parameters (see below)', [],...
    'Calculate fluorescence properties, perform correlations between different fluorescence channels, and extract the Haralick texture features.', ...
    'usage/parameter_calculation.html#fluorescence-properties';...
    'Tag cells', false, 'Click to see options', [], [], 'Name of tagged cells can be freely choosen', [],...
    'Tag cells following certain criteria with user-defined tag names.', ...
    'usage/parameter_calculation.html#id7';...
    'User-defined parameter', false, '', 'file', 'Please choose a Matlab script.', 'User_defined', [],...
    'Use the script "includes/cell processing/actions/user-defined parameters/template.m" as template for creating further models', ...
    'usage/parameter_calculation.html#custom-parameters'};

set(handles.splashScreenHandle,'ProgressRatio', 0.1)

handles.layout.boxPanels.mainVBox = uix.VBox('Parent', handles.mainFig, 'Padding', 10, 'Spacing', 10);

handles.layout.boxPanels.mainHeader = uix.HBox('Parent', handles.layout.boxPanels.mainVBox, 'Spacing', 10);

handles.layout.uipanels.uipanel_experimentFolder.Parent = handles.layout.boxPanels.mainHeader;
handles.layout.uipanels.uipanel_folderStats.Parent = handles.layout.boxPanels.mainHeader;
handles.layout.uipanels.uipanel_status.Parent = handles.layout.boxPanels.mainHeader;

handles.layout.mainLayout = uix.CardPanel('Parent', handles.layout.boxPanels.mainVBox, 'Padding', 0);

if isdeployed
    welcomeMsg = fileread('welcome.html');
    logoPath = which('logo_large.png');
else
    welcomeMsg = fileread(fullfile(currentDir, 'includes', 'layout', 'welcome.html'));
    logoPath = fullfile(currentDir, 'includes', 'layout', 'logo_large.png');
end
logoPath = ['file:///', strrep(logoPath, filesep, '/')];
welcomeMsg = strrep(welcomeMsg, '{{logo}}', logoPath);
welcomeMsg = strrep(welcomeMsg, '{{background_color}}', rgb2hex(get(0,'defaultUicontrolBackgroundColor')));
browserJ = com.mathworks.mlwidgets.html.HTMLBrowserPanel;
handles.uicontrols.text.htmlBrowser = javacomponent(browserJ, [], handles.layout.mainLayout);
handles.uicontrols.text.htmlBrowser.setHtmlText(welcomeMsg);

handles.uicontrols.pushbutton.pushbutton_cancel.Enable = 'off';

handles.layout.tabs.mainTabs = uitabgroup('Parent', handles.layout.mainLayout, 'TabLocation', 'top', 'units', 'characters', 'Position', get(handles.layout.uipanels.uipanel_content, 'Position'));
handles.layout.mainLayout.Selection = 1;
handles.layout.boxPanels.mainVBox.Heights = [65 -1];
delete(handles.layout.uipanels.uipanel_content);

handles = populateTabs(handles, 'uipanel_imageProcessing','mainTabs');
handles = populateTabs(handles, 'uipanel_visualization','mainTabs');

handles.layout.boxPanels.imageProcessing = uix.HBox('Parent', handles.layout.tabs.imageProcessing, 'Spacing', 10, 'Padding', 10);

handles.layout.boxPanels.imageProcessing_filesBoxPanel = uix.BoxPanel('Parent', handles.layout.boxPanels.imageProcessing, 'padding', 10,...
    'Title', handles.layout.uipanels.uipanel_files.Title, 'TitleColor', [0.7490 0.902 1], 'ForegroundColor', [0 0 0]);
handles.layout.boxPanels.imageProcessing_files = uix.VBox('Parent', handles.layout.boxPanels.imageProcessing_filesBoxPanel, 'Spacing', 10);

handles.uicontrols.popupmenu.popupmenu_fileType.Parent = handles.layout.boxPanels.imageProcessing_files;
handles.uitables.files.Parent = handles.layout.boxPanels.imageProcessing_files;
handles.layout.boxPanels.imageProcessing_files_buttonsGrid = uix.VBox('Parent', handles.layout.boxPanels.imageProcessing_files, 'Spacing', handles.settings.spacing);
handles.layout.boxPanels.imageProcessing_files_buttonsGridTop = uix.HBox('Parent', handles.layout.boxPanels.imageProcessing_files_buttonsGrid, 'Spacing', handles.settings.spacing);
handles.uicontrols.pushbutton.pushbutton_files_export.Parent = handles.layout.boxPanels.imageProcessing_files_buttonsGridTop;
uix.Empty('Parent', handles.layout.boxPanels.imageProcessing_files_buttonsGridTop);
handles.uicontrols.pushbutton.pushbutton_files_delete.Parent = handles.layout.boxPanels.imageProcessing_files_buttonsGridTop;
handles.uicontrols.checkbox.files_createPosFolder.Parent = handles.layout.boxPanels.imageProcessing_files_buttonsGrid;
handles.layout.boxPanels.imageProcessing_files_buttonsGrid.Heights = handles.settings.objectHeight*[1, 1];
handles.layout.boxPanels.imageProcessing_files_buttonsGridTop.Widths = [80, -1, 70];
handles.layout.boxPanels.imageProcessing_files.Heights = [handles.settings.objectHeight, -1, 2*handles.settings.objectHeight+handles.settings.spacing];

delete(handles.layout.uipanels.uipanel_files);

handles.layout.boxPanels.imageProcessing_preview_slidePanel = uix.ScrollingPanel('Parent', handles.layout.boxPanels.imageProcessing);
handles.layout.boxPanels.imageProcessing_preview = uix.VBox('Parent', handles.layout.boxPanels.imageProcessing_preview_slidePanel, 'Spacing', 10);

handles.layout.uipanels.uipanel_imageDetails.Parent = handles.layout.boxPanels.imageProcessing_preview;
handles.layout.uipanels.uipanel_plotCellParameters.Parent = handles.layout.boxPanels.imageProcessing_preview;
handles.layout.boxPanels.boxpanel_commandHistory = uix.BoxPanel('Parent', handles.layout.boxPanels.imageProcessing_preview, 'padding', 10,...
    'Title', handles.layout.uipanels.uipanel_commandHistory.Title, 'TitleColor', [0.7490 0.902 1], 'ForegroundColor', [0 0 0]);
handles.uicontrols.listbox.listbox_status.Parent = handles.layout.boxPanels.boxpanel_commandHistory;
delete(handles.layout.uipanels.uipanel_commandHistory);

handles.layout.boxPanels.imageProcessing_workflow = uix.VBox('Parent', handles.layout.boxPanels.imageProcessing, 'Spacing', 10);

handles.layout.uipanels.uipanel_imageRange.Parent = handles.layout.boxPanels.imageProcessing_workflow;

handles.layout.boxPanels.analysis = uix.HBox('Parent', handles.layout.tabs.visualization, 'Spacing', 0, 'Padding', 10);

set(handles.splashScreenHandle,'ProgressRatio', 0.15)

handles.layout.boxPanels.analysis_files = uix.VBox('Parent', handles.layout.boxPanels.analysis, 'Spacing', 10, 'Padding', handles.settings.padding);
handles.layout.boxPanels.analysis_filesBoxPanel = uix.BoxPanel('Parent', handles.layout.boxPanels.analysis_files, 'padding', 10,...
    'Title', handles.layout.uipanels.uipanel_analysis_files.Title, 'TitleColor', [0.7490 0.902 1], 'ForegroundColor', [0 0 0]);

handles.layout.uipanels.uipanel_imageRange_visualization.Parent = handles.layout.boxPanels.analysis_files;


delete(handles.layout.uipanels.uipanel_analysis_files);

handles.layout.boxPanels.analysis_biofilmPreviewBoxPanel = uix.BoxPanel('Parent', handles.layout.boxPanels.analysis_files, 'padding', 10,...
    'Title', handles.layout.uipanels.uipanel_analysis_biofilmPreview.Title, 'TitleColor', [0.7490 0.902 1], 'ForegroundColor', [0 0 0]);

handles.axes.axes_analysis_overview.Parent = handles.layout.boxPanels.analysis_biofilmPreviewBoxPanel;
delete(handles.layout.uipanels.uipanel_analysis_biofilmPreview);

handles.layout.boxPanels.analysis_visualization = uix.VBox('Parent', handles.layout.boxPanels.analysis, 'Padding', 5);
handles.layout.boxPanels.analysis_analysisTabs_slidePanel = uix.ScrollingPanel('Parent', handles.layout.boxPanels.analysis_visualization);
uix.Empty('Parent', handles.layout.boxPanels.analysis_visualization);



handles.layout.tabs.mainTabs.SelectionChangedFcn = @(hObject,eventdata)BiofilmQ('mainTabSelection_Callback',handles.layout.tabs.mainTabs,eventdata,guidata(handles.layout.tabs.mainTabs));

handles.layout.tabs.invisibleTabs = uitabgroup('Parent', handles.layout.uipanels.uipanel_invisibleTabs_placeholder, 'TabLocation', 'top', 'units', 'characters');
handles.layout.tabs.invisibleTabs.Visible = 'off';
handles.layout.tabs.invisibleTab = uitab('Parent', handles.layout.tabs.invisibleTabs);

handles.layout.tabs.workflow = uitabgroup('Parent', handles.layout.tabs.imageProcessing, 'TabLocation', 'top', 'units', 'characters', 'Position', get(handles.layout.uipanels.uipanel_workflow, 'Position'));
delete(handles.layout.uipanels.uipanel_workflow);
handles = populateTabs(handles, 'uipanel_workflow_simulationInput','workflow');
handles = populateTabs(handles, 'uipanel_workflow_customTiffImportPanel', 'workflow');
handles = populateTabs(handles, 'uipanel_workflow_exportNd2','workflow');
handles = populateTabs(handles, 'uipanel_workflow_imagePreparation','workflow');
handles = populateTabs(handles, 'uipanel_workflow_segmentation','workflow');
handles = populateTabs(handles, 'uipanel_workflow_parameters','workflow');
handles = populateTabs(handles, 'uipanel_workflow_cellTracking','workflow');
handles = populateTabs(handles, 'uipanel_workflow_dataExport','workflow');
handles.layout.tabs.workflow.SelectedTab = handles.layout.tabs.workflow.Children(2);

handles.layout.boxPanels.imageProcessing_workflow_slidePanel = uix.ScrollingPanel('Parent', handles.layout.boxPanels.imageProcessing_workflow);
handles.layout.tabs.workflow.Parent = handles.layout.boxPanels.imageProcessing_workflow_slidePanel;

set(handles.splashScreenHandle,'ProgressRatio', 0.2)

handles.layout.tabs.workflow_imagePreparationTabs = uitabgroup('Parent', handles.layout.uipanels.uipanel_workflow_imagePreparationTabs.Parent, 'TabLocation', handles.settings.tabLocations, 'units', 'characters', 'Position', get(handles.layout.uipanels.uipanel_workflow_imagePreparationTabs, 'Position'));
delete(handles.layout.uipanels.uipanel_workflow_imagePreparationTabs);

handles = populateTabs(handles, 'uipanel_workflow_imagePreparation_imageSeriesCuration','workflow_imagePreparationTabs');
handles = populateTabs(handles, 'uipanel_workflow_imagePreparation_colonySeparation','workflow_imagePreparationTabs');
handles = populateTabs(handles, 'uipanel_workflow_imagePreparation_registration','workflow_imagePreparationTabs');

handles.layout.tabs.workflow_segmentationTabs = uitabgroup('Parent', handles.layout.uipanels.uipanel_workflow_segmentationTabs.Parent, 'TabLocation', handles.settings.tabLocations, 'units', 'characters', 'Position', get(handles.layout.uipanels.uipanel_workflow_segmentationTabs, 'Position'));
delete(handles.layout.uipanels.uipanel_workflow_segmentationTabs);

handles = populateTabs(handles, 'uipanel_workflow_segmentation_generalSettings','workflow_segmentationTabs');
handles = populateTabs(handles, 'uipanel_workflow_segmentation_imageSettings','workflow_segmentationTabs');
handles = populateTabs(handles, 'uipanel_workflow_segmentation_preprocessing','workflow_segmentationTabs');
handles = populateTabs(handles, 'uipanel_workflow_segmentation_denoising','workflow_segmentationTabs');
handles = populateTabs(handles, 'uipanel_workflow_segmentation_edgeDetection','workflow_segmentationTabs');
handles = populateTabs(handles, 'uipanel_workflow_segmentation_thresholding','workflow_segmentationTabs');
handles = populateTabs(handles, 'uipanel_workflow_segmentation_objectDeclumping','workflow_segmentationTabs');
handles = populateTabs(handles, 'uipanel_workflow_segmentation_postprocessing','workflow_segmentationTabs');

set(handles.splashScreenHandle,'ProgressRatio', 0.25)


handles.layout.tabs.workflow_exportTabs = uitabgroup('Parent', handles.layout.uipanels.uipanel_workflow_dataExport_methodTabs.Parent, 'TabLocation', 'top', 'units', 'characters', 'Position', get(handles.layout.uipanels.uipanel_workflow_dataExport_methodTabs, 'Position'));
delete(handles.layout.uipanels.uipanel_workflow_dataExport_methodTabs)

handles = populateTabs(handles, 'uipanel_workflow_dataExport_vtk','workflow_exportTabs');
handles = populateTabs(handles, 'uipanel_workflow_dataExport_fcs','workflow_exportTabs');
handles = populateTabs(handles, 'uipanel_workflow_dataExport_csv','workflow_exportTabs');

set(handles.splashScreenHandle,'ProgressRatio', 0.3)


handles.mainFig = addIcon(handles.mainFig);

set(handles.splashScreenHandle,'ProgressRatio', 0.35)

handles = restylePanel(handles, handles.layout.uipanels.uipanel_cellParameters_parameterTabs, [1.0000 0.6784 0.64310]);

handles = addPanelToBoxPanel(handles, 'uipanel_parameters_filtering', 'boxpanel_cellParameters_parameterTabs');
handles = addPanelToBoxPanel(handles, 'uipanel_parameters_intensityFeatures', 'boxpanel_cellParameters_parameterTabs');
handles = addPanelToBoxPanel(handles, 'uipanel_parameters_tagCells', 'boxpanel_cellParameters_parameterTabs');
handles = addPanelToBoxPanel(handles, 'uipanel_parameters_inputTemplate', 'boxpanel_cellParameters_parameterTabs');
handles = addPanelToBoxPanel(handles, 'uipanel_parameters_inputTemplate_file', 'boxpanel_cellParameters_parameterTabs');
handles = addPanelToBoxPanel(handles, 'uipanel_parameters_mergingSplitting', 'boxpanel_cellParameters_parameterTabs');

handles = restylePanel(handles, handles.layout.uipanels.uipanel_experimentFolder);
handles = restylePanel(handles, handles.layout.uipanels.uipanel_imageRange_visualization);
handles = restylePanel(handles, handles.layout.uipanels.uipanel_status);
handles = restylePanel(handles, handles.layout.uipanels.uipanel_imageDetails);
handles = restylePanel(handles, handles.layout.uipanels.uipanel_imageRange);
handles = restylePanel(handles, handles.layout.uipanels.uipanel_segmentationControl);
handles = restylePanel(handles, handles.layout.uipanels.uipanel_parameterDescription);
handles = restylePanel(handles, handles.layout.uipanels.uipanel_plotCellParameters);
handles = restylePanel(handles, handles.layout.uipanels.uipanel_folderStats);

set(handles.splashScreenHandle,'ProgressRatio', 0.4)

handles.uicontrols.text.parameterDescriptionJ = uicomponent('style', 'javax.swing.JTextPane', ...
    'parent', handles.uicontrols.text.parameterDescription.Parent, 'ContentType', 'text/html', 'Editable', false,...
    'Opaque', false);
handles.uicontrols.text.parameterDescriptionJ.Units = 'characters';
handles.uicontrols.text.parameterDescriptionJ.Position = handles.uicontrols.text.parameterDescription.Position;
delete(handles.uicontrols.text.parameterDescription);

handles = replaceUIPanel(handles, 'uipanel_experimentFolder');
handles = replaceUIPanel(handles, 'uipanel_status');
handles = replaceUIPanel(handles, 'uipanel_folderStats');
handles = replaceUIPanel(handles, 'uipanel_imageDetails');

set(handles.splashScreenHandle,'ProgressRatio', 0.45)

handles = replaceUIPanel(handles, 'uipanel_plotCellParameters');
handles = replaceUIPanel(handles, 'uipanel_imageRange');
handles = replaceUIPanel(handles, 'workflow_imagePreparation_imageSeriesCuration');

set(handles.splashScreenHandle,'ProgressRatio', 0.46)

handles = replaceUIPanel(handles, 'workflow_imagePreparation_colonySeparation');
handles = replaceUIPanel(handles, 'workflow_imagePreparation_registration');
handles = replaceUIPanel(handles, 'uipanel_workflow_imagePreparation');
handles = replaceUIPanel(handles, 'uipanel_workflow_exportNd2');
handles = replaceUIPanel(handles, 'uipanel_workflow_simulationInput');
handles = replaceUIPanel(handles, 'uipanel_workflow_customTiffImportPanel');

set(handles.splashScreenHandle,'ProgressRatio', 0.47)

handles = replaceUIPanel(handles, 'uipanel_workflow_segmentation');
handles = replaceUIPanel(handles, 'uipanel_segmentationControl');
handles = replaceUIPanel(handles, 'uipanel_workflow_segmentation_generalSettings');
handles = replaceUIPanel(handles, 'uipanel_workflow_segmentation_imageSettings');
handles = replaceUIPanel(handles, 'uipanel_workflow_segmentation_preprocessing');


set(handles.splashScreenHandle,'ProgressRatio', 0.50)

handles = replaceUIPanel(handles, 'uipanel_workflow_segmentation_denoising');
handles = replaceUIPanel(handles, 'uipanel_workflow_segmentation_edgeDetection');
handles = replaceUIPanel(handles, 'uipanel_workflow_segmentation_thresholding');
handles = replaceUIPanel(handles, 'uipanel_workflow_segmentation_objectDeclumping');
handles = replaceUIPanel(handles, 'uipanel_workflow_segmentation_postprocessing');

set(handles.splashScreenHandle,'ProgressRatio', 0.53)

handles = replaceUIPanel(handles, 'uipanel_workflow_parameters');
handles = replaceUIPanel(handles, 'uipanel_parameterDescription');
handles = replaceUIPanel(handles, 'uipanel_parameters_filtering');
handles = replaceUIPanel(handles, 'uipanel_parameters_mergingSplitting');
handles = replaceUIPanel(handles, 'uipanel_parameters_inputTemplate_file');

set(handles.splashScreenHandle,'ProgressRatio', 0.58)

handles = replaceUIPanel(handles, 'uipanel_parameters_inputTemplate');

handles = replaceUIPanel(handles, 'uipanel_parameters_intensityFeatures');
handles = replaceUIPanel(handles, 'uipanel_parameters_tagCells');
handles = replaceUIPanel(handles, 'uipanel_workflow_cellTracking');

set(handles.splashScreenHandle,'ProgressRatio', 0.6)

handles = replaceUIPanel(handles, 'uipanel_workflow_dataExport');
handles = replaceUIPanel(handles, 'uipanel_workflow_dataExport_vtk');
handles = replaceUIPanel(handles, 'uipanel_workflow_dataExport_fcs');

set(handles.splashScreenHandle,'ProgressRatio', 0.65)

handles = replaceUIPanel(handles, 'uipanel_workflow_dataExport_csv');
handles = replaceUIPanel(handles, 'uipanel_imageRange_visualization');

set(handles.splashScreenHandle,'ProgressRatio', 0.7)


handles.layout.tabs.workflow_segmentation_generalSettings.Parent = handles.layout.tabs.invisibleTabs;
handles.layout.tabs.workflow_segmentation_thresholding.Parent = handles.layout.tabs.workflow_segmentationTabs;
handles.layout.tabs.workflow_segmentation_edgeDetection.Parent = handles.layout.tabs.invisibleTabs;
sortTabs(handles.layout.tabs.workflow_segmentationTabs);
handles.uicontrols.checkbox.median3D.Value = 0;
handles.uicontrols.popupmenu.declumpingMethod.Value = 1;
handles.uicontrols.edit.gridSpacing.String = '20';
handles.uicontrols.checkbox.stopProcessingNCellsMax.Value = 0;
handles.uicontrols.checkbox.removeVoxels.Value = 0;
handles.uicontrols.text.text_workflow_segmentation_preprocessing_gamma.Visible = 'off';
handles.uicontrols.popupmenu.gamma.Visible = 'off';
handles.uicontrols.text.text_workflow_segmentation_preprocessing_gammaDescr.Visible = 'off';

handles.uitables.cellParametersCalculate.Data = cellParametersCalculate(:, 1:3);
handles.tableData = cellParametersCalculate;

handles.uitables.files.Data = {'No images loaded'};

handles.uitables.intensity_tasks.Data = [];
handles.uitables.tagCells_rules.Data = [];

handles = loadAnalysisPanel(handles);
handles.layout.boxPanels.boxpanel_biofilmAnalysis.Parent = handles.layout.boxPanels.analysis_analysisTabs_slidePanel;

handles = loadAdditionalModules(handles);


sortTabs(handles.layout.tabs.workflow_imagePreparationTabs, true);

handles = centerTexts(handles);

set(handles.splashScreenHandle,'ProgressRatio', 0.75)

handles.layout.boxPanels.imageProcessing_preview.Children = [...
    handles.layout.boxPanels.boxpanel_commandHistory,...
    handles.layout.boxPanels.boxpanel_plotCellParameters,...
    handles.layout.boxPanels.boxpanel_imageDetails];
handles.layout.boxPanels.imageProcessing_preview.Heights = [605, -3, -1];
handles.layout.boxPanels.imageProcessing_preview.MinimumHeights = [605, 200, 70];
handles.layout.boxPanels.imageProcessing_preview_slidePanel.MinimumHeights = 895;

handles.layout.boxPanels.imageProcessing_workflow.Children = [...
    handles.layout.boxPanels.imageProcessing_workflow_slidePanel,...
    handles.layout.boxPanels.boxpanel_imageRange];

handles.layout.boxPanels.imageProcessing_workflow.Heights = [handles.settings.objectHeight+2*handles.settings.padding+3*handles.settings.spacing, -1];
handles.layout.boxPanels.imageProcessing_workflow_slidePanel.MinimumHeights = 1;
handles.layout.boxPanels.imageProcessing_workflow_slidePanel.MinimumWidths = 720;

handles.layout.boxPanels.analysis_files.Children = [...
    handles.layout.boxPanels.analysis_biofilmPreviewBoxPanel,...
    handles.layout.boxPanels.analysis_filesBoxPanel,...
    handles.layout.boxPanels.boxpanel_imageRange_visualization];

handles.layout.boxPanels.analysis_files.Heights = [60 -1 200];

set(handles.splashScreenHandle,'ProgressRatio', 0.80)

handles.layout.boxPanels.analysis_visualization.Heights = [-1, 0];
handles.layout.boxPanels.analysis_analysisTabs_slidePanel.MinimumHeights = 500;
handles.layout.boxPanels.analysis_analysisTabs_slidePanel.MinimumWidths = 1;
handles.layout.boxPanels.analysis.Widths = [490 -1];

handles.layout.boxPanels.mainHeader.Widths = [-2 -1.3 -1];
handles.layout.boxPanels.mainHeader.MinimumWidths = [300 300 0];
handles.layout.boxPanels.imageProcessing.Widths = [430, 390, -1];
set(handles.splashScreenHandle,'ProgressRatio', 0.85)

try
    drawnow;
    handles.java.files_javaHandle = findjobj(handles.uitables.files);
    jscrollpane = javaObjectEDT(handles.java.files_javaHandle);
    viewport    = javaObjectEDT(jscrollpane.getViewport);
    jtable      = javaObjectEDT(viewport.getView);
    handles.java.files_jtable = jtable;
    
    [jtable, jscrollpane] = createJavaTable(uix.VBox('Parent', handles.layout.boxPanels.analysis_filesBoxPanel), {@analysis_files_CellSelectionCallback, handles});
    handles.java.tableAnalysis = {jtable, jscrollpane};
    set(handle(jtable.getModel, 'CallbackProperties'));
    
catch
    uiwait(msgbox('Could not retrieve underlying java object for file table!', 'Please note', 'error', 'modal'));
end

set(handles.splashScreenHandle,'ProgressRatio', 0.90)

handles = toggleUIElements(handles, 0, 'image_processing', 'init');
handles = toggleUIElements(handles, 0, 'visualization', 'init');

set(handles.splashScreenHandle,'ProgressRatio', 0.95)

set(handles.axes.axes_status, 'XTick', [], 'YTick', []);

set(handles.mainFig, 'units', 'pixels');
pos = get(handles.mainFig, 'Position');
pos(3) = handles.settings.figureSize(1);
pos(4) = handles.settings.figureSize(2);
screenSize = get(0,'screensize');

if screenSize(3) >= pos(3)
    pos(1) = (screenSize(3)-pos(3))/2;
else
    pos(1) = 0;
    pos(3) = screenSize(3);
end
if screenSize(4) >= pos(4)
    pos(2) = (screenSize(4)-pos(4))/2;
else
    pos(2) = 0;
    pos(4) = screenSize(4);
end

handles = centerTexts(handles);

set(handles.splashScreenHandle,'ProgressRatio', 1)

set(handles.mainFig, 'Position', pos, 'Resize', 'on');

handles.layout.boxPanels.imageProcessing_filesBoxPanel.HelpFcn = {@openHelp, 'usage/fileInput.html'};
handles.layout.boxPanels.boxpanel_experimentFolder.HelpFcn = {@openHelp, 'usage/fileInput.html'};
handles.layout.boxPanels.boxpanel_biofilmAnalysis.HelpFcn = {@openHelp, 'usage/visualization.html'};
handles.layout.boxPanels.boxpanel_segmentationControl.HelpFcn = {@openHelp, 'usage/segmentation.html'};
handles.layout.boxPanels.boxpanel_parameterDescription.HelpFcn = {@openHelp, 'usage/parameter_calculation.html'};
handles.layout.boxPanels.boxpanel_cellParameters_parameterTabs.HelpFcn = {@openHelp, 'usage/parameter_calculation.html'};

handles = deleteEmptyPanels(handles);

assignin('base', 'handles', handles)
assignin('base', 'hObject', hObject)

guidata(hObject, handles);

function varargout = BiofilmQ_OutputFcn(hObject, eventdata, handles)

varargout{1} = handles.output;

fprintf('Done.\n');
deleteSplashScreen(handles.splashScreenHandle)
toggleBusyPointer(handles, false)