Difference between revisions of "Advanced starters guide"

From Dynamo
Jump to navigation Jump to search
Line 114: Line 114:
  
 
== Cropping particles ==
 
== Cropping particles ==
 +
 +
Now we want to use the positions that we have marked to extract the subtomograms and format them as a [[data folder]]. The first thing we nee is an estimation of the sidelength in pixels of each of the subtomograms. In [[dtmslice]] We can use the keys [1] and [2] to define two anchor points that appear as rombohedra. Clicking (with the right button) onto the black dashed that links the will show on screen both coordinates and the distance between them. All distances are reported in pixels of the not-binned tomogram: even if you are using any un-binned version, ''Dynamo'' keeps track of it.
 +
 +
[[File:FhvMeasureDistance.png|thumb|center|500px|Measuring distances with [1] , [2] and right-click]].
 +
 +
We will thus choose to create a datafolder with a cubic sidelength of 128 pixels (remember that the particles will be cropped in the ''unbinned'' tomogram). This will ensure that the crowns fit comfortably inside the physical box, even if our manual picking imposes an error of several pixels. If you were using, say, a ''thickness'' parameter of 10 pixles in <tt>dtmslice</tt>, you have to count with at least this inaccuracy in the location of the particles.
 +
 +
Now, we check that the  catalogued tomogram contains the model that we manually picked before:
  
 
  <nowiki>>> dcmodels fhv
 
  <nowiki>>> dcmodels fhv
 
Volume 1 contains 1 models in total
 
Volume 1 contains 1 models in total
 
/Users/casdanie//fhv/tomograms/volume_1/models/mboxes.omd</nowiki>
 
/Users/casdanie//fhv/tomograms/volume_1/models/mboxes.omd</nowiki>
 +
 +
We could just use  the catalogue GUI to extract the particles, be it is also possible top roceed directly  with the command line. We will use the  <tt>dtcrop</tt> command, .which requires preparing a [[table]] with the information of the model.
 +
 +
<nowiki>  m = dread('/Users/casdanie//fhv/tomograms/volume_1/models/mboxes.omd');
 +
t = m.grepTable();</nowiki>
 +
 +
Here, you read the file into a model object (which we arbitrarily choose to call <tt>m</tt>), and then you use the <tt>grepTable</tt> method on this object to extract a variable into your workspace. We arbitrarily call it <tt>t</tt>.
 +
 +
Note that we can extract models directly from the output of <tt>dcmodels</tt>
 +
<nowiki>  dcmodels fhv -i 1 -ws o;
 +
m = dread(o.files{1});
 +
t = m.grepTable();</nowiki>
 +
 +
i.e., we load the answer of <tt>dcmodels</tt> for volume index <tt>-i 1</tt>in the output variable <tt>o</tt> .  Inside it, there is a field called <tt>'files'</tt> which contains a [[matlab cell array| cell array]] of files containing models.  Then we read the first entry <tt>o.files{1}</tt>.

Revision as of 16:27, 16 July 2017

This walkthrough uses a small size example based on a real tomogram to covers several tasks.


The example data set

The data is a fraction of a tomogram. The full tomogram was used in "Cryo-electron tomography reveals novel features of a viral RNA replication compartment." (Ertel et al.), and represents several FHV viruses docked in the membrane of a mythocondrion.


Downloading

In principle, you can download all the files related to this example with the command:

 dpkhelp.wiki.downloadExample('fhv');

If it fails under Matlab or the Dynamo command line, you can try to directly use the linux order

wget  https://wiki.dynamo.biozentrum.unibas.ch/w/doc/data/fhv/crop.rec 

or

curl -O  https://wiki.dynamo.biozentrum.unibas.ch/w/doc/data/fhv/crop.rec 

unter MacOS.

This should have created the file called crop.rec in your current directory.

Size check of a file

You're probably curious to see what's inside, so that let's write first:

dfile crop.rec

to let Dynamo check the dimensions of the file. The header of a .rec file is readed as a regular mrc, yielding:

 filetype: volume
 size: 1285 x 956 x 786

So, it's a tomogram.

Lightweight visualization

We can inspect quickly its contents with dtmshow

dtmshow -otf crop.rec

Hereby, the flag -otf means "on the fly", telling dtmshow to not preload the full tomogram, but to access in disk the individual slices that are needed when inspecting a particular area.

Basic controls of dtmshow

Go up and down. We want to select the locations were the vesicles intersect the mythocondrion membrane and average them together. For this, we need to catalogue the tomogram, so that our annotations are stored with a clear relationship with the tomogram.

Cataloguing the tomogram

