Skip to content
Snippets Groups Projects
initialise_gt.m 8.42 KiB
Newer Older
function initialise_gt()
% INITIALISE.M for Matlab installations on Windows, Macs, and Linux
% in process of being modified - Greg & Wolfgang, August 2005
% should probably change this to a function so that finishing the script
% automatically clears up the variables.  Ugly at the moment
% ADD DESIRED PATH ENTRIES TO THIS LIST FOLLOWING THE EXISTING FORMAT!!
% PT, big bug with image display due to openGL. crashed completely
% ganymedes. disabled the 03/12/07
% '/graintracking',...  % Grain tracking project (WL,MHG,AK) * symlink *
% 24/05/2010  PT correction to ensure that personnal startup is read at the
% end of the initialisation if present for non DCT people
%
% 2011-2012, Modified and improved by Nicola Vigano', vigano@esrf.fr
% 2012, Modified and improved by Yoann Guilhem, guilhem@esrf.fr

    pathstruct={...                     % Tools from ID19's legacy code
            {'/' },...
            {'/art' },...               % Algebraic reconstruction attempts
            {'/util' },...
            {'/stitching' },...         % Image stitching code
            {'/stitching/heprom' },...
            {'/sliceomatic' },...       % Viewing tool for volumes
            {'/IBF' },...               % IBF tools (Olivier Hignette & Greg Johnson)
            {'/moretomo' },...          % tomography tools in development
            {'/tracking' },...          % particle tracking (Weitzlab, www.harvard.edu)
            {'/ringcorrection' },...    % ring correction code
            {'/imagej' },...            % imagej support
            {'/lsge-matlab' },...       % fitting routines from the NPL in the UK
            {'/lamino' }...             % laminography specific (LH)
            {'/tomotools', '-begin'}... % Tools for tomography
            };
%             {'/parallel' },...          % embarrasingly parallel matlab (ML and GJ)

    disp('Graintracking settings in progress...');

    % No multi platform support, at the moment.
    disp(['Machine is: ', computer])
Nicola Vigano's avatar
Nicola Vigano committed
    deprecated_id19_paths = fullfile('/data','id19','archive','matlab');
Nicola Vigano's avatar
Nicola Vigano committed
    if (~exist(deprecated_id19_paths, 'dir'))
        error(['ERROR: No folder called: "' deprecated_id19_paths '"'])
    % Adding paths
    for n = 1:length(pathstruct)
        switch size(pathstruct{n}, 2)
Nicola Vigano's avatar
Nicola Vigano committed
            addpath(fullfile(deprecated_id19_paths, pathstruct{n}{1}))
Nicola Vigano's avatar
Nicola Vigano committed
            addpath(fullfile(deprecated_id19_paths, pathstruct{n}{1}), pathstruct{n}{2})
        otherwise
            disp(['Wrong parameters number for entry "', n, '"(', pathstruct{n}{1} ,') of structure "pathstruct"'])
Nicola Vigano's avatar
Nicola Vigano committed
            addpath(fullfile(deprecated_id19_paths, pathstruct{n}{1}))
    % suppress extra linefeeds in command window
    format compact

    %%%%%%%%%%%%%%%%%%%%%%
    % other special settings

    % changing default settings at root level
    set(0,'DefaultFigurePaperType','A4')
    set(0,'DefaultFigurePaperUnits','centimeters')
    %set(0,'DefaultAxesFontName','Times')
    %set(0,'DefaultAxesFontSize',12)
    %set(0,'DefaultTextFontName','Times')
    %set(0,'DefaultTextFontSize',12)
    %     disp('Enabling OpenGL graphics by default - may cause problems with old versions of XMing')
    %set(0,'DefaultFigureRenderer','opengl');  % permit hardware acceleration if card exists

    % beamline (for alignment)
    global FT_BL
    FT_BL = 'id19';

    % volume selection in fasttomo; values are 'total', 'manual', 'graphics'
    global FT_VOLSELECT
    FT_VOLSELECT = 'graphics';

    % initialise path for graintracking project
    disp('Adding graintracking specific folders to the path')
    global GT_MATLAB_HOME
