IMOD - mtk

From NoskeWiki
Jump to navigation Jump to search

About

NOTE: This page is a daughter page of: IMOD


Mtk is a command program which comes with the IMOD tomography suite and allows you to analyse the analyze distances between model objects in 3D. For more information you should visit the IMOD mtk man page. On this page I just give some examples of use.


Important notes about MTK and distance analysis

When using mtk for distance analysis, there are some tricky values to enter - hence it's very important to read and understand the "man page". I have use mtk mostly for distance analysis / closest approach and I like to output the resulting closest lines into a new model file (option 21). Here are a couple of tricky little caveats:

  • Before running mtk you should make sure your contours have correct surface number:
    • First mesh your model using imodmesh or use the meshing options in ModelView's Object window.
    • Run imodsortsurf to sort contours into surfaces.
  • For the first two question, and many others, you'll probably just want to answer no by hitting enter
  • For "starting and ending" enter: 0,0
  • For "power for radial weighting, number points" enter: 2,0 --> not sure why exactly but just do it!
  • The "bin width" is measured in MICRONS, so a value of "0.05" means increments of 50 nm are graphed.
  • For "bin width (radial distance), number of bins" I suggest you start with: "0.05,20" --> which will mean 50nm x 20 meaning it will measure/graph up to one micron ***
  • To output closet distances as open contours out to a new IMOD file you need option (21), but before this option work must first run option (17) and give a "Min & max distance for adding connecting lines max" which is also measured in microns, and you can enter something like: 0,5 --> for 10 microns


Example: Finding closest distances from scattered spheres to closed surfaces

Here's an example of trying to measure the distance from a bunch of scattered spheres in object 2, to the nearest surfaces (closed contours) in object 1. For easier reading, all the text I have input has been underlined. Lets assumed I've already meshed it properly, so I should first run imodsortsurf.

command_prompt$ imodsortsurf chlamydia_cell_1.mod chlamydia_cell_1.mod
Object 1 already has surface information which will be replaced
Object 1 sorted into 3 surfaces
...

Next I'll start mtk on chlamydia_cell_1.mod. I generate a graph in the "Plax window" but I also want to output open contours / closest contours distances to a new file called "out_file_with_lines.mod", and so I run option 17 then 25 to do this.

command_prompt$ mtk
Enter name of file with commands, or Return for input from keyboard       ...(hit return key)

Enter name of output file to store density values in (Return for none)    ...(hit return key)

0 for graphs in Plax window, 1 to suppress graphs: 0
0 for 3D density/closest approach analysis
  or 1 for ends versus bundle analysis: 0
Enter name of input model file, or Return to skip to entering options
chlamydia_cell_1.mod
Name of file of tilt info (Return if none):                               ...(hit return key)
Scale set from model header at  0.014000 microns/pixel
Enter list of Z values (numbered from 0) across 
which surfaces should be connected (Return for none)                      ...(hit return key)

Starting and ending Z to include (0,0 for all; 0,-1 for new model): 0,0
Object   kind    number     name
   1   meshes            Inclusion.1                             
   2   points    1237    Chlamydia.EB                            
   3   points     321    Chlamydia.IB                            
   4   meshes            Chlamydia.RB                            

Bin width (radial distance), number of bins: 0.05,200
Sampling length for lines, or 0 to find closest approach to whole line: 0
(For whole lines) Power for radial weighting,
 number of points to fit over: 2,0
(For line segments) 0 to find distance from start of sample segment,
 or 1 to find closest approach to segment: 1
0 to measure from center of scattered points or 1 to measure from surface: 1
Number of different graphs to compute: 1
For graph #  1, enter list of objects to measure distances
    from (reference objects) (Return for all, ranges OK)
2
For graph #  1, enter list of objects to measure distances
    to (neighboring objects) (Return for all, ranges OK)
1
Processing meshes...
Object   1:    53407 vertices,   320925 indices,   106810 triangles,
   247 polygons,      1 surfaces,    246 contours
