Skip to content
Snippets Groups Projects
Demo.m 3.17 KiB
Newer Older
  • Learn to ignore specific revisions
  • bepi's avatar
    bepi committed
    %% The code is written by Behnaz Pirzamanbein, bepi@dtu.dk last version 2020.08.04
    %% Demo
    
    bepi's avatar
    bepi committed
    close all
    clear
    
    
    addpath(genpath('./Functions'))
    
    bepi's avatar
    bepi committed
    
    %% Defaults
    
    % if you know the path otherwise choose the path using the 
    answer = questdlg('Write data path or browse to the data folder?', 'Data Path','Write','Browse','Browse');
    switch answer
        case 'Write'
            Data_path = '..\..\..\HCP Anywhere\LINX FP08.001\Activity 7 - bending - visualizations and tiff stacks\mat_file\';
        case 'Browse'
            Data_path = uigetdir;
            Data_path = fullfile(Data_path,'\');
            fprintf('Data Path: %s \n', Data_path)
    end
    
    
    bepi's avatar
    bepi committed
    samples = {'out_out_CD','out_out_MD','in_in_CD','in_in_MD'};
    degree = {'0','45','90','180'};
    layer_name = {'outer','inner'};
    
    
    %% extract poitns for the pipeline
    clc
    
    flag_points = 1; % 1 if no point has been extracted and first time use of the code
    flag_save = 0; % 0: to not save the results; 1: to save the results
    
    answer = inputdlg('Contrast Enhansed value:','Contrast',[1 50],{'.7 1.5'}); % this is default based on the data scanned at DTU
    ce = str2num(answer{1});
    
    
    bepi's avatar
    bepi committed
    
    if flag_points
        for i = 1
            sample = samples{i};
    
            for j = 1
    
    bepi's avatar
    bepi committed
                dg = degree{j};
    
                %% load data
                load([Data_path,'Processed_',sample,'_',dg])
    
                %% use the pre_processing to extract the points
                PointSelection
            end
        end
    end
    
    clearvars -except Data_path samples degree layer_name
    
    %% layer segmentation and investigation
    clc
    answer = questdlg('Do you want to enhance the contrast? ','Contrast:','No','Yes','No');
    
    
    for i = 1:4
    
    bepi's avatar
    bepi committed
        sample = samples{i};
        for j = 1:4
            %% load data
            dg = degree{j};
    
            fprintf('Load Data %s %s \n',sample,dg)
            load([Data_path,'Processed_',sample,'_',dg])
            
            %% use the pre_processing to extract the points
            
            % detect the layers
            layer_name = {'outer','inner'};
            
            for l = 1:length(layer_name)
                flag_layer = layer_name{l};
                
                disp(['Layer Detection ',flag_layer])
                load(['Results\point\',flag_layer,'_points_',sample,'_',dg])
                
                Delta_LU = [3, 7];
                
                if any(strcmp(dg,'0') | strcmp(dg,'45'))
                    range = 15:-1:-15;
                else
                    switch flag_layer
                        case 'inner'
                            range = 30:-1:-35;
                        case 'outer'
                            range = 20:-1:-20;
                    end
                end
    
                flag_save = 1;
                flag_fig = 0; % if you want to check the results
    
    bepi's avatar
    bepi committed
                LayerDetection
            end
            
             %% measure
            disp('Measure ...')
    
            flag_save = 1;
    
    bepi's avatar
    bepi committed
            PrepMeasure
            
             %% registration
            disp('Registration ...')
    
            flag_save = 1;
    
    bepi's avatar
    bepi committed
            PrepRegistration
            
        end
    end
    
    %% visualize the measure
    
    for i = 1:4
        flag_save = 1;
    
    bepi's avatar
    bepi committed
        Measure
    end
    close all
    
    %% apply the registration
    
    for i = 1:4
        flag_save = 1;
    
    bepi's avatar
    bepi committed
        Registration
    end
    close all
    
    %% apply the alignment and transformation
    
    for i = 1:4
        flag_save = 1;
        flag_fig = 1;
    
    bepi's avatar
    bepi committed
        Transformation
    end
    close all
    
    %% convert the meshes
    
    for i = 1:4
    
    bepi's avatar
    bepi committed
        Export2inp
    end
    close all