Difference between revisions of "Walkthrough on localized reconstruction"
(62 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | |||
In this walkthrough, we use ''localized reconstruction'' to reconstruct a set of subtomograms at full pixel resolution without the requirement of creating a full reconstruction first. | In this walkthrough, we use ''localized reconstruction'' to reconstruct a set of subtomograms at full pixel resolution without the requirement of creating a full reconstruction first. | ||
Line 7: | Line 6: | ||
* reconstruct separately the different coordinates at full resolution | * reconstruct separately the different coordinates at full resolution | ||
− | For the sake of simplicity, in this walkthrough, the landmarks of interest will be | + | For the sake of simplicity, in this walkthrough, the landmarks of interest will be simply the gold beads, which are trivially recognizable both in tomograms and in projections in the tilt series. |
== Example data set == | == Example data set == | ||
Line 16: | Line 15: | ||
=== Download tilt series file=== | === Download tilt series file=== | ||
− | The aligned tilt series can be download | + | The aligned tilt series can be download with the command: |
− | <tt> | + | <tt>wget https://wiki.dynamo.biozentrum.unibas.ch/w/doc/data/t6ss/vc17_align.mrc </tt> |
+ | |||
+ | in a linux shell, or through: | ||
+ | |||
+ | <tt>curl -O https://wiki.dynamo.biozentrum.unibas.ch/w/doc/data/t6ss/vc17_align.mrc</tt> | ||
+ | under MacOS. | ||
This will create a file called <tt>vc17_align.ali</tt> in your current working directory. The tilt angles go from -60 to 60 in intervals of 3 degrees. | This will create a file called <tt>vc17_align.ali</tt> in your current working directory. The tilt angles go from -60 to 60 in intervals of 3 degrees. | ||
Line 33: | Line 37: | ||
<tt>dtmshow(ts)</tt> | <tt>dtmshow(ts)</tt> | ||
+ | |||
+ | [[ File:LocalizedProjectionDtmshowFullZoomed.png |thumb|center|800px| <tt>tmshow</tt> of raw tilt series ]] | ||
==== Prebinning during inspection ==== | ==== Prebinning during inspection ==== | ||
Line 39: | Line 45: | ||
Note that the coordinates of the axis are kept to the dimension of the unbinned tilt series. | Note that the coordinates of the axis are kept to the dimension of the unbinned tilt series. | ||
− | Also, it is possible to create a prebinned version of the stack for different binning levels, so that the slice is accessed already in its prebinned dimension. This can be done after <tt>dtmshow</tt> has been | + | Also, it is possible to create a prebinned version of the stack for different binning levels, so that the slice is accessed already in its prebinned dimension. This can be done after <tt>dtmshow</tt> has been initialized |
+ | or already when starting it (at the cost of an slower initialization) | ||
− | + | <tt>dtmshow(ts,'bz',3)</tt> | |
− | <tt> | + | [[ File:LocalizedProjectionDtmshowBinnedZoomed.png |thumb|center|500px| <tt>tmshow</tt> of 3x binned tilt series ]] |
=== Geometric conventions === | === Geometric conventions === | ||
Line 58: | Line 65: | ||
We bin the original tilt series: | We bin the original tilt series: | ||
− | <tt> | + | <tt>sbin = dpktilt.bin(ts,3;)</tt> |
This command applies a binning of level two to the micorgraphs in the matrix <tt>ts</tt> separately. Note that the dimensions of the new matrix are floor( [sx,sy]/2<sup>2<2>). | This command applies a binning of level two to the micorgraphs in the matrix <tt>ts</tt> separately. Note that the dimensions of the new matrix are floor( [sx,sy]/2<sup>2<2>). | ||
Line 66: | Line 73: | ||
In this walkthrough, we use Weighted Backprojection as reconstruction algorithm. We apply here the simplest possible filter onto the original projections: a ramp filter. | In this walkthrough, we use Weighted Backprojection as reconstruction algorithm. We apply here the simplest possible filter onto the original projections: a ramp filter. | ||
− | <tt> | + | <tt>sf = dpktomo.rec.applyRampFilter(sbin);</tt> |
=== Reconstruction === | === Reconstruction === | ||
Line 73: | Line 80: | ||
By default, the center of the reconstructed volume will be located at the stack 3d center. | By default, the center of the reconstructed volume will be located at the stack 3d center. | ||
− | <tt> | + | <tt>tiltAngles = -60:3:60; </tt> |
+ | |||
+ | <tt> outputBP = dpktilt.math.backproject([400,300,200],sf,tiltAngles);</tt> | ||
+ | |||
+ | The reconstruction can be normally accessed through the field <tt>rec</tt> in the output. | ||
+ | |||
+ | <tt>dtmshow(outputBP.rec);</tt> | ||
+ | |||
+ | [[ File:LocalizedProjectionDtmshowRec.png |thumb|center|800px| <tt>tmshow</tt> on the reconstruction, ''z'' and ''x' views ]] | ||
+ | |||
+ | In order to store this tomogram into a file, type: | ||
− | The | + | <tt>dwrite(outputBP.rec,'temp.mrc');</tt> |
+ | |||
+ | ==== Reconstruction options ==== | ||
+ | The command <tt>dpktilt.math.backproject</tt> allows several modifications. The most used ones are: | ||
+ | * <tt> 'mw'</tt> to use several cores working in parallel. | ||
+ | * <tt>'maxGb'</tt> to state the maximum size that can be kept at once in memory. If the reconstruction needs more space, it will be computed in chunks along z. Each chunk will be computed separately and immediately written into disk. | ||
+ | |||
+ | ==== Reconstruction output object==== | ||
+ | |||
+ | Other than the final reconstruction, the output of the <tt>dpktilt.math.backproject</tt> command is an object that stores different information, including a description of the geometrical relationship between the reconstucted volume and the tilt series. We will use this information later in this walkthrough. | ||
+ | |||
+ | In actual practice, this reconstruction object can be saved into disk (as a binary file with extension <tt>.obp</tt>), so that the information on how a reconstruction relates to a given tilt series can be recalled in a later session. The command | ||
+ | |||
+ | <tt>outputBP.save('myInfo');</tt> | ||
+ | |||
+ | will create a file called <tt> myInfo.obp</tt> in disk, whose contents can be brought later into memory through | ||
+ | |||
+ | <tt>oRead = dread('myInfo.obp');</tt> | ||
==== CTF considerations ==== | ==== CTF considerations ==== | ||
Line 82: | Line 116: | ||
== Annotation on binned reconstruction == | == Annotation on binned reconstruction == | ||
− | The reconstruction in bin level | + | The reconstruction in bin level 3 fits in memory and can be explored easily with <tt>dtmslice</tt> |
We open it creating a catalogue on the fly to contain our annotations: | We open it creating a catalogue on the fly to contain our annotations: | ||
− | <tt>dtmslice( | + | <tt>dtmslice('temp.rec','c','gbcat');</tt> |
− | + | [[File:LocalizedWBPBoxes.png |thumb|center|500px| Boxes-type models are the most suitable for picking in 3D]] | |
+ | |||
+ | The flag <tt>'c'</tt> orders <tt>dtmslice</tt> to prepare a [[catalogue]] arbitrarily called <tt>gbcat</tt> | ||
+ | |||
+ | === Annotation on 3D === | ||
+ | |||
+ | The most trivial strategy for picking particles is to use the 3D viewer. Use ''C'' to input a 3d coordinate into the model. Further controls are [[dtmslice # editing models | explained here]] | ||
+ | |||
+ | [[ File:LocalizedWBPSelectionBoxes.png |thumb|center|500px| Select a few gold beads. ]] | ||
+ | |||
+ | Note that you don't need to be very precise to catch the center of the gold bead. | ||
+ | |||
+ | [[ File:LocalizedWBPSelectionBoxesZoom.png |thumb|center|500px| Gold beads can be selected approximately]] | ||
+ | |||
+ | === Annotation on projections === | ||
+ | An '''alternative''' way to quickly annotate the gold beads is by concurrent projection. In this approach we launch a projection view of the full tomogram [''Project > project full shown fragment alongz z'']. | ||
+ | |||
+ | [[ File:LocalizedWBPSelectionProjection.png |thumb|center|500px| Location of a single gold bead in the total projection viewed along z. A right click (two-finger tap on the Mac) marks the x-y position]] | ||
+ | |||
+ | Two concurrent viewers will pop up showing cuts along ''x'' and ''y'', i.e, YZ and XZ planes where the ''z'' coordinate can be clicked (in either of them). | ||
+ | |||
+ | [[File:LocalizedWBPSelectionProjectionConcurrent.png |thumb|center|800px| A left click marks the z]] | ||
+ | |||
+ | The (''x'',''y'',''z'') point will update in the <tt>tomoslice</tt> window. Also, the windows that show the cuts long ''x'' and ''y'' will update upon new right-clicks on the ''z'' projection. | ||
+ | |||
+ | === Saving annotation as model === | ||
+ | |||
+ | On either way you chose to perform your annotations (by 3d or by concurrent 2d projections and cut), you can save your model in the catalogue with the disk icon or under the active model menu. | ||
== Location of 3d annotations on 2d tilt series == | == Location of 3d annotations on 2d tilt series == | ||
Now we want to localize the 3d coordinates of the gold beads in the binned tilt serie. We first bring the coordinates to a memory variable that we can manipulate. | Now we want to localize the 3d coordinates of the gold beads in the binned tilt serie. We first bring the coordinates to a memory variable that we can manipulate. | ||
− | '''If'' your <tt>dtmslice</tt> is still open, you can put the points into the workspace memory by ''Active Model > Export to workspace > Points'', which will create in the memory a variable called <tt>temp_points</tt> with Nx3 entries. | + | '''If'' your <tt>dtmslice</tt> is still open, you can put the points into the workspace memory by ''Active Model > Export to workspace > Points'', which will create in the memory a variable called <tt>temp_points</tt> with Nx3 entries. In this variable, each row are the ''xyz'' coordinates of a single gold bead. |
If you already closed the <tt>dtmslice</tt> session, you need to read the model that you saved into catalogue: | If you already closed the <tt>dtmslice</tt> session, you need to read the model that you saved into catalogue: | ||
− | The points are stored as Nx3 matrix in the <tt>points</tt> property of the model. | + | <nowiki>dcmodels gbcat -ws oum |
+ | m = dread(oum.files{1}); </nowiki> | ||
+ | |||
+ | The points are stored as Nx3 matrix in the <tt>points</tt> property of the model <tt>m</tt> | ||
+ | |||
+ | <nowiki> gb = m.points;</nowiki> | ||
+ | |||
+ | So, we have defined in memory a matrix Nx3 called <tt>gb</tt>. Each row is the 3d position of the center on one of the manually picked gold beads, expressed in the coordinates of the 3x binned reconstruction. You can check the geometry with low level depicting commands as <tt>dslice3d</tt> | ||
+ | |||
+ | <nowiki>figure; dslice3d('temp.mrc','r',gb(1,:));</nowiki> | ||
+ | |||
+ | which plots a single slice of the tomogram cutting a point of interest (by default, in direction ''z'' and covering the full extent of the volume), followed by a depiction of the 3d point of interest. For instance, for the first gold bead (in row 1) | ||
+ | |||
+ | <nowiki>hold on;h=dpkgeom.plotCloud(gb(1,:),'or');</nowiki> | ||
+ | |||
+ | [[File:LocalizedWBPgoldbead1_3d.png|thumb|center|500px| <tt>dslice3d</tt> ]] | ||
+ | |||
+ | A different way to check it is to crop a subtomogram around the 3d coordinates of interest. For instance, for the second gold bead: | ||
+ | |||
+ | <tt>gb3d = dcrop('temp.rec',40,gb(2,:));</tt> | ||
+ | |||
+ | and show it as montage of slices with <tt>dview</tt>: | ||
+ | |||
+ | <tt>dview(gb3d);</tt> | ||
+ | |||
+ | [[File:LocalizedWBPgoldbead1_view.png|thumb|center|500px| <tt>dview</tt> of an area cropped with <tt>dview</tt> ]] | ||
=== Computation === | === Computation === | ||
+ | To find the 2d coordinates of all the goldbeads at once in the micrograph corresponding to a tilt angle of -60, we would write | ||
+ | |||
+ | <nowiki>tilt = 1; | ||
+ | r2d = dpktilt.point3dInMicrograph(gb,tiltAngles(tilt),'sizeStack',size(sf),'sc',[200.5,150.5,100.5]);</nowiki> | ||
+ | |||
+ | Note that you need to express the geometric context of <tt>r3d</tt>. | ||
+ | * <tt>'sc'</tt> stands for <tt>'stack3dcenter'</tt> | ||
+ | *<tt>'ss'</tt> stands for <tt>'stackSize'</tt> | ||
+ | |||
+ | In other words, <tt>gb</tt> are the coordinates of the points of interest in the reconstructed volume. You need to express how the reconstructed volume related to the original stack <tt>dpktilt.point3dInMicrograph</tt> needs this information explicitly. Alternatively, you can just use the method <tt>'point3dInAlignedMicrograph'</tt> in the <tt>obp</tt> object, assuming it is still in memory. As this object carries the geometric information, the syntax is simpler. | ||
+ | |||
+ | <tt> r2d = outputBP.point3dInAlignedMicrograph(gb,-60);</tt> | ||
+ | |||
+ | or with the notation {} to pass position in the tilt series instead of the angle value. | ||
+ | |||
+ | <tt> r2d = outputBP.point3dInAlignedMicrograph(r3d,{1});</tt> | ||
=== Visualization === | === Visualization === | ||
− | The basic tool for visualizing sets of 2d markers defined on a tilt series is <tt>dmarkers</tt> | + | |
+ | ==== Basic Matlab commands ==== | ||
+ | |||
+ | So, did it work? You can check it by just plotting the image of the micrograph | ||
+ | |||
+ | <nowiki>figure(); | ||
+ | hi = dshow(sbin(:,:,tilt)); </nowiki> | ||
+ | |||
+ | and then plotting on it the positions of the markers. | ||
+ | <nowiki> hold on; | ||
+ | h = plot(r2d(:,1),r2d(:,2),'o');</nowiki> | ||
+ | |||
+ | further tunning of the graphical output is possible through access to the properties of the handle <tt>h</tt> | ||
+ | |||
+ | <nowiki>h.LineWidth=1; | ||
+ | h.MarkerSize=10; | ||
+ | h.Color='r'; </nowiki> | ||
+ | |||
+ | [[File:LocalizedWBPdshow2d.png|thumb|center|700px| Projections of tilts 1 and 21 (-60 and 0 degrees) ]] | ||
+ | |||
+ | Note that the default convention in <tt>dshow</tt> is to plot the rows of the matrix along the 'x' axis of the plot, with the origin of coordinates in the left bottom corner of the plot. The intensity of matrix entry [i,j] is represented in the pixel centered at (i-0.5,j-0.5). | ||
+ | |||
+ | ==== Interactive GUI ==== | ||
+ | |||
+ | The basic tool for visualizing sets of 2d markers defined on a tilt series is <tt>dmarkers</tt>. This allows to navigate at once through all the annotations on all the images. We first compute the positions in 2d of all the 3d positions in <tt>gb</tt>: | ||
+ | |||
+ | <nowiki>r2dAll = outputBP.point3dInAlignedMicrograph(gb,'*');</nowiki> | ||
+ | |||
+ | and then create a shape set object with this information. This step is necessary to provide <tt>dmarkers</tt> with the right format. | ||
+ | |||
+ | <nowiki>ss = dpktilt.aux.markgold.MarkerSet(); | ||
+ | ss.setFrameCellArray(r2dAll); </nowiki> | ||
+ | |||
+ | Now we can open the <tt>dmarkers</tt> GUI on the tilt series <tt>ts3</tt> for this shape set: | ||
+ | |||
+ | <tt>og = dmarkers(sbin,'lm',ss);</tt> | ||
+ | |||
+ | [[File:LocalizedWBPdmarkersRough.png |thumb|center|900px| <tt>dmarkers</tt> allow to slide along the projections. On the right, a zoom view (with the mouse wheel) ]] | ||
+ | |||
+ | Remember that the gold beads had been picked loosely. If you zoom in, you'll see that the red spots are close to but not on the gold bead projections. | ||
== Localized reconstruction == | == Localized reconstruction == | ||
+ | |||
+ | Now we want to reconstruct locally each of the gold beads, i.e. | ||
=== Reconstruct a single area === | === Reconstruct a single area === | ||
+ | |||
+ | <nowiki>ogb = outputBP.localReconstruction(gb(1,:),[20,20,20],sf); | ||
+ | ogb.view(); </nowiki> | ||
+ | |||
+ | [[File:LocalizedWBPlocalReconstruction1.png|thumb|center|500px| Single area, binned ]] | ||
=== Reconstruction into a data folder === | === Reconstruction into a data folder === | ||
− | The command <tt>dtrec</tt> is the counterpart of <tt>dtcrop</tt> for tilt series. It loops on the positions inside a table | + | The command <tt>dtrec</tt> is the counterpart of <tt>dtcrop</tt> for tilt series. It loops on the positions inside a table. We will use a different approach. |
+ | |||
+ | <nowiki>outputBP.reconstructIntoDataFolder('binnedGoldBeads',20,sf,'points',gb,'fo',1); | ||
+ | figure;dslices binnedGoldBeads z -j * </nowiki> | ||
+ | |||
+ | [[File:LocalizedWBPlocalReconstructionAllBinned.png |thumb|center|500px| All gold beads, binned. Each red box represents a ''z'' projection. ]] | ||
+ | |||
+ | === Full resolution reconstruction === | ||
+ | Now we can proceed to transport the locations annotated in the 3x binned geometry into the full size information. | ||
+ | |||
+ | <tt>fbp = outputBP.rescale('up',3);</tt> | ||
+ | |||
+ | We can apply the weight on the original tilt series at full resolution <tt>ts</tt>: | ||
+ | |||
+ | <tt>sWeightedFull = dpktomo.rec.applyRampFilter(ts);</tt> | ||
+ | |||
+ | It will take around a minute. The function accepts the <tt>mw</tt> flag to increase the speed. | ||
+ | |||
+ | <tt>fgb = fbp.localReconstruction(gb(1,:)*2^3,[60,60,60], sWeightedFull); </tt> | ||
+ | |||
+ | The localized reconstruction can be shown through: | ||
+ | |||
+ | <tt>fgb.view();</tt> | ||
+ | |||
+ | [[ File:LocalizedWBPlocalReconstruction1Full.png |thumb|center|500px| Single gold bead, full resolution ]] | ||
+ | |||
+ | Note that we don't really need to use the object <tt>fgb</tt> as support. Its only role is to work out the geometry, computing the position of the 3d stack center with reference to the subtomogram that we want to reconstruct locally. We can work out the maths and compute the vector: <tt>[1035.431 551.378 318.140] </tt>. We could use this vector directly in <tt>dpktilt.math.backproject</tt> | ||
+ | and get the same result. | ||
+ | |||
+ | <tt>fbpDirect = dpktilt.math.backproject([60,60,60], sWeightedFull,tiltAngles,'sc',[1035.431 551.378 318.140]);</tt> | ||
+ | |||
+ | We can now reconstruct all the gold beads at full resolution. | ||
+ | |||
+ | <tt>fbp.reconstructIntoDataFolder('fullGoldBeads',80, sWeightedFull,'points',gb*8,'fo',1); </tt> | ||
+ | |||
+ | and create a depiction of the data set. | ||
+ | |||
+ | <tt>figure;dslices fullGoldBeads z -j * </tt> | ||
+ | |||
+ | [[ File:LocalizedWBPlocalReconstructionAllFullCompare.png |thumb|center|1000px| All gold beads, full resolution, compared to the reconstructions computed with the binned tilt series ]] | ||
+ | |||
+ | === Refining the full resolution reconstruction === | ||
+ | |||
+ | Now, we could find the actual positions of the gold beads with an alignment project. We create a spherical template and mask: | ||
+ | |||
+ | <nowiki> | ||
+ | dwrite(-dsphere(10,80),'template.mrc'); | ||
+ | dwrite(dsphere(16,80),'mask.mrc'); | ||
+ | dwrite(dynamo_table_blank('fullGoldBeads'),'blankFull.tbl'); </nowiki> | ||
+ | |||
+ | <nowiki>ddelete goldAligner | ||
+ | dcp.new('goldAligner','d','fullGoldBeads','t','blankFull.tbl','template','template.mrc','mask','mask.mrc','show',0); | ||
+ | dvput goldAligner -cr 0; | ||
+ | dvput goldAligner -ir 0; | ||
+ | dvput goldAligner -rf 0; | ||
+ | dvput goldAligner -lims 40; | ||
+ | dvput goldAligner -ite 1; | ||
+ | dvput goldAligner -dim 80; | ||
+ | check = dvcheck('goldAligner');</nowiki> | ||
+ | |||
+ | If the check doesn't report any problem, we can then just unfold the project: | ||
+ | |||
+ | <nowiki> dvunfold goldAligner | ||
+ | goldAligner</nowiki> | ||
+ | |||
+ | Then we can check the result. | ||
+ | |||
+ | <nowiki>ddb goldAligner:a -v </nowiki> | ||
+ | |||
+ | The resulting gold bead is now centered | ||
+ | |||
+ | [[ File:LocalizedWBPlocalReconstruction1FullRecentered.png |thumb|center|500px| Averaged gold bead (centered)]] | ||
+ | |||
+ | More importantly, the ''individual'' gold beads are now centered: | ||
+ | |||
+ | [[ File:LocalizedWBPlocalReconstruction1FullRecentered.png |thumb|center|500px| Averaged gold bead (centered)]] | ||
+ | |||
+ | The alignment parameters are stored in the refinement table, which we can read into a workspace variable (we arbitrarily call it <tt>t</tt>) | ||
+ | |||
+ | <tt>ddb goldAligner:rt -r t </tt> | ||
+ | |||
+ | The position of gold beads in 3d is the addition of the computed shifts (columns 4 to 6 in the table) on the coarse positions of the gold beads: | ||
+ | |||
+ | <tt>gf3d = t(:,4:6)+gb*2^3;</tt> | ||
+ | |||
+ | <nowiki>r2coarse = outputBP.point3dInAlignedMicrograph(gf3d,'*'); | ||
+ | sc = dpktilt.aux.markgold.MarkerSet(); | ||
+ | sc.setFrameCellArray(r2coarse); | ||
+ | ogc = dmarkers(sbin,'lm',sc); </nowiki> | ||
+ | |||
+ | [[ File:LocalizedWBPMarkersAligned.png |thumb|center|500px| New set of markers in 2d (red)]] | ||
+ | |||
+ | We can show in this session of <tt>dmarkers</tt> the same shape set of positions that we computed before the alignment project. We will paint it i blue for comparison with the current positions. | ||
+ | <nowiki>ss.name ='previous'; | ||
+ | ogc.bindGenericShapeSet(ss,'pointColor','b');</nowiki> | ||
+ | [[ File:LocalizedWBPMarkersAlignedZoom.png |thumb|center|800px| Raw set of markers (blue) ]] |
Latest revision as of 10:57, 27 August 2018
In this walkthrough, we use localized reconstruction to reconstruct a set of subtomograms at full pixel resolution without the requirement of creating a full reconstruction first. In this approach, we:
- create a reconstruction at low resolution
- mark the coordinates of interest in the low resolution reconstruction
- reconstruct separately the different coordinates at full resolution
For the sake of simplicity, in this walkthrough, the landmarks of interest will be simply the gold beads, which are trivially recognizable both in tomograms and in projections in the tilt series.
Contents
Example data set
The data set is an aligned tilt series. No filtering has been performed on it.
Source
The tilt series was used in the publication Cryo-EM structure of the extended type VI secretion system sheath-tube complex (J Wang et. al - Nature microbiology, 2017).
Download tilt series file
The aligned tilt series can be download with the command:
wget https://wiki.dynamo.biozentrum.unibas.ch/w/doc/data/t6ss/vc17_align.mrc
in a linux shell, or through:
curl -O https://wiki.dynamo.biozentrum.unibas.ch/w/doc/data/t6ss/vc17_align.mrc
under MacOS.
This will create a file called vc17_align.ali in your current working directory. The tilt angles go from -60 to 60 in intervals of 3 degrees.
The file can be brought into memory through the command
ts = dread('vc17_align.ali');
creating the variable ts (name has been chosen arbitrarily) which contains the tilt series as a numerical matrix.
Inspecting the tilt series
The tilt series at full pixel resolution can be inspected by:
dtmshow(ts)
Prebinning during inspection
You will notice that inspecting the full series in dtmshow is bound to rather slow transitions. It is more convenient to bin the images to a smaller bin level. This can be done by switching on the binning radiobutton. Thus, the accessed slices will be binned on the fl when required.
Note that the coordinates of the axis are kept to the dimension of the unbinned tilt series.
Also, it is possible to create a prebinned version of the stack for different binning levels, so that the slice is accessed already in its prebinned dimension. This can be done after dtmshow has been initialized
or already when starting it (at the cost of an slower initialization)
dtmshow(ts,'bz',3)
Geometric conventions
In Dynamo, we call stack 3d center to a point (xsc, ysc,zsc) univocally defined by a stack of micrographs:
- xsc and zsc and determined by the rotation axis implicitly defined by the alignment.
- ysc is the center of the stack along direction y, defined as floor(Ny/2)+0.5; for a tilt series with Ny pixels along y.
Creation of a binned reconstruction
Binned tilt series
We bin the original tilt series:
sbin = dpktilt.bin(ts,3;)
This command applies a binning of level two to the micorgraphs in the matrix ts separately. Note that the dimensions of the new matrix are floor( [sx,sy]/22<2>).
Filtered tilt series
In this walkthrough, we use Weighted Backprojection as reconstruction algorithm. We apply here the simplest possible filter onto the original projections: a ramp filter.
sf = dpktomo.rec.applyRampFilter(sbin);
Reconstruction
As we have binned the tiltseries, a reconstruction at the full extent of the tomogram will fit easily in memory. We need to chose a size of the output tomogram, expressed in pixels of the stack By default, the center of the reconstructed volume will be located at the stack 3d center.
tiltAngles = -60:3:60;
outputBP = dpktilt.math.backproject([400,300,200],sf,tiltAngles);
The reconstruction can be normally accessed through the field rec in the output.
dtmshow(outputBP.rec);
In order to store this tomogram into a file, type:
dwrite(outputBP.rec,'temp.mrc');
Reconstruction options
The command dpktilt.math.backproject allows several modifications. The most used ones are:
- 'mw' to use several cores working in parallel.
- 'maxGb' to state the maximum size that can be kept at once in memory. If the reconstruction needs more space, it will be computed in chunks along z. Each chunk will be computed separately and immediately written into disk.
Reconstruction output object
Other than the final reconstruction, the output of the dpktilt.math.backproject command is an object that stores different information, including a description of the geometrical relationship between the reconstucted volume and the tilt series. We will use this information later in this walkthrough.
In actual practice, this reconstruction object can be saved into disk (as a binary file with extension .obp), so that the information on how a reconstruction relates to a given tilt series can be recalled in a later session. The command
outputBP.save('myInfo');
will create a file called myInfo.obp in disk, whose contents can be brought later into memory through
oRead = dread('myInfo.obp');
CTF considerations
For simplicity, we are skipping the CTF correction step in this walkthrough, where we are only interested in the geometrical manipulations. In a real case, you would just use a version of the tilt series where each micrograph has been phase-flipped according to a defocus estimation computed on the full micrograph.
Annotation on binned reconstruction
The reconstruction in bin level 3 fits in memory and can be explored easily with dtmslice
We open it creating a catalogue on the fly to contain our annotations:
dtmslice('temp.rec','c','gbcat');
The flag 'c' orders dtmslice to prepare a catalogue arbitrarily called gbcat
Annotation on 3D
The most trivial strategy for picking particles is to use the 3D viewer. Use C to input a 3d coordinate into the model. Further controls are explained here
Note that you don't need to be very precise to catch the center of the gold bead.
Annotation on projections
An alternative way to quickly annotate the gold beads is by concurrent projection. In this approach we launch a projection view of the full tomogram [Project > project full shown fragment alongz z].
Two concurrent viewers will pop up showing cuts along x and y, i.e, YZ and XZ planes where the z coordinate can be clicked (in either of them).
The (x,y,z) point will update in the tomoslice window. Also, the windows that show the cuts long x and y will update upon new right-clicks on the z projection.
Saving annotation as model
On either way you chose to perform your annotations (by 3d or by concurrent 2d projections and cut), you can save your model in the catalogue with the disk icon or under the active model menu.
Location of 3d annotations on 2d tilt series
Now we want to localize the 3d coordinates of the gold beads in the binned tilt serie. We first bring the coordinates to a memory variable that we can manipulate. 'If your dtmslice is still open, you can put the points into the workspace memory by Active Model > Export to workspace > Points, which will create in the memory a variable called temp_points with Nx3 entries. In this variable, each row are the xyz coordinates of a single gold bead.
If you already closed the dtmslice session, you need to read the model that you saved into catalogue:
dcmodels gbcat -ws oum m = dread(oum.files{1});
The points are stored as Nx3 matrix in the points property of the model m
gb = m.points;
So, we have defined in memory a matrix Nx3 called gb. Each row is the 3d position of the center on one of the manually picked gold beads, expressed in the coordinates of the 3x binned reconstruction. You can check the geometry with low level depicting commands as dslice3d
figure; dslice3d('temp.mrc','r',gb(1,:));
which plots a single slice of the tomogram cutting a point of interest (by default, in direction z and covering the full extent of the volume), followed by a depiction of the 3d point of interest. For instance, for the first gold bead (in row 1)
hold on;h=dpkgeom.plotCloud(gb(1,:),'or');
A different way to check it is to crop a subtomogram around the 3d coordinates of interest. For instance, for the second gold bead:
gb3d = dcrop('temp.rec',40,gb(2,:));
and show it as montage of slices with dview:
dview(gb3d);
Computation
To find the 2d coordinates of all the goldbeads at once in the micrograph corresponding to a tilt angle of -60, we would write
tilt = 1; r2d = dpktilt.point3dInMicrograph(gb,tiltAngles(tilt),'sizeStack',size(sf),'sc',[200.5,150.5,100.5]);
Note that you need to express the geometric context of r3d.
- 'sc' stands for 'stack3dcenter'
- 'ss' stands for 'stackSize'
In other words, gb are the coordinates of the points of interest in the reconstructed volume. You need to express how the reconstructed volume related to the original stack dpktilt.point3dInMicrograph needs this information explicitly. Alternatively, you can just use the method 'point3dInAlignedMicrograph' in the obp object, assuming it is still in memory. As this object carries the geometric information, the syntax is simpler.
r2d = outputBP.point3dInAlignedMicrograph(gb,-60);
or with the notation {} to pass position in the tilt series instead of the angle value.
r2d = outputBP.point3dInAlignedMicrograph(r3d,{1});
Visualization
Basic Matlab commands
So, did it work? You can check it by just plotting the image of the micrograph
figure(); hi = dshow(sbin(:,:,tilt));
and then plotting on it the positions of the markers.
hold on; h = plot(r2d(:,1),r2d(:,2),'o');
further tunning of the graphical output is possible through access to the properties of the handle h
h.LineWidth=1; h.MarkerSize=10; h.Color='r';
Note that the default convention in dshow is to plot the rows of the matrix along the 'x' axis of the plot, with the origin of coordinates in the left bottom corner of the plot. The intensity of matrix entry [i,j] is represented in the pixel centered at (i-0.5,j-0.5).
Interactive GUI
The basic tool for visualizing sets of 2d markers defined on a tilt series is dmarkers. This allows to navigate at once through all the annotations on all the images. We first compute the positions in 2d of all the 3d positions in gb:
r2dAll = outputBP.point3dInAlignedMicrograph(gb,'*');
and then create a shape set object with this information. This step is necessary to provide dmarkers with the right format.
ss = dpktilt.aux.markgold.MarkerSet(); ss.setFrameCellArray(r2dAll);
Now we can open the dmarkers GUI on the tilt series ts3 for this shape set:
og = dmarkers(sbin,'lm',ss);
Remember that the gold beads had been picked loosely. If you zoom in, you'll see that the red spots are close to but not on the gold bead projections.
Localized reconstruction
Now we want to reconstruct locally each of the gold beads, i.e.
Reconstruct a single area
ogb = outputBP.localReconstruction(gb(1,:),[20,20,20],sf); ogb.view();
Reconstruction into a data folder
The command dtrec is the counterpart of dtcrop for tilt series. It loops on the positions inside a table. We will use a different approach.
outputBP.reconstructIntoDataFolder('binnedGoldBeads',20,sf,'points',gb,'fo',1); figure;dslices binnedGoldBeads z -j *
Full resolution reconstruction
Now we can proceed to transport the locations annotated in the 3x binned geometry into the full size information.
fbp = outputBP.rescale('up',3);
We can apply the weight on the original tilt series at full resolution ts:
sWeightedFull = dpktomo.rec.applyRampFilter(ts);
It will take around a minute. The function accepts the mw flag to increase the speed.
fgb = fbp.localReconstruction(gb(1,:)*2^3,[60,60,60], sWeightedFull);
The localized reconstruction can be shown through:
fgb.view();
Note that we don't really need to use the object fgb as support. Its only role is to work out the geometry, computing the position of the 3d stack center with reference to the subtomogram that we want to reconstruct locally. We can work out the maths and compute the vector: [1035.431 551.378 318.140] . We could use this vector directly in dpktilt.math.backproject and get the same result.
fbpDirect = dpktilt.math.backproject([60,60,60], sWeightedFull,tiltAngles,'sc',[1035.431 551.378 318.140]);
We can now reconstruct all the gold beads at full resolution.
fbp.reconstructIntoDataFolder('fullGoldBeads',80, sWeightedFull,'points',gb*8,'fo',1);
and create a depiction of the data set.
figure;dslices fullGoldBeads z -j *
Refining the full resolution reconstruction
Now, we could find the actual positions of the gold beads with an alignment project. We create a spherical template and mask:
dwrite(-dsphere(10,80),'template.mrc'); dwrite(dsphere(16,80),'mask.mrc'); dwrite(dynamo_table_blank('fullGoldBeads'),'blankFull.tbl');
ddelete goldAligner dcp.new('goldAligner','d','fullGoldBeads','t','blankFull.tbl','template','template.mrc','mask','mask.mrc','show',0); dvput goldAligner -cr 0; dvput goldAligner -ir 0; dvput goldAligner -rf 0; dvput goldAligner -lims 40; dvput goldAligner -ite 1; dvput goldAligner -dim 80; check = dvcheck('goldAligner');
If the check doesn't report any problem, we can then just unfold the project:
dvunfold goldAligner goldAligner
Then we can check the result.
ddb goldAligner:a -v
The resulting gold bead is now centered
More importantly, the individual gold beads are now centered:
The alignment parameters are stored in the refinement table, which we can read into a workspace variable (we arbitrarily call it t)
ddb goldAligner:rt -r t
The position of gold beads in 3d is the addition of the computed shifts (columns 4 to 6 in the table) on the coarse positions of the gold beads:
gf3d = t(:,4:6)+gb*2^3;
r2coarse = outputBP.point3dInAlignedMicrograph(gf3d,'*'); sc = dpktilt.aux.markgold.MarkerSet(); sc.setFrameCellArray(r2coarse); ogc = dmarkers(sbin,'lm',sc);
We can show in this session of dmarkers the same shape set of positions that we computed before the alignment project. We will paint it i blue for comparison with the current positions.
ss.name ='previous'; ogc.bindGenericShapeSet(ss,'pointColor','b');