Analyzing closest distances...
Doing point #   1237 Graph  1 to window 1:
 X: 0 to     10.00000, at     1.000000/div
 Y: 0 to      8.00000, at     0.800000/div
 1/2: Type/Average selected bins of the graph in a specified window
 3: Compute integrated number of (excess/missing) items in selected bins
 4/5: Display one graph in a window/Enter list of graphs to display
 6/7: Rescale X or Y axis of one window/Y axis of all windows
 8/9: Plot one window/all windows to PostScript graphics file
 10/11: Output PostScript file to screen/printer
 12: Output single or average graph to file
 13: Loop back to specify new range of Z to analyze (or new model)
 14: Change radial weighting of a graph
 15: Analyze new region and average with previous region(s)
 16: Redo current region(s) with new bin size, # of bins, or types for graphs
 17: Set min & max distances at which to compute angles and add lines to model 
 18: Save bins of a graph to specify rejection probabilities for random points
 19/26/20: Do current region(s) with shuffled/converted types or random shifts
 21: Save current set of objects and their types as an IMOD model
 22/27/23: Do many sets & integrals with shuffled/converted types/random shifts
 24: Take command input from file        25: Exit
 28/29/30 Save a graph/Average/Combine 2 graphs into an extra graph location
 31/32: Save graph in file/Read from file into an extra graph location
 33: Replace some sets of bins by their averages
 37/38/39 Add list of graphs/Read list of graphs from file/Read&Add from file
 40: Unshift an object
 41: Toggle between including and excluding items that failed to shift
 42: Export graph values or points for drawing to file
 43: List distances of close approach between min/max limits
 Option, or -1 for list of choices: 17
 Min & max distance for adding connecting lines and computing angles: 0,20
 Bin width (radial distance), number of bins: 0.05,1000
 0 to keep other parameters the same, 1 to change them: 0
 0 to keep same graph specifications or 1 to specify new graphs: 0
 Analyzing closest distances...
Doing point #   12371146 distances in window; angle mean=  0.00,  SD=  0.00
  1143 reference and    1 neighbor objects
 Graph  1 to window 1:
 X: 0 to     50.00000, at     5.000000/div
 Y: 0 to      8.00000, at     0.800000/div
 Option, or -1 for list of choices: 21
 Name of output model file: out_file_with_lines.mod
 Enter list of objects for which to put
 contours in window into new objects (Return for none)
 2
 There are           7  objects in the output model
 Connecting lines and points are in objects           6  and           7
 Option, or -1 for list of choices: 25

At the end of this the file out_file_with_lines.mod is a copy of our input file with three extra objects - object 5 is a copy of the spheres in range, object 6 are the open contours and object 7 are little spheres placed midway along the line. If we want to output the length of all distance we thus want to look at object 6 and we can run "imodinfo" with an "-l" argument to see all contour distances:

command_prompt$ imodinfo -l -o 6 out_file_with_lines.mod
...
# Obj Cont Pnts Length (in nm)
#------------------------
...
  6   1    2  5808.29
  6   2    2  4651.37
  6   3    2  2304.32
  6   4    2  1836.68
  6   5    2  1651.67
  6   6    2  4116.86
  6   7    2  1143.17
... (and so on)

The advantage of me doing this, is that I can then copy these number into my own graphing system to analyze distances outside of the "Plax window". To isolate the lengths, the easiest method is to paste them into any text editor, then do a find-and-replace to replace spaces with tabs, then copy and paste the next text into a program like Excel and the distances should now be in their own column. Within Excel you can generate new stats and/or histograms with formulae like "=MEDIAN(E1:E50)", "=COUNTIF(E4:E42,">2000")" and "=INT(E1/1000)" (copy this down).

  • TIP: If you find imodinfo output is too long to copy and paste easily you can also output it directly to a text file by adding a "-f" argument: imodinfo -l -f result.txt out_file_with_lines.mod.


Using a command file

As you can see above, entering all the commands can get a bit tedious, so one trick is to create a "command file" which is just a text file will all the input commands in the order they appear. For the example above, the command file looks would look like this:

$mtk


0                      # For graphs in Plax window
0                      # For 3D density/closest approach analysis.... # line below = input file (******)
chlamydia_cell_1.mod


0,0
0.05,200
0                      # To find closest approach.
2,0                    # Good power for radial weighting, & number points to fit over.
1                      # To find closest approach to segment.
1                      # To measure from surface of scattered points.
1                      # Number of different graphs to compute: 
2                      # Objects to measure distances from           ... (****** CHANGE ME FOR DIFFERENT MODEL).
1                      # Objects to measure distances to             ... (****** CHANGE ME FOR DIFFERENT MODEL).
17                     # (OPTION #17): Set min & max distances at which to compute angles and add lines to model.
0,20                   # Min & max distance for adding connecting lines and computing angles - got up to 20 microns.
0.05,1000              # Bin width (radial distance), number of bins.... 0.05 microns * 1000 = 5 microns limit on graph.
0                      # Keep other parameters same as before.
0                      # Keep same graph specifications same as before.
21                     # (OPTION #21): save current set of objects and their types as an IMOD model  # name of output file.
out_file.mod
2                      # Objects for which new contours will be placed for.
25                     # Exit program.
# (****)  - Lines with this should be changed for different models.

