Difference between revisions of "Walkthrough on command line based tilt series alignment"

From Dynamo
Jump to navigation Jump to search
Line 11: Line 11:
  
 
The <tt>u</tt> object contains several areas to interact with the workflow. They can be found by autocompletion using the <tt>tab</tt> key. Here, we will proceed step by step; remember that you can write all the command lines in a single <tt>.m</tt> script.
 
The <tt>u</tt> object contains several areas to interact with the workflow. They can be found by autocompletion using the <tt>tab</tt> key. Here, we will proceed step by step; remember that you can write all the command lines in a single <tt>.m</tt> script.
 +
 +
[[ File:alignCommandLine_autocompletionOfUserObject.png |thumb|center| 100px|autocompletion of user object]]
 +
[[ File:alignCommandLine_autocompletionOfFurtherFieldsOfUserObject.png |thumb|center| 100px|autocompletion of further fields of user object]]
  
 
== Basic data==
 
== Basic data==
  <code>u.enter.tiltSeries(fileWorkshop);
+
  <code>u.enter.tiltSeries(file);
 
u.enter.tiltAngles(-57:3:60);</code>
 
u.enter.tiltAngles(-57:3:60);</code>
  
Line 53: Line 56:
 
<tt>dtmslice 'workflows/hivCommandLine.AWF/reconstruction/binnedReconstructionWBP.mrc';</tt>
 
<tt>dtmslice 'workflows/hivCommandLine.AWF/reconstruction/binnedReconstructionWBP.mrc';</tt>
  
 
+
[[ File:alignCommandLine_viewOfTiltLines.png |thumb|center| 600px|view of tilt lines]]
 +
[[ File:alignCommandLine_dtmsliceOfBinnedReconstruction.png |thumb|center| 600px|dtmslice of binned reconstruction]]
 +
[[ File:alignCommandLine_dtmsliceContrastControl.png |thumb|center| 600px|dtmslice contrast control]]
 +
[[ File:alignCommandLine_dtmsliceAfterContrastCorrection.png |thumb|center| 600px|dtmslice after contrast correction]]
 +
[[ File:alignCommandLine_createANewModel.png |thumb|center| 600px|create a new model]]
 +
[[ File:alignCommandLine_showAFullProjection.png |thumb|center| 600px|show a full projection]]
 +
[[ File:alignCommandLine_fullProjectionOfBinnedReconstruction.png |thumb|center| 600px|full projection of binned reconstruction]]
 +
[[ File:alignCommandLine_rightClickOnAPoint.png |thumb|center| 600px|right click on a point]]
 +
[[ File:alignCommandLine_xViewOfClickedPoint.png |thumb|center| 600px|x view of clicked point]]
 +
[[ File:alignCommandLine_mainClickToFixThe3dCoordinates.png |thumb|center| 600px|main click to fix the 3d coordinates]]
 +
[[ File:alignCommandLine_clickAroundTenMarkers.png |thumb|center| 600px|click around ten markers]]
 +
[[ File:alignCommandLine_exportATableIntoTheMatlabWorkspace.png |thumb|center| 600px|export a table into the matlab workspace]]
 +
[[ File:alignCommandLine_theCommandLineShowsTheVariableNameAssignedToTheCreatedTable.png |thumb|center| 600px|the command line shows the variable name assigned to the created table]]
  
 
Now we can save the table as a file:
 
Now we can save the table as a file:
Line 68: Line 83:
 
And then we visualise a projection along <tt>z</tt> of each cropped particle
 
And then we visualise a projection along <tt>z</tt> of each cropped particle
 
  <tt>dslices(targetBinnedParticles,'proj','c');shg;</tt>
 
  <tt>dslices(targetBinnedParticles,'proj','c');shg;</tt>
 +
 +
[[ File:alignCommandLine_dslicesOnBinnedGoldBeads.png |thumb|center| 600px|dslices on binned gold beads]]
  
 
== Reconstruct particles on the fly ==
 
== Reconstruct particles on the fly ==
Line 79: Line 96:
 
tblFull = dynamo_table_rescale(tbl,'factor',2^alignmentBinLevel); </code>
 
tblFull = dynamo_table_rescale(tbl,'factor',2^alignmentBinLevel); </code>
  
 
+
  <tt>source  = 'workflows/hivCommandLine AWF/align/alignedFullStack.mrc';</tt>
  <tt>source  = 'workflows/new.AWF/align/alignedFullStack.mrc';</tt>
 
 
 
  
 
We create a data folder to contain the particles reconstructed on the fly.
 
We create a data folder to contain the particles reconstructed on the fly.
 
  <tt>targetDirectory = 'tempCrop.Data'</tt>;
 
  <tt>targetDirectory = 'tempCrop.Data'</tt>;
if exist(targetDirectory,'dir')==7
 
    o.e('Deleting directory');
 
  rmdir(targetDirectory,'s');
 
end
 
  
Angles are contained in the
 
