Utilities for stack creation with the Hagen scheme

From Dynamo
Revision as of 11:52, 10 March 2017 by Daniel Castaño (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here we describe some parsers we frequently use to organize the data folders delivered by the microscope operators into single stack files. The Hagen scheme collects the data in the order 0,angle1,-angle1,angle2,-angle2,..., which frequently leads to inconveniently formatted raw data folders after a data collection session.

This utility just:

  • parses the structure of the input folder
  • creates a correctly formatted input for the Imod command alignframes
  • creates the corresponding Imod order and
  • submits it to Imod

Thus, you'll need to have Imod activated in your session to use this parser

Input raw data folder

A typical input raw data folder contains

  • a gain reference file (with extension .dm4)
  • a defect file (with extension .txt)
  • a series of files, each one for each tilt angle.

An example:

  . . . .

Imod wrappers

Creates the wrapper object

p = <full path to your directory>;
a = dpcomp.hagen.StackConverter();

It will detect the contents of the file, and check that it can understand the ordering of the micrographs.

Order the projection files

You can display if the files where correctly parsed:


and, if so, you can then create a text file for them


which will be called by default orderedFiles.list and will be located on the same directory. You can also create text file for the tilt angles with a.writeTiltList(); This will create by default the file stack.tlt

Align the frames

Imod order

The created order for imod will have the structure:

alignframes -gain GAINFILE -defect DEFECTFILE -mode 2 -list LIST STACK

By default, the target STACK will be called stack.mcr.

To create and run it, type:


If the target STACK already exist in disk, Dynamo will show the formatted order, but will abort before submitting it to Imod. The 'execute' flag indicates Dynamo to submit the order (not only create the string). Other default values can be changed with the flags 'gain','defect','list','mode','target'


You need to activate Imod before opening Matlab (or before starting the Dynamo standalone session).

Batched operation

Single folder

To operate all the steps with default values on a single folder, use:

 check = dpcomp.hagen.StackConverter.processFolder(path) 

Cell array of folders

If you have the names of identically structured folders in a array (say, myFolders), you can operate the order:

 check = dpcomp.hagen.StackConverter.processFolderArray(myFolders) 

to create the stacks for all of them.