We can create catalogues just to contain a single tomogram. They are useful to keep track of all annotations, and of the typical transforms (binning, cropping of fractions) that we usually perform on a larged size tomogram of interest. In this case, we can create the catalogue directly from the command line:

 >dcm -c create fhv 

where dcm is the short form of dynamo_catalogue_manager and fhv is just an arbitrary name. The just created catalogue is empty, and we can add our tomogram with:

 dcm -c fhv -at crop.rec

We can check that the tomogram is in the catalogue by asking Dynamo to show the contents of the catalogue

dcm -c fhv -l tomograms

or

dcm -c fhv -l t

The flag -l asks Dynamo to list items of a given category of catalogue contents, in this case tomograms

Prebinning the tomograms

We typically want to prebin the tomogram, i.e., have a version of smaller size that is known to the catalogue. This version will be useful in some operations that require a full tomogram in memory, an operation that can consume much memory and need a long time. In this example, this is probably not necessary: a tomogram with a sidelength on x and y of ~1000 pixels shouldn't pose any visualization problem. Still, in the command line, we can write

dynamo_catalogue_bin('fhv', 1, 'zchunk', 300); 

where the parameter zchunk represents the maximum number of z slices that are kept simultaneously in the memory during the binning process. This parameter might be important for larger size tomograms.

Operation with GUI

These steps could have been performed thorugh the dcm GUI <tbi>

Annotation of particle positions

Now we can open the tomogram through the catalogue:

dtmslice crop.rec -c fhv  -prebinned 1 


dtmslice opened on the FHV example tomogramdtmslice


Probably you don't like the initial contrast, change it with the button in the toolbar.

contrast adjustment options inside dtmslice

Navigating the tomogram

Use the bar to move the slice up and dow, or drag it with the cursor while keeping the main mouse button pressed. Other axiliary tools are the keys x,y,z to change the slice orientation, the number of projected slices (called thickness in the GUI)

Creation of models to contain annotations

In this example we just want to manually pick some particles. This can be done creating a general or box model, which will reside in memory till we save it into the catalogue.

Creating a new model in the scene. Each annotation is represented by a box

After creating the model, it will be only model currently active in the dtmslice scene. You can add new points pressing on [c]. The idea is to mark on the positions where you see the "neck" of a vesicle (what we called "crowns") in contact with the mythocondrial membrane.

Clicking the crowns on screen

The last marked point can be deleted by pressing [delete]. An arbitrary point can be deleting by clicking on it with the auxiliary mouse button. This will open a menu that includes the option of deleting the point (through Ctrl+X in Linux or Cmmd+X in Mac).

At this stage you probably want to change the transparence of the depicted slice, so that you can control which objects have been already clicked below the depicted slide.

Selection of points. Transparency of slide was set to 0.8

.

When you are done, remember to save the model, using the menu options on active model or simply clicking on the disk icon in tomoslice.

Cropping particles

Now we want to use the positions that we have marked to extract the subtomograms and format them as a data folder. The first thing we nee is an estimation of the sidelength in pixels of each of the subtomograms. In dtmslice We can use the keys [1] and [2] to define two anchor points that appear as rombohedra. Clicking (with the right button) onto the black dashed that links the will show on screen both coordinates and the distance between them. All distances are reported in pixels of the not-binned tomogram: even if you are using any un-binned version, Dynamo keeps track of it.

Measuring distances with [1] , [2] and right-click

.

We will thus choose to create a datafolder with a cubic sidelength of 128 pixels (remember that the particles will be cropped in the unbinned tomogram). This will ensure that the crowns fit comfortably inside the physical box, even if our manual picking imposes an error of several pixels. If you were using, say, a thickness parameter of 10 pixles in dtmslice, you have to count with at least this inaccuracy in the location of the particles.

Now, we check that the catalogued tomogram contains the model that we manually picked before:

>> dcmodels fhv
Volume 1 contains 1 models in total
/Users/casdanie//fhv/tomograms/volume_1/models/mboxes.omd

We could just use the catalogue GUI to extract the particles, be it is also possible top roceed directly with the command line. We will use the dtcrop command, .which requires preparing a table with the information of the model.

  m = dread('/Users/casdanie//fhv/tomograms/volume_1/models/mboxes.omd');
t = m.grepTable();

Here, you read the file into a model object (which we arbitrarily choose to call m), and then you use the grepTable method on this object to extract a variable into your workspace. We arbitrarily call it t.

Note that we can extract models directly from the output of dcmodels

  dcmodels fhv -i 1 -ws o;
m = dread(o.files{1});
t = m.grepTable();

i.e., we load the answer of dcmodels for volume index -i 1in the output variable o . Inside it, there is a field called 'files' which contains a cell array of files containing models. Then we read the first entry o.files{1}.