<tt>angles =  'workflows/new.AWF/align/reconstructionTiltAngles.tlt';</tt>
 
sidelength = 160;
 
  
%
+
Angles actually used during the reconstruction are contained in the ''reconstructionTiltAngles' item of the output folder. Note that they might differ from the nominal angles, as some views might have been eliminated, both explicitely by the user, of by the program not being able to align all tilts.
% shift tomogram center
+
<tt>angles =  'workflows/hivCommandLine.AWF/align/reconstructionTiltAngles.tlt';</tt>
%
+
 
% if the binned visualization tomogram would contain a shift
+
The (binned) coordinates were measured in a binned tomogram, whose dimensionality is requested by <tt>dynamo_table_rec</tt>. We need to provide <tt>dynamo_table_rec</tt> with
% we would have to scale it
+
<tt>visualizationTomogram =  'workflows/ hivCommandLine.AWF/reconstruction/binnedReconstructionWBP.mrc';
visualizationTomogram =  'workflows/ hivCommandLine.AWF/reconstruction/binnedReconstructionWBP.mrc';
 
 
sizeTomogram = dynamo_read_size(visualizationTomogram);
 
sizeTomogram = dynamo_read_size(visualizationTomogram);
sizeTomogramFull = sizeTomogram*2^alignmentBinLevel;
+
sizeTomogramFull = sizeTomogram*2^alignmentBinLevel;</tt>
  
 +
The tomogram center can be shifted in order to account for a possible shift in the centre in the binned reconstruction that was used to crop the particles.
 +
<tt>shiftTomogramCenter = [0,0,0];</tt>
  
%
+
We proceed now to the reconstruction.
% shift tomogram center
+
<tt>sidelengthFullSize = 128;</tt>
%
+
<code>dynamo_table_rec(tblFull,source,angles,targetDirectory,sidelength,....
% if the binned visualization tomogram would contain a shift
 
% we would have to scale it
 
shiftTomogramCenter = [0,0,0];
 
 
 
%
 
% command executions
 
%
 
dynamo_table_rec(tblFull,source,angles,targetDirectory,sidelength,....
 
 
     'applyRampFilter',1,....
 
     'applyRampFilter',1,....
 
     'sizeTomogram',sizeTomogramFull,....
 
     'sizeTomogram',sizeTomogramFull,....
     'shiftTomogramCenter',shiftTomogramCenter);
+
     'shiftTomogramCenter',shiftTomogramCenter);</code>
  
figure;dslices(targetDirectory,'proj','c');shg;
+
We can now check that the particles have been reconstructed in full size.
disp('done');
+
<tt>figure;dslices(targetDirectory,'proj','c');shg;</tt>
 
 
 
 
[[ File:alignCommandLine_autocompletionOfUserObject.png |thumb|center| 600px|autocompletion of user object]]
 
[[ File:alignCommandLine_autocompletionOfFurtherFieldsOfUserObject.png |thumb|center| 600px|autocompletion of further fields of user object]]
 
[[ File:alignCommandLine_viewOfTiltLines.png |thumb|center| 600px|view of tilt lines]]
 
[[ File:alignCommandLine_dtmsliceOfBinnedReconstruction.png |thumb|center| 600px|dtmslice of binned reconstruction]]
 
[[ File:alignCommandLine_dtmsliceContrastControl.png |thumb|center| 600px|dtmslice contrast control]]
 
[[ File:alignCommandLine_dtmsliceAfterContrastCorrection.png |thumb|center| 600px|dtmslice after contrast correction]]
 
[[ File:alignCommandLine_createANewModel.png |thumb|center| 600px|create a new model]]
 
[[ File:alignCommandLine_showAFullProjection.png |thumb|center| 600px|show a full projection]]
 
[[ File:alignCommandLine_fullProjectionOfBinnedReconstruction.png |thumb|center| 600px|full projection of binned reconstruction]]
 
[[ File:alignCommandLine_rightClickOnAPoint.png |thumb|center| 600px|right click on a point]]
 
[[ File:alignCommandLine_xViewOfClickedPoint.png |thumb|center| 600px|x view of clicked point]]
 
[[ File:alignCommandLine_mainClickToFixThe3dCoordinates.png |thumb|center| 600px|main click to fix the 3d coordinates]]
 
[[ File:alignCommandLine_clickAroundTenMarkers.png |thumb|center| 600px|click around ten markers]]
 
[[ File:alignCommandLine_exportATableIntoTheMatlabWorkspace.png |thumb|center| 600px|export a table into the matlab workspace]]
 
[[ File:alignCommandLine_theCommandLineShowsTheVariableNameAssignedToTheCreatedTable.png |thumb|center| 600px|the command line shows the variable name assigned to the created table]]
 
[[ File:alignCommandLine_dslicesOnBinnedGoldBeads.png |thumb|center| 600px|dslices on binned gold beads]]
 
 
[[ File:alignCommandLine_dslicesOnFullSizedGoldBeads.png |thumb|center| 600px|dslices on full sized gold beads]]
 
