Skip to content

Commit

Permalink
Fix reco size. Add missing angle interpolation.
Browse files Browse the repository at this point in the history
  • Loading branch information
moosmann committed Jul 21, 2021
1 parent 1196aa9 commit f40502f
Show file tree
Hide file tree
Showing 9 changed files with 519 additions and 43 deletions.
29 changes: 26 additions & 3 deletions matlab/astra/astra_parallel3D.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,40 @@
gpu_index = assign_from_struct( tomo, 'astra_gpu_index', [] );
link_data = assign_from_struct( tomo, 'astra_link_data', 0 );
offset_shift = assign_from_struct( tomo, 'offset_shift', 0 );
interpolate_missing_angles = assign_from_struct( tomo, 'interpolate_missing_angles', 0 );


%% Main %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


rotation_axis_offset = rotation_axis_offset + offset_shift;


angles = double( angles );
%rotation_axis_offset = double( rotation_axis_offset );

if interpolate_missing_angles
angles0 = angles; % orginal range
da = angles(2) - angles(1); % angle increment
a0 = angles(1); % First angle
a1 = angles(end); % last original angle
a2 = ceil( a1 / pi ) * pi; % supposed to be final angle plus one inc
angles_missing = (a1+da:da:a2)';

% Interpolation
angles_query = [a1, a2 + a0];
[X1, X2, X3] = meshgrid( angles_query, 1:size( sino, 1), 1:size( sino, 3) );
[X1q, X2q, X3q] = meshgrid( angles_missing, 1:size( sino, 1), 1:size( sino, 3) );
V = cat(2, sino(:,end,:), sino(:,1,:));
switch ndims( sino )
case 2
sino_missing = interp2(X1,X2,V,X1q,X2q);
case 3
sino_missing = interp3(X1,X2,X3,V,X1q,X2q,X3q);
end

% Concatenation
angles = cat(1, angles0, angles_missing); % new angle range
sino = cat(2, sino, sino_missing);
end

% GPU
if isempty( gpu_index )
astra_mex('set_gpu_index', 0:gpuDeviceCount - 1);
Expand Down
7 changes: 6 additions & 1 deletion matlab/experiments/p05/p05_create_reco_loop.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,13 @@ function p05_create_reco_loop( raw_path, scan_name_pattern, out_path, name)
% Write Data Sets
fprintf(fid, '\nraw_path = ''%s/'';', raw_path);
for nn = 1:numel( folders )
fn = folders{nn};
% Skip non tomo folders from in situ measurements
if numel( fn ) > 7 && strcmp( fn(end-7:end), 'setforce')
continue
end
fprintf(fid, '\n' );
fprintf(fid, '\npar.scan_path = [raw_path ''%s'']; ADD', folders{nn});
fprintf(fid, '\npar.scan_path = [raw_path ''%s'']; ADD', fn );
end

% Write bottom: call reco loop
Expand Down
24 changes: 13 additions & 11 deletions matlab/experiments/p05/p05_reco.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,22 @@ function p05_reco( external_parameter )
% !!! OVERWRITES PARAMETERS BELOW QUICK SWITCH SECTION !!!
% Just copy parameter and set quick switch to 1
par.quick_switch = 1;
par.raw_bin = 10;
par.raw_roi = [0.2 0.8];
par.proj_range = 8;
par.ref_range = 10;
par.raw_bin = 3;
par.raw_roi = [];
par.proj_range = 1;
par.ref_range = 1;
par.ref_path = {};
phase_retrieval.apply = 0;
write.to_scratch = 0;
tomo.rot_axis_offset = [];%-9.95 * 2 / par.raw_bin;
write.to_scratch = 1;
tomo.rot_axis_offset = 2 * 3 / par.raw_bin;
tomo.rot_axis_tilt_camera = [];
image_correlation.method = 'median';
image_correlation.num_flats = 19;
%image_correlation.method = 'median';
interactive_mode.rot_axis_pos = 1;
interactive_mode.rot_axis_tilt = 0;
interactive_mode.phase_retrieval = 0;
%write.subfolder_reco = 'tilt-0p001';
%par.pixel_scaling = 0.9985;
tomo.interpolate_missing_angles = 1;
%write.subfolder_reco = 'interpolate_missing_angles';
% END OF QUICK SWITCH TO ALTERNATIVE SET OF PARAMETERS %%%%%%%%%%%%%%%%%%%%

pp_parameter_switch % DO NOT DELETE THIS LINE
Expand Down Expand Up @@ -227,7 +228,7 @@ function p05_reco( external_parameter )
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

weblink_url = 'https://github.com/moosmann/matlab';
weblink_name = sprintf( 'code reposiory on github: %s', weblink_url );
weblink_name = sprintf( 'code repository on github: %s', weblink_url );
weblink = sprintf('<a href = "%s">%s</a>\n', weblink_url, weblink_name);
fprintf( weblink );

Expand Down Expand Up @@ -360,6 +361,7 @@ function p05_reco( external_parameter )
assign_default( 'tomo.angle_scaling', 1 );
assign_default( 'tomo.MinConstraint', [])
assign_default( 'tomo.MaxConstraint', [])
assign_default( 'tomo.interpolate_missing_angles', 0)
assign_default( 'write.path', '' )
assign_default( 'write.parfolder', '' )
assign_default( 'write.subfolder_reco', '' )
Expand Down Expand Up @@ -889,7 +891,7 @@ function p05_reco( external_parameter )
otherwise
vert_shift_micron = s_stage_z.value( 1:num_proj_found );
end
if std( vert_shift_micron )
if abs(std( SubtractMean( vert_shift_micron ) )) > 1e-3
vert_shift_micron = vert_shift_micron(par.proj_range);

% Check
Expand Down
1 change: 1 addition & 0 deletions matlab/experiments/p07/mgsafe_p07_11012079.m
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ function mgsafe_p07_11012079( SUBSETS, RUN_RECO, PRINT_PARAMETERS)
write.to_scratch = 0;
tomo.rot_axis_offset = 2 * 3 / par.raw_bin;
tomo.rot_axis_tilt_camera = [];
tomo.interpolate_missing_angles = 1;
interactive_mode.rot_axis_pos = 0;
interactive_mode.rot_axis_tilt = 0;
%tomo.vol_size = [-1.1 1.1 -1.1 1.1 -0.5 0.5];
Expand Down
Loading

0 comments on commit f40502f

Please sign in to comment.