You can use this "command file" in two ways:

  1. Save it as a text file (eg: "closest_approach.txt"), run mtk and on the very first input of mtk ("enter name of file with commands, or return ...") you can enter the path to the file to run it.
  2. Copy the text from just after the $ sign and paste it into the command window

I personally find the second option much easier, but either way it can be very helpful to archieve these files. Don't forget you'll probably want to change the name of the input file each time! In my file above you'll notice the first two lines must be left blank, as are a few other lines. I've also added comments with "#" after some of the numbers, but be warned that putting comments on the end of many lines (eg: the file name) will break things, so you may find it's safer to omit or delete comments.



Example: Finding mitochondria with a given range of Golgi

This is the MTK input I use to isolate and output only those mitochondria (object 11) their open contour within 300 nm of the Golgi (object 1). Some thing to note:

  • The 300 nm part is highlighted below with stars (*****).
  • MTK only works well between open contours and a mesh.
  • Distances are measured from the CENTER of tubes - in other words from the points in the open contours to the point to to points in the closed contour - so you may need to factor in the average width of the tube radius and gaps between contours / points.
  • Bin width is measured in MICRONS, so 0.05 means increments of 50 nm are graphed.


[bjm-autophagy:DataDataData/Shared/ribbonmtk] a.costin% imodsortsurf -o 1,11 ribbon01.mod ribbon01.mod
Object 1 already has surface information which will be replaced
Object 1 sorted into 12 surfaces
Object 11 sorted into 311 surfaces
[bjm-autophagy:DataDataData/Shared/ribbonmtk] a.costin% mtk
Enter name of file with commands, or Return for input from keyboard

Enter name of output file to store density values in (Return for none)

0 for graphs in Plax window, 1 to suppress graphs: 0
0 for 3D density/closest approach analysis
 or 1 for ends versus bundle analysis: 0
Enter name of input model file, or Return to skip to entering options
    ribbon01.mod
Name of file of tilt info (Return if none): 
Scale set from model header at  0.005736 microns/pixel
Enter list of Z values (numbered from 0) across 
which surfaces should be connected (Return for none)

Starting and ending Z to include (0,0 for all; 0,-1 for new model): 0,0
Object   kind    number     name
   1   meshes            golgi_boundary1                         
   2   meshes            ER_boundary                             
   3   meshes            ER_boundary2                            
   4    lines     129    cell_membrane                           
   5   meshes            nucleus                                 
   7   meshes            tomogram_boundaries                     
   8   meshes            minimum_bounding_box                    
  11    lines     311    mitochondria_30                         
  12   points    1166    general_vesicles                        
  13   points    4448    mature_granules                         
  16   meshes            immature_granules_hand                  
  17   meshes            multi_vesicular_body                    
  18   points       8    points_of_interest                      
  19   meshes            high_res_area                           
  20   meshes            distortion_points                       
  23   points     414    mature_shadow                           
  24    lines      19    MEASURE_LENGTH                          

Bin width (radial distance), number of bins: 0.05,20
Sampling length for lines, or 0 to find closest approach to whole line: 0
(For whole lines) Power for radial weighting,
 number of points to fit over: 2,0
(For line segments) 0 to find distance from start of sample segment,
 or 1 to find closest approach to segment: 1
0 to measure from center of scattered points or 1 to measure from surface: 1
Number of different graphs to compute: 1
For graph #  1, enter list of objects to measure distances
    from (reference objects) (Return for all, ranges OK)
11
For graph #  1, enter list of objects to measure distances
    to (neighboring objects) (Return for all, ranges OK)
1
Processing meshes...
Object   1:    80173 vertices,   485195 indices,   160418 triangles,
  1964 polygons,     12 surfaces,   2014 contours
