function ProjectionData=Data_loading
%% 1. Path and measurement info

[filename, pathname]=uigetfile({'*.raw;*.jpg;*.tif;*.png;*.gif' },'C:\');%('*.raw');

 

 k=strfind(filename,'.');
 form=filename(k(end)+1:end);
 
 if strcmp(form, 'raw')
     
     if strcmp('original',filename(1:8))
        name=filename(10:k(end)-1);
        name_proj_info=[pathname name '.raw'];
     elseif contains(filename,'i0') %strcmp('i0',filename(k(end)-2:k(end)-1))
         pom=strfind(filename,'i0');
         name=filename(1:pom-2);
         name_proj_info=[pathname name '.raw'];
     elseif contains(filename,'dark') %strcmp('dark',filename(k(end)-4:k(end)-1))
         pom=strfind(filename,'dark');
         name=filename(1:pom-2);
         name_proj_info=[pathname name '.raw'];
     else
         name=filename(1:k(end)-1);
         name_proj_info=[pathname filename];
     end
     name_proj=[pathname filename];
     [dx_pixel, dy_pixel, binning, exposure, background_value, ...
              xd_pos, pix_size, psf_L, psf_dL, angle_range] ...
              = measurement_info( name_proj_info ); % Determination of projection size + other parameters
        fin=fopen(name_proj);
        proj=fread(fin,'uint16=>uint16'); 
        num_proj = length(proj)/(dx_pixel*dy_pixel); % calculate number of projections
        proj=reshape(proj,dx_pixel,dy_pixel,num_proj);
        proj=permute(proj, [2 1 3]);% Projection transposition
        fclose(fin);
        proj=double(proj);
        % Calculate cone beam parameters
        pix_size = pix_size*binning; % actual pixel size when taking binning into account
        vox_size = pix_size * psf_L / (psf_L + psf_dL + xd_pos); % voxel size of volume
        pix_scale = pix_size/vox_size; % magnification of projections due to cone beam
        SOD = (psf_L * 1000) / vox_size; % SOD in volume voxel units (mm>um>voxels)
        ODD = ((psf_dL + xd_pos) * 1000) / vox_size; % ODD in volume voxel units
        % angles in radians
    %     angles = linspace(0, angle_range * pi/180, num_proj);
 else
     Info=imfinfo([pathname filename]);
     name=filename(1:k(end)-1);
     if length(Info)>1
         proj=zeros(Info(1).Height,Info(1).Width,length(Info));
         for i=1:length(Info)
              proj(:,:,i)=imread(Info(i).Filename,'Index',i);
         end
         
     else
         
         files=dir([pathname '*.' form]);
         proj=zeros(Info(1).Height,Info(1).Width,length(files));
         for i=1:length(files)
             proj(:,:,i)=imread([pathname files(i).name]);
         end
     end
 end
 angles = linspace(0, angle_range * pi/180, num_proj);
 
 ProjectionData.Name=name;
 ProjectionData.Data=double(proj);
 ProjectionData.Num_proj=num_proj;
 ProjectionData.Background_value=background_value;
 ProjectionData.Pixel_size=pix_size;
 ProjectionData.Voxel_size=vox_size;
 ProjectionData.Pixel_scale=pix_scale;
 ProjectionData.SOD=SOD;
 ProjectionData.ODD=ODD;
 ProjectionData.Angle_range=angle_range;
 ProjectionData.Angles=angles;
 ProjectionData.Binning=binning;
 

end