[[ File:alignCommandLine_dslicesOnFullSizedGoldBeads.png |thumb|center| 600px|dslices on full sized gold beads]]

Revision as of 15:52, 27 August 2019

This is the command line based version of the GUI based alignment walkthrough

Create the workflow

name = 'hivCommandLine';
folder = 'workflows';
u = dtsa(name,'--nogui','-path',folder,'fp',1); 

Here, we instruct Dynamo to skip opening the GUI. We also create the workflow in a different folder.

Entering the data

The u object contains several areas to interact with the workflow. They can be found by autocompletion using the tab key. Here, we will proceed step by step; remember that you can write all the command lines in a single .m script.

autocompletion of user object
autocompletion of further fields of user object

Basic data

u.enter.tiltSeries(file);

u.enter.tiltAngles(-57:3:60);

If you want to reject some of the hight tilts (or any other view that appears to have been damages,) u.enter.discardedTiltIndices([1,40]);

Acquisition settings

u.enter.settingAcquisition.apix(2.7);

Computation settings

u.enter.settingComputing.parallelCPUUse(1);

Detection settings

These here are the actual design decisions when running an alignment workflow:

u.enter.settingDetection.beadRadius(16); u.enter.settingDetection.maskRadius(28);

u.enter.templateSidelength(64);

The bin level is mainly used to accelerate the detection procedure. Needs to be chosen in a way that a binned gold bead still can be recognisable as such, with a radius of at least 4 pixels.

u.enter.settingDetection.detectionBinningFactor(1);

Changing generic parameters

Yo can find handles to the parameters of the individuals steps through auto ompletion on the area, then step items.

u.area.indexing.step.tiltGapFiller.parameterSet.residualsThreshold(8);


Running the workflow

u.run.all('noctf',1);

On the fly reconstruction of particles

Grep coordinates in the binned tomogram

Open the binned reconstruction with dtmslice dtmslice 'workflows/hivCommandLine.AWF/reconstruction/binnedReconstructionWBP.mrc';

view of tilt lines
dtmslice of binned reconstruction
dtmslice contrast control
dtmslice after contrast correction
create a new model
show a full projection
full projection of binned reconstruction
right click on a point
x view of clicked point
main click to fix the 3d coordinates
click around ten markers
export a table into the matlab workspace
the command line shows the variable name assigned to the created table

Now we can save the table as a file: write(temp_table,'binnedGoldbeads.tbl');

Cropping the gold bead particles

tomo = 'workflows/workshop.AWF/reconstruction/binnedReconstructionWBP.mrc'; tbl = 'binnedGoldbeads.tbl'; targetBinnedParticles = 'binnedGoldBeads.Data'; sidelength = 32; o = dtcrop(tomo,tbl,target,sidelength);

And then we visualise a projection along z of each cropped particle

dslices(targetBinnedParticles,'proj','c');shg;
dslices on binned gold beads

Reconstruct particles on the fly

The command that reconstructs full sized particles from an aligned stack is dynama_table_trec. This is an independent function, not part of the workflow, implying that we will need to perform some format conversion.

tbl = dread('binnedGoldbeads.tbl');

We scale the table

alignmentBinLevel = 2;

tblFull = dynamo_table_rescale(tbl,'factor',2^alignmentBinLevel);

source  = 'workflows/hivCommandLine AWF/align/alignedFullStack.mrc';

We create a data folder to contain the particles reconstructed on the fly.

targetDirectory = 'tempCrop.Data';


Angles actually used during the reconstruction are contained in the reconstructionTiltAngles' item of the output folder. Note that they might differ from the nominal angles, as some views might have been eliminated, both explicitely by the user, of by the program not being able to align all tilts.

angles =  'workflows/hivCommandLine.AWF/align/reconstructionTiltAngles.tlt';

The (binned) coordinates were measured in a binned tomogram, whose dimensionality is requested by dynamo_table_rec. We need to provide dynamo_table_rec with visualizationTomogram = 'workflows/ hivCommandLine.AWF/reconstruction/binnedReconstructionWBP.mrc'; sizeTomogram = dynamo_read_size(visualizationTomogram); sizeTomogramFull = sizeTomogram*2^alignmentBinLevel;

The tomogram center can be shifted in order to account for a possible shift in the centre in the binned reconstruction that was used to crop the particles.

shiftTomogramCenter = [0,0,0];

We proceed now to the reconstruction. sidelengthFullSize = 128; dynamo_table_rec(tblFull,source,angles,targetDirectory,sidelength,....

   'applyRampFilter',1,....
   'sizeTomogram',sizeTomogramFull,....
   'shiftTomogramCenter',shiftTomogramCenter);

We can now check that the particles have been reconstructed in full size.

figure;dslices(targetDirectory,'proj','c');shg;
dslices on full sized gold beads