4 duplicate triangles ignored
Analyzing closest distances...
Doing line #  311 Graph  1 to window 1:
 X: 0 to      1.00000, at     0.100000/div
 Y: 0 to     10.00000, at     1.000000/div
 1/2: Type/Average selected bins of the graph in a specified window
 3: Compute integrated number of (excess/missing) items in selected bins
 4/5: Display one graph in a window/Enter list of graphs to display
 6/7: Rescale X or Y axis of one window/Y axis of all windows
 8/9: Plot one window/all windows to PostScript graphics file
 10/11: Output PostScript file to screen/printer
 12: Output single or average graph to file
 13: Loop back to specify new range of Z to analyze (or new model)
 14: Change radial weighting of a graph
 15: Analyze new region and average with previous region(s)
 16: Redo current region(s) with new bin size, # of bins, or types for graphs
 17: Set min & max distances at which to compute angles and add lines to model
 18: Save bins of a graph to specify rejection probabilities for random points
 19/26/20: Do current region(s) with shuffled/converted types or random shifts
 21: Save current set of objects and their types as a WIMP model
 22/27/23: Do many sets & integrals with shuffled/converted types/random shifts
 24: Take command input from file        25: Exit
 28/29/30 Save a graph/Average/Combine 2 graphs into an extra graph location
 31/32: Save graph in file/Read from file into an extra graph location
 33: Replace some sets of bins by their averages
 37/38/39 Add list of graphs/Read list of graphs from file/Read&Add from file
 40: Unshift an object
 41: Toggle between including and excluding items that failed to shift
 42: Export graph values or points for drawing to file
 Option, or -1 for list of choices: 16
 Bin width (radial distance), number of bins: 0.05,20
 0 to keep other parameters the same, 1 to change them: 1
 Sampling length for lines, or 0 to find closest approach to whole line: 1
 (For whole lines) Power for radial weighting,
  number of points to fit over: 2,0
 (For line segments) 0 to find distance from start of sample segment,
  or 1 to find closest approach to segment: 1
 0 to measure from center of scattered points or 1 to measure from surface: 1
 0 to keep same graph specifications or 1 to specify new graphs: 0
 Analyzing closest distances...
 Doing line #  311 Graph  1 to window 1:
 X: 0 to      1.00000, at     0.100000/div
 Y: 0 to      0.60000, at     0.060000/div
 Option, or -1 for list of choices: 17
 Min & max distance for adding connecting lines and computing angles: 0,0.3        (****)
 Bin width (radial distance), number of bins: 0.05,20
 0 to keep other parameters the same, 1 to change them: 1
 Sampling length for lines, or 0 to find closest approach to whole line: 1
 (For whole lines) Power for radial weighting,
  number of points to fit over: 2,0
 (For line segments) 0 to find distance from start of sample segment,
  or 1 to find closest approach to segment: 1
0 to measure from center of scattered points or 1 to measure from surface: 1
0 to keep same graph specifications or 1 to specify new graphs: 0
Analyzing closest distances...
Doing line #  311  90 distances in window; angle mean=  0.00,  SD=  0.00
   58 reference and    8 neighbor objects
Graph  1 to window 1:
X: 0 to      1.00000, at     0.100000/div
Y: 0 to      0.60000, at     0.060000/div
Option, or -1 for list of choices: 21
Name of output model file: ribbon01_output.mod
Enter list of objects for which to put
contours in window into new objects (Return for none)
11
There are 27 objects in the output model
Connecting lines and points are in objects 26 and 27
Option, or -1 for list of choices: -1
1/2: Type/Average selected bins of the graph in a specified window
3: Compute integrated number of (excess/missing) items in selected bins
4/5: Display one graph in a window/Enter list of graphs to display
6/7: Rescale X or Y axis of one window/Y axis of all windows
8/9: Plot one window/all windows to PostScript graphics file
10/11: Output PostScript file to screen/printer
12: Output single or average graph to file
13: Loop back to specify new range of Z to analyze (or new model)
14: Change radial weighting of a graph
15: Analyze new region and average with previous region(s)
16: Redo current region(s) with new bin size, # of bins, or types for graphs
17: Set min & max distances at which to compute angles and add lines to model 
18: Save bins of a graph to specify rejection probabilities for random points
19/26/20: Do current region(s) with shuffled/converted types or random shifts
21: Save current set of objects and their types as a WIMP model
22/27/23: Do many sets & integrals with shuffled/converted types/random shifts
24: Take command input from file        25: Exit
28/29/30 Save a graph/Average/Combine 2 graphs into an extra graph location
31/32: Save graph in file/Read from file into an extra graph location
33: Replace some sets of bins by their averages
37/38/39 Add list of graphs/Read list of graphs from file/Read&Add from file
40: Unshift an object
41: Toggle between including and excluding items that failed to shift
42: Export graph values or points for drawing to file
Option, or -1 for list of choices: 19
Processing meshes...
Object   1:    80173 vertices,   485195 indices,   160418 triangles,
  1964 polygons,     12 surfaces,   2014 contours
