Skip to content

Commit

Permalink
Added add_zero option to generate_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
EuanPyle committed Jan 18, 2022
1 parent c58e178 commit fbda681
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function generate_metadata(ts_dir,ext,scheme,n_flip,dose,thickness)
function generate_metadata(ts_dir,ext,scheme,n_flip,dose,thickness,add_zero)
%This function will generate the metadata needed for RELION 4, including the newst.com & tilt.com files, the tilt order list, and the tomograms_descr.star file
% Dynamo and IMOD must be loaded in this terminal window for this function to work
% The function inputs are: generate_metadata(ts_dir, ext, tilt_scheme, n_flip, dose, tomo_thickness)
Expand All @@ -11,6 +11,7 @@ function generate_metadata(ts_dir,ext,scheme,n_flip,dose,thickness)
% NOTE: For bidirectional tilt schemes n_flip should be left either blank: [], or any number you wish.
% dose = dose per tilt of each image in e/A^2
% tomo_thickness = unbinned thickness of the tomogram to be generated. We tend to use a value of 3000
% add_zero = A rarely used option. Enter 'y' to use. Use if the sign of your tilt series flips after the first image and then goes to a different flipping pattern. e.g. if your tilt flipping is 2 but your tilt series was collected in this order: -0,3,6,-3,-6,9,12,-9,-12,15,18,etc.
%%%%% For newst/tilt.com files, you will be prompeted to either choose to use the template provided (recommended) or if the tomograms produced look strange, you can use your own tilt and newst.com templates after a quick etomo reconstruction. Note, the latter way is error prone.

%%% List of already processed tilt-series
Expand Down Expand Up @@ -104,7 +105,7 @@ function generate_metadata(ts_dir,ext,scheme,n_flip,dose,thickness)

com_file_spoofer(current_ts, x_dim, y_dim, thickness, newst_com, tilt_com);

template_tlt=tilt_template(scheme, max_tilt_angle, tilt_increments, n_flip);
template_tlt=tilt_template(scheme, max_tilt_angle, tilt_increments, n_flip, add_zero);

% Reads .tlt files and removes tilts which are missing

Expand Down
55 changes: 31 additions & 24 deletions relion4_tomo_robot/relion_metadata_generators/tilt_template.m
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
function template_tlt = tilt_template(scheme, max_tilt_angle, tilt_increments, n_flip)
function template_tlt = tilt_template(scheme, max_tilt_angle, tilt_increments, n_flip, add_zero)

% Number of tilts
seq_ntilt=((max_tilt_angle./tilt_increments).*2)+1;

seq=zeros(seq_ntilt,2);

% Generates tilt order for dose symmetric scheme and an n_flip of 2

if contains(scheme,'dose') & contains(scheme,'sym') & (n_flip == 2 | n_flip == '2')
for i=2:4:seq_ntilt
seq(i,2)=seq(i-1,2)+tilt_increments;
seq(i+1,2)=-seq(i,2);
seq(i+2,2)=seq(i+1,2)-tilt_increments;
seq(i+3,2)=-seq(i+2,2);
end
elseif contains(scheme,'dose') & contains(scheme,'sym') & (n_flip == 3 | n_flip == '3')
for i=2:6:seq_ntilt
seq(i,2)=seq(i-1,2)+tilt_increments;
seq(i+1,2)=seq(i-1,2)+(2*tilt_increments);
seq(i+2,2)=-seq(i,2);
seq(i+3,2)=-seq(i,2)-tilt_increments;
seq(i+4,2)=-seq(i,2)-(2*tilt_increments);
seq(i+5,2)=-seq(i+3,2)+(tilt_increments);
seq=zeros(seq_ntilt,2);

if contains(scheme,'dose') & contains(scheme,'sym') & (contains(add_zero,'y'))
seq=zeros(1,2);
for i=1:n_flip:seq_ntilt
offset=i;
for n=0:n_flip-1
seq(end+1,2)=(offset+n)*tilt_increments;
end
for n=0:n_flip-1
seq(end+1,2)=-(offset+n)*tilt_increments;
end
end
elseif contains(scheme,'dose') & contains(scheme,'sym') & (n_flip == 1 | n_flip == '1')
for i=2:2:seq_ntilt
if seq(i-1,2) >= 0
seq(i,2)=seq(i-1,2)+tilt_increments;
elseif contains(scheme,'dose') & contains(scheme,'sym') & ~(contains(add_zero,'y'))
seq=[];
for i=1:n_flip:seq_ntilt
offset=i;
if offset==1
for n=0:n_flip-1
seq(end+1,2)=((offset+n)*tilt_increments) - tilt_increments;
end
for n=0:n_flip-1
seq(end+1,2)=-(offset+n)*tilt_increments;
end
else
seq(i,2)=-seq(i-1,2)+tilt_increments;
for n=0:n_flip-1
seq(end+1,2)=(offset+n)*tilt_increments - tilt_increments;
end
for n=0:n_flip-1
seq(end+1,2)=-(offset+n)*tilt_increments;
end
end
seq(i+1,2)=-seq(i,2);
end

elseif contains(scheme,'bidi') & contains(scheme,'+ve')
seq(:,2) = [0:tilt_increments:max_tilt_angle,-tilt_increments:-tilt_increments:-max_tilt_angle]';
elseif contains(scheme,'bidi') & contains(scheme,'-ve')
Expand Down

0 comments on commit fbda681

Please sign in to comment.