Difference between revisions of "Cropping unbinned particles after having worked with binned particles"

From Dynamo
Jump to: navigation, search
Line 2: Line 2:
  
  
 +
= Walkthrough =
  
Creates the catalogue in full size
+
== Creating a data set ==
 +
This part of the walkthrough serves only to create a synthetic data set
 +
 
 +
Creates the catalogue in full size (let us assume 1 a.u. -arbitrary unit- per pixel)
 
  <tt>dctutorial full -n 3  -cc withmodels</tt>
 
  <tt>dctutorial full -n 3  -cc withmodels</tt>
 +
In real life, you are advised to always have a catalogue that links the "big", full resolution tomogram
  
 
+
Let Dynamo create a 1x binned version of each tomogram.
Let Dynamo create a bin1 version of eac tomogram
 
 
  <tt>dynamo_catalogue_bin full_withmodels 1 -ss 256 </tt>
 
  <tt>dynamo_catalogue_bin full_withmodels 1 -ss 256 </tt>
-ss 256 defines the size of the chunks that are loaded at once from disk. This parameter does not matter for small tomograms like here.
+
-ss 256 defines the size of the chunks that are loaded at once from disk. This parameter does not matter for small tomograms like here. Each newly created tomogram will have a pixel size of 2 a.u.  
  
  
Now, create a new catalogue where the bin1 versions are the ''main entries'' (meaning that the particles will be cropped from the binned version);
+
Now, we create a new catalogue where the 1x bin versions are the ''main entries'' (meaning that the particles will be cropped from the binned version);
  
 
  <tt>dcm -c full_withmodels -l t -ws o</tt>
 
  <tt>dcm -c full_withmodels -l t -ws o</tt>
Line 19: Line 23:
 
  <tt>binnedFiles=strrep((o.results),'.mrc','_CatBinned1.mrc');</tt>
 
  <tt>binnedFiles=strrep((o.results),'.mrc','_CatBinned1.mrc');</tt>
  
A good policy ios to check that the chars that we generated correspond to files that actually exist:  
+
A good policy is to check that the chars that we generated correspond to files that actually exist:  
 
  <tt>isfile(binnedFiles);</tt>
 
  <tt>isfile(binnedFiles);</tt>
  
Line 46: Line 50:
 
dcmodels binned1
 
dcmodels binned1
  
 +
== Cropping particles from the binned tomogram ==
 
% creates a text file that expresses which models will come from
 
% creates a text file that expresses which models will come from
 
% which tomogram. The format is as follows
 
% which tomogram. The format is as follows
Line 52: Line 57:
 
%  
 
%  
 
createCroppingVll();
 
createCroppingVll();
 
 
 
  
  
Line 69: Line 71:
  
  
<nowiki>% Ok, now the actual meat... how do we crop the particle in the unbinned
 
% tomogram using as input a table?
 
  
% We first upscaled the table
+
== Cropping particles from the full resolution tomoamo tomogram ==
tUpscale = dynamo_table_rescale('targetData/crop.tbl','factor',2);
+
  Ok, now the actual meat... how do we crop the particles in the unbinnedtomogram '''using as input the table collected on the binned particles'''? Remember, we disregard the metadata from the full size tomogram
 +
 
 +
=== Upscale the coordinates in the table ===
 +
We first upscale the table
 +
<tt>tUpscale = dynamo_table_rescale('targetData/crop.tbl','factor',2);</tt>
 +
 
 +
Then we create a text file that indicates which tomogram file is intended  for which tomogram number in the table (remember that tomogram numbers are represented in the index entry in the column 20).
  
% then we create a text file that indicates which tomogram file is intended
+
The text file is formatted as
% for which tomogram number in the table (remember that tomogram numbers
+
<nowiki>% 1 tomogramFileForIndex1
% are represented in the index entry in the column 20)
 
%
 
% The text file is formated as
 
% 1 tomogramFileForIndex1
 
 
% 2 tomogramFileForIndex1
 
% 2 tomogramFileForIndex1
 
% </nowiki>
 
% </nowiki>
  
 +
 +
<tt>edit createTomogramIndexMapFile</tt>
 +
 +
<nowiki>binnedCatalogue = dread('binned1.ctlg');
 +
%ull  = dread('full_withmodels.ctlg');
 +
 +
linesMap = {};
 +
foundIndices = tUpscale(:,20);
 +