Nicola Vigano's avatar
Nicola Vigano committed
    GT_MATLAB_HOME = pwd;
    disp(['Using the DCT code in directory ' GT_MATLAB_HOME])

    addpath(GT_MATLAB_HOME)

    addpath(fullfile(GT_MATLAB_HOME, '1_preprocessing'));
    addpath(fullfile(GT_MATLAB_HOME, '1_preprocessing', 'gtSetup_Utils'));
    addpath(fullfile(GT_MATLAB_HOME, '2_difspot'));
    addpath(fullfile(GT_MATLAB_HOME, '3_pairmatching'));
    addpath(fullfile(GT_MATLAB_HOME, '3_pairmatchingGUI'));
    addpath(fullfile(GT_MATLAB_HOME, '4_grains'));
    addpath(fullfile(GT_MATLAB_HOME, '5_reconstruction'));
    addpath(fullfile(GT_MATLAB_HOME, '5_reconstruction', 'AREMIS'));
    addpath(fullfile(GT_MATLAB_HOME, '6_rendering'));
    addpath(fullfile(GT_MATLAB_HOME, '7_fed'));
    addpath(fullfile(GT_MATLAB_HOME, '7_fed', 'AndyFunctions'));
    addpath(fullfile(GT_MATLAB_HOME, '7_fed', 'geometry'));
    addpath(fullfile(GT_MATLAB_HOME, '7_fed', 'Ccode_SpreadInt'));
    addpath(fullfile(GT_MATLAB_HOME, '8_optimization'));

    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Analysis'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Boundaries'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Crack'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Cryst'));
Nicola Vigano's avatar
Nicola Vigano committed
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Cryst', 'file_cif'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_DataStructures'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_DB'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Distortion'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Drawing'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_EDF'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_ErrorHandling'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_ForwardProjection'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Geo'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_GUI'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_GUI', 'GUILayout_v1p10'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_GUI', 'GUILayout_v1p10', 'layoutHelp'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_GUI', 'GUILayout_v1p10', 'Patch'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_GUI', 'FindJObj'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_GVF'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Help'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_ICP'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Imaging'));
Nicola Vigano's avatar
Nicola Vigano committed
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Imaging', 'pmedf'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Indexter'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Maths'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_OAR'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Parameters'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Python'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Smoothing'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Strain'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_Strain2'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_TIFF'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_TomoUtils'));
    addpath(fullfile(GT_MATLAB_HOME, 'zUtil_XML'));

    addpath(fullfile(GT_MATLAB_HOME, 'FigureManagement'));
    addpath(fullfile(GT_MATLAB_HOME, 'orthogonal_slicer'));
    addpath(fullfile(GT_MATLAB_HOME, 'm2html'));

    % C Compiled code
    addpath(fullfile(GT_MATLAB_HOME, 'bin', 'mex'));
    disp('Loading configuration about external libraries from conf.xml')
    % File and dirs patterns
    global GT_DB
    GT_DB = [];
    if isfield(xmlConf, 'database')
        GT_DB.name = xmlConf.database.name;
        GT_DB.host = xmlConf.database.host;
        GT_DB.user = xmlConf.database.user;
        GT_DB.password = xmlConf.database.password;
    else
        GT_DB.name = 'graintracking';
        GT_DB.host = 'graindb.esrf.fr';
        GT_DB.user = 'gtadmin';
        GT_DB.password = 'gtadmin';
    end

Nicola Vigano's avatar
Nicola Vigano committed
    % ASTRA toolkit
    if isfield(xmlConf, 'astra')
        for n = 1:length(xmlConf.astra.mex.path)
            addpath(xmlConf.astra.mex.path{n});
        end
    else
        warning('XML:no_astra_conf', 'Using hardcoded paths for Astra mex files')
        addpath('/scisoft/users/batenbur/gpu/matlab');
        addpath('/scisoft/users/batenbur/gpu/matlab/algorithms');
    end
    % Check which version of matlab compiled the oar executables
    if isfield(xmlConf, 'matlab_command')
        matlabCommand = xmlConf.('matlab_command');
        currentMatlabRelease = version('-release');
        if (~strcmpi(['matlab' currentMatlabRelease], matlabCommand))
            warning('MATLAB_COMPILED:version_mismatch', ...
                    ['You are now running matlab "%s", but the matlab ' ...
                    'command specified in conf.xml is "%s".\nThere is no ' ...
                    'guarantee that OAR jobs will work'], ...
                    currentMatlabRelease, matlabCommand);
        end
    else
        warning('XML:no_matlab_executable_version', ...
                'Couldn''t find matlab executable version in conf.xml');
    end

Nicola Vigano's avatar
Nicola Vigano committed
    disp('Finished adding')
Andrew King's avatar
Andrew King committed