4 duplicate triangles ignored
Analyzing closest distances...
Doing line #  3112751 distances in window; angle mean=  0.00,  SD=  0.00
  187 reference and   12 neighbor objects
Graph  1 to window 1:
X: 0 to      1.00000, at     0.100000/div
Y: 0 to     10.00000, at     1.000000/div
Option, or -1 for list of choices: 25


To perform this quickly you, modify the bits in bold and cut and paste this:

mtk


0
0
cell01_DEF_mtk.mod


0,0
0.05,20
1
2,0
1
1
1
1
4
17
0,0.45
0.05,20
0
0
21
cell01_DEF_mtk_out.mod
4
25

Where 1 = mesh object, 2 = open contour object and 0.45 = min distance in microns.


Original example

Below is the original output from MTK Adam showed me:


[bjm-autophagy:DataDataData/Shared/ribbonmtk] a.costin% 3dmodv ribbon01_\(before_branching\).mod
[bjm-autophagy:DataDataData/Shared/ribbonmtk] a.costin% mtk
Enter name of file with commands, or Return for input from keyboard

Enter name of output file to store density values in (Return for none)

0 for graphs in Plax window, 1 to suppress graphs: 0
0 for 3D density/closest approach analysis
 or 1 for ends versus bundle analysis: 0
Enter name of input model file, or Return to skip to entering options
  ribbon01.mod
Name of file of tilt info (Return if none): 
Scale set from model header at  0.005736 microns/pixel
Enter list of Z values (numbered from 0) across 
which surfaces should be connected (Return for none)

Starting and ending Z to include (0,0 for all; 0,-1 for new model): 0,0
Object   kind    number     name
   1   meshes            golgi_boundary1                         
   ...  
  11    lines     311    mitochondria_30                                        

Bin width (radial distance), number of bins: 0.05,100
Sampling length for lines, or 0 to find closest approach to whole line: 0
(For whole lines) Power for radial weighting,
 number of points to fit over: 2,0
(For line segments) 0 to find distance from start of sample segment,
 or 1 to find closest approach to segment: 1
0 to measure from center of scattered points or 1 to measure from surface: 1
Number of different graphs to compute: 1
For graph #  1, enter list of objects to measure distances
    from (reference objects) (Return for all, ranges OK)
1
 For graph #  1, enter list of objects to measure distances
     to (neighboring objects) (Return for all, ranges OK)
11
 Processing meshes... 
Object   1:    80173 vertices,   485195 indices,   160418 triangles,
   1964 polygons,     12 surfaces,   2014 contours
 4 duplicate triangles ignored
 Analyzing closest distances...
Doing surface #   12 Graph  1 to window 1:
 X: 0 to      5.00000, at     0.500000/div
 Y: 0 to      2.50000, at     0.250000/div
 1/2: Type/Average selected bins of the graph in a specified window
 3: Compute integrated number of (excess/missing) items in selected bins
 4/5: Display one graph in a window/Enter list of graphs to display
 6/7: Rescale X or Y axis of one window/Y axis of all windows
 8/9: Plot one window/all windows to PostScript graphics file
 10/11: Output PostScript file to screen/printer
 12: Output single or average graph to file
 13: Loop back to specify new range of Z to analyze (or new model)
 14: Change radial weighting of a graph
 15: Analyze new region and average with previous region(s)
 16: Redo current region(s) with new bin size, # of bins, or types for graphs
 17: Set min & max distances at which to compute angles and add lines to model 
 18: Save bins of a graph to specify rejection probabilities for random points
 19/26/20: Do current region(s) with shuffled/converted types or random shifts
 21: Save current set of objects and their types as a WIMP model
 22/27/23: Do many sets & integrals with shuffled/converted types/random shifts
 24: Take command input from file        25: Exit
 28/29/30 Save a graph/Average/Combine 2 graphs into an extra graph location
 31/32: Save graph in file/Read from file into an extra graph location
 33: Replace some sets of bins by their averages
 37/38/39 Add list of graphs/Read list of graphs from file/Read&Add from file
 40: Unshift an object
 41: Toggle between including and excluding items that failed to shift
 42: Export graph values or points for drawing to file
  Option, or -1 for list of choices: 25


Links