for i=1:length(foundIndices)
 +
    thisIndex = foundIndices(i);
 +
    fileBinned = binnedCatalogue.volumes{thisIndex}.fullFileName();
 +
    fileUnbinned = strrep(fileBinned,'_CatBinned1','');
 +
   
 +
    if ~isfile(fileUnbinned)
 +
      error('Hm... the corresponding unbinned file cannot be found: %s',fileUnbinned);
 +
    end
 +
    linesMap{end+1} = [num2str(thisIndex), ' ',fileUnbinned];
 +
    %linesMap{end+1} = [num2str(i), ' ',fileUnbinned];
 +
end
 +
 +
% writes the actual file
 +
mbio.writeas.textlines(linesMap,'mapFullTomograms.doc'); </nowiki>
  
 
We run the newly created script:
 
We run the newly created script:

Revision as of 18:57, 5 February 2020

Work in progress


Walkthrough

Creating a data set

This part of the walkthrough serves only to create a synthetic data set

Creates the catalogue in full size (let us assume 1 a.u. -arbitrary unit- per pixel)

dctutorial full -n 3  -cc withmodels

In real life, you are advised to always have a catalogue that links the "big", full resolution tomogram

Let Dynamo create a 1x binned version of each tomogram.

dynamo_catalogue_bin full_withmodels 1 -ss 256 

-ss 256 defines the size of the chunks that are loaded at once from disk. This parameter does not matter for small tomograms like here. Each newly created tomogram will have a pixel size of 2 a.u.


Now, we create a new catalogue where the 1x bin versions are the main entries (meaning that the particles will be cropped from the binned version);

dcm -c full_withmodels -l t -ws o

Creates a list with the names of the binned tomograms

binnedFiles=strrep((o.results),'.mrc','_CatBinned1.mrc');

A good policy is to check that the chars that we generated correspond to files that actually exist:

isfile(binnedFiles);

should produce an array of 3 "trues", i.e:

% ans =
% 
%   1×3 logical array
% 
%    1   1   1 

% % create the new catalogue % We creates a text file which just a list of files

mbio.writeas.textlines(binnedFiles,'binnedFileList.vll');
which is used to create a catalogue: 
dcm -create binned1 -fromvll binnedFileList.vll

% % imports the models of the main catalogue %

scaleModels;

% checks that the new catalogue has indeed 3 models dcmodels binned1

Cropping particles from the binned tomogram

% creates a text file that expresses which models will come from % which tomogram. The format is as follows % tomogram1 % >model file 1 in tomogram 1 % createCroppingVll();


dtcrop binned.vll reorder targetData 24; % the 'reorder' string as second argument tells dynamo to parse the % contents of the vll and to use a new set of tags on the created % particles


% check the results

ddbrowse -d targetData -t targetData/crop.tbl  
1x binned particles (pixel size 2nm )


Cropping particles from the full resolution tomoamo tomogram

 Ok, now the actual meat... how do we crop the particles in the unbinnedtomogram using as input the table collected on the binned particles? Remember, we disregard the metadata from the full size tomogram

Upscale the coordinates in the table

We first upscale the table

tUpscale = dynamo_table_rescale('targetData/crop.tbl','factor',2);

Then we create a text file that indicates which tomogram file is intended for which tomogram number in the table (remember that tomogram numbers are represented in the index entry in the column 20).

The text file is formatted as

% 1 tomogramFileForIndex1
% 2 tomogramFileForIndex1
% 


edit createTomogramIndexMapFile
binnedCatalogue = dread('binned1.ctlg');
%ull   = dread('full_withmodels.ctlg');

linesMap = {};
foundIndices = tUpscale(:,20);
for i=1:length(foundIndices)
    thisIndex = foundIndices(i);
    fileBinned = binnedCatalogue.volumes{thisIndex}.fullFileName();
    fileUnbinned = strrep(fileBinned,'_CatBinned1','');
    
    if ~isfile(fileUnbinned)
       error('Hm... the corresponding unbinned file cannot be found: %s',fileUnbinned); 
    end
    linesMap{end+1} = [num2str(thisIndex), ' ',fileUnbinned];
    %linesMap{end+1} = [num2str(i), ' ',fileUnbinned];
end

% writes the actual file
mbio.writeas.textlines(linesMap,'mapFullTomograms.doc'); 

We run the newly created script:

createTomogramIndexMapFile();

% % Now we crop the particles with the newly created file mapFullTomograms %

dtcrop('mapFullTomograms.doc',tUpscale,'targetDataFull', 48);

Now we check the results:

ddbrowse -d targetDataFull -t targetDataFull/crop.tbl
File:UpScaleCroppingUnBinnedGallery.png
1x binned particles (pixel size 2nm )