├── .gitignore ├── README.md ├── assets ├── autoalign_activate_example.m ├── autoalign_dynamo.png ├── dynamo_markers.png └── filaments.png ├── autoalign ├── autoalign.m ├── autoalign_aux_cleanup.m ├── autoalign_sleep.m ├── autoalign_summarise.m ├── autoalign_warn.m ├── autoalign_workflow_cleanup.m ├── check_status_cmdout.m ├── dautoalign4warp.m ├── dms2mod.m ├── get_directories.m ├── get_tasolution.py ├── handle_exception.m ├── next_dir.m ├── tiltalign.m ├── tiltalign_wrapper.sh ├── ts_info_from_dir.m └── warp2catalogue.m └── install.sh /.gitignore: -------------------------------------------------------------------------------- 1 | test_data/ 2 | test/ 3 | tmp.tlt 4 | tmp.csv 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Automated on-the-fly fiducial-based tilt-series alignment for Warp tilt-series directories 2 |

3 | dautoalign4warp workflow overview 8 |

9 | 10 | #### Workflow from raw data to aligned tilt-series 11 | 1. Follow the Warp user guide to take you from frames to tilt-series 12 | 2. Run `dautoalign4warp`, it will watch your tilt-series directory (`imod`) and align any incoming tilt-series 13 | 3. Import the results into warp and reconstruct your tomograms! 14 | 4. (optional) Use `warp2catalogue` to easily create a Dynamo catalogue for particle picking 15 | 16 | #### Motivation 17 | - Robust, automated tilt-series alignment of stacks created by Warp 18 | - Ability to easily use Warp reconstructions with the geometrical particle picking tools in Dynamo 19 | 20 | #### Outline 21 | - Automated robust fiducial detection and fiducial position refinement using Dynamo 22 | 23 |

24 | Automatically detected fiducial markers 29 |

30 | 31 | - Creation of an IMOD model from these positions 32 | - Solve for tilt-series alignment transformations using the IMOD program tiltalign (fixed tilt angles, solve for one rotation angle, robust fitting) 33 | - Preparation of all results for easy import back into Warp 34 | 35 | #### Particle picking in Dynamo? 36 | Do you want to use the geometrical tools in Dynamo to pick particles, imparting prior knowledge about your particle orientation to further subtomogram averaging? 37 | 38 |

39 | Filament models with different geometries 42 |

43 | 44 | If so, you may want to use the `warp2catalogue` function to quickly set up a catalogue of your data, correctly linked for visualisation of Warp's deconvolved tomograms with cropping directly from the 3d-CTF corrected tomogram from warp 45 | 46 | 47 | #### Installation 48 | #### Requirements 49 | - Dynamo (1.1.478 or later, 1.1.522 has problems) activated in MATLAB 50 | - IMOD (tested on 4.10.35) 51 | - MATLAB (R2019a or later) (tested with the following toolboxes) 52 | - parallel computing toolbox 53 | - image processing toolbox 54 | - computer vision toolbox 55 | - curve fitting toolbox 56 | - Python (3.0 or later) 57 | 58 | There have been reports of slowness when MATLAB is configured to run on external computational resources, for this reason we recommend to run locally. 59 | 60 | #### Download and install 61 | ```bash 62 | git clone https://github.com/alisterburt/autoalign_dynamo.git 63 | cd autoalign_dynamo 64 | ./install.sh 65 | ``` 66 | 67 | This requires git, which can be installed by your package manager if not already present in your system, for example... 68 | ```bash 69 | sudo apt-get install git 70 | ``` 71 | 72 | You will be asked where you would like to install the package, the default location is... 73 | ```bash 74 | /opt/autoalign_dynamo 75 | ``` 76 | 77 | After installation you can remove the installation files 78 | ```bash 79 | cd .. 80 | rm -r autoalign_dynamo 81 | ``` 82 | 83 | #### Activation and Running 84 | 1. Make sure Dynamo is activated in MATLAB (`dynamo_activate`) 85 | 2. Activate autoalign_dynamo (`run /path/to/install/autoalign_activate.m`) 86 | 3. run `dautoalign4warp(, , , , )` 87 | 88 | This will watch the warp tilt-series directory, align your tilt-series on-the-fly and tidy everything up ready for import back into Warp so you can generate your tomograms. The warp tilt-series directory is the 'imod' directory found inside your main warp processing directory. 89 | 90 | If you then want to use Dynamo for particle picking... 91 | 92 | 4. Import alignments into Warp as described in Warp's user guide 93 | 5. Reconstruct downsampled tomograms (and deconvolved tomograms for visualisation) in Warp 94 | 6. Run `warp2catalogue(, )` 95 | 96 | This will generate a catalogue in which the visualisation volume is the deconvolved tomogram from Warp, particles will be cropped from the 3D-CTF corrected, unfiltered reconstructions 97 | 98 | To look at this catalogue, in MATLAB type... 99 | ``` 100 | dcm warp_catalogue 101 | ``` 102 | 103 | #### Additional info 104 | If you want to use the automated alignment script outside of the Warp directory structure, a function called align is provided which allows automated alignment of a single tilt-series. 105 | 106 | Enjoy! 107 | -------------------------------------------------------------------------------- /assets/autoalign_activate_example.m: -------------------------------------------------------------------------------- 1 | % Activation script for autoalign_dynamo 2 | install_loc = 'XXX_INSTALL_LOC_XXX'; 3 | PATH = getenv('PATH'); 4 | addpath(install_loc); 5 | setenv('PATH', [install_loc, ':' PATH]); 6 | clear install_loc 7 | clear PATH 8 | disp("Successfully activated 'autoalign_dynamo'!") 9 | -------------------------------------------------------------------------------- /assets/autoalign_dynamo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alisterburt/autoalign_dynamo/6c8760199057fdf3eee28b12adad893b9ae4b91c/assets/autoalign_dynamo.png -------------------------------------------------------------------------------- /assets/dynamo_markers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alisterburt/autoalign_dynamo/6c8760199057fdf3eee28b12adad893b9ae4b91c/assets/dynamo_markers.png -------------------------------------------------------------------------------- /assets/filaments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alisterburt/autoalign_dynamo/6c8760199057fdf3eee28b12adad893b9ae4b91c/assets/filaments.png -------------------------------------------------------------------------------- /autoalign/autoalign.m: -------------------------------------------------------------------------------- 1 | function final_dir_name = autoalign(stack, workflow_name, tilt_angles, apix, fiducial_diameter_nm, workflows_folder) 2 | %%% Parameter descriptions 3 | % stack - filepath of tilt series stack in mrc format 4 | % workflow_name - name of workflow to be saved 5 | % tilt_angles - filepath to text file containing tilt angles (IMOD format tlt/rawtlt) 6 | % apix - pixel size in angstroms of tilt series 7 | % fiducial_diameter_nm - diameter of fiducials in nanometers 8 | % workflows folder - directory in which to save the workflow 9 | 10 | %%% Prep names for marker and model files 11 | [p, basename, ext] = fileparts(workflow_name); 12 | workflow_folder = fullfile(workflows_folder, strcat(basename, '.AWF')); 13 | markers_file = fullfile(workflow_folder, 'workingMarkers.dms'); 14 | model_file = fullfile(workflow_folder, 'workingMarkers.mod'); 15 | 16 | %%% Set up alignment workflow 17 | workflow = dtsa(workflow_name, '--nogui', '-path', workflows_folder, 'fp', 1); 18 | 19 | %%% Calculate fiducial radius in unbinned pixels 20 | fiducial_diameter_px = (fiducial_diameter_nm * 10) / apix; 21 | fiducial_radius_px = fiducial_diameter_px / 2; 22 | fiducial_radius_px = round(fiducial_radius_px); 23 | 24 | % Copy tilt angles to temporary file 25 | % (does not accept .rawtlt files so do this to force .tlt extension) 26 | copyfile(tilt_angles, 'tmp.tlt'); 27 | 28 | % Assign workflow parameters 29 | % files 30 | workflow.enter.tiltSeries(stack); 31 | workflow.enter.tiltAngles('tmp.tlt'); 32 | 33 | % computing params 34 | workflow.enter.settingComputing.parallelCPUUse(1); 35 | workflow.enter.settingComputing.cpus('*') 36 | workflow.enter.settingDetection.detectionBinningFactor(1); 37 | 38 | % acquisition settings 39 | workflow.enter.settingAcquisition.apix(apix); 40 | 41 | % relevant lengths for bead detection 42 | workflow.enter.settingDetection.beadRadius(fiducial_radius_px); 43 | workflow.enter.settingDetection.maskRadius(fiducial_radius_px * 1.5); 44 | workflow.enter.templateSidelength(fiducial_radius_px * 4); 45 | 46 | % Trim markers (aiming to keep as many good observations, later trimmed by IMOD) 47 | workflow.area.indexing.step.tiltGapFiller.parameterSet.residualsThreshold(5); 48 | workflow.area.refinement.step.trimMarkers.parameterSet.maximalResidualObservation(5); 49 | 50 | %%% Run workflow up to refinement 51 | workflow.run.area.uptoRefinement(); 52 | 53 | %%% Create IMOD format model 54 | dms2mod(markers_file, model_file, stack); 55 | 56 | %%% Cleanup 57 | final_dir_name = autoalign_workflow_cleanup(workflow_folder, workflow_name, workflows_folder); 58 | end -------------------------------------------------------------------------------- /autoalign/autoalign_aux_cleanup.m: -------------------------------------------------------------------------------- 1 | function autoalign_aux_cleanup() 2 | delete tmp.csv 3 | delete tmp.tlt 4 | end 5 | 6 | -------------------------------------------------------------------------------- /autoalign/autoalign_sleep.m: -------------------------------------------------------------------------------- 1 | function autoalign_sleep(processed) 2 | % Initial message to inform that no new TS found 3 | msg = sprintf('No new tilt series found at %s\n', datestr(now,'HH:MM:SS')); 4 | disp(msg); 5 | 6 | % Inform about n tilt series processed 7 | n_processed = size(processed, 2); 8 | msg = sprintf('%d tilt series processed in this session so far', n_processed); 9 | disp(msg) 10 | 11 | % Sleep 12 | disp('Going to sleep for 30s...') 13 | pause(30) 14 | end 15 | 16 | -------------------------------------------------------------------------------- /autoalign/autoalign_summarise.m: -------------------------------------------------------------------------------- 1 | function autoalign_summarise(output_folder) 2 | info_file_paths = fullfile(output_folder, '*', 'info', 'fitting.doc'); 3 | command = ['cat ', info_file_paths, " | grep rms | awk '{print $2}' > ",fullfile(output_folder, 'rms.txt')]; 4 | command = strjoin(command); 5 | system(command); 6 | 7 | m = csvread(fullfile(output_folder, 'rms.txt')); 8 | mean_rms = mean(m); 9 | min_rms = min(m); 10 | max_rms = max(m); 11 | std_rms = std(m); 12 | 13 | fprintf('Updated RMSD stats for experimental bead positions vs. projection model\nmin: %.2f\nmax: %.2f\nmean: %.2f\nsdev: %.2f\n', min_rms, max_rms, mean_rms, std_rms); 14 | end 15 | 16 | 17 | -------------------------------------------------------------------------------- /autoalign/autoalign_warn.m: -------------------------------------------------------------------------------- 1 | function [outputArg1,outputArg2] = autoalign_warn(msg) 2 | % Seems like dynamo plays with warning state, capture original state 3 | orig_state = warning; 4 | warning('on'); 5 | 6 | % warn 7 | warning(msg); 8 | 9 | % restore original state 10 | warning(orig_state); 11 | end 12 | 13 | -------------------------------------------------------------------------------- /autoalign/autoalign_workflow_cleanup.m: -------------------------------------------------------------------------------- 1 | function warp_dir_name_full = autoalign_workflow_cleanup(workflow_folder, warp_dir_name, workflows_folder) 2 | %%%%% cleanup unnecessary files in workflow folder and rename to have proper name for Warp 3 | 4 | % File names 5 | warp_dir_name_full = fullfile(workflows_folder, warp_dir_name); 6 | align_folder = fullfile(workflow_folder, 'align'); 7 | config_folder = fullfile(workflow_folder, 'configFiles'); 8 | detection_folder = fullfile(workflow_folder, 'detection'); 9 | intermediate_markers_folder = fullfile(workflow_folder, 'markersIntermediate'); 10 | markers_model_file_imod = fullfile(workflow_folder, 'workingMarkers.mod'); 11 | nominal_tilt_angles = fullfile(workflow_folder, 'workingMarkers.tlt'); 12 | 13 | % Try to remove not needed folders 14 | try 15 | rmdir(align_folder, 's'); 16 | rmdir(config_folder, 's'); 17 | rmdir(detection_folder, 's'); 18 | rmdir(intermediate_markers_folder, 's'); 19 | catch 20 | 21 | end 22 | 23 | % model file name in warp directory 24 | new_markers_file = [warp_dir_name, '.mod']; 25 | [filepath, name, ext] = fileparts(new_markers_file); 26 | new_markers_file = [name, ext]; 27 | 28 | % rawtlt file name in warp directory 29 | new_rawtlt_file = [warp_dir_name, '.rawtlt']; 30 | [filepath, name, ext] = fileparts(new_rawtlt_file); 31 | new_rawtlt_file = [name, ext]; 32 | 33 | % move files into right places 34 | movefile(markers_model_file_imod, fullfile(workflow_folder, new_markers_file)); 35 | movefile(nominal_tilt_angles, fullfile(workflow_folder, new_rawtlt_file)); 36 | 37 | % move intermediate dynamo workflow folder to final folder with correct name 38 | movefile(workflow_folder, warp_dir_name_full); 39 | end -------------------------------------------------------------------------------- /autoalign/check_status_cmdout.m: -------------------------------------------------------------------------------- 1 | function check_status_cmdout(status, cmdout) 2 | if status == 0 3 | return 4 | end 5 | orig_state = warning; 6 | warning('on'); 7 | warning(cmdout); 8 | warning(orig_state) 9 | end 10 | 11 | -------------------------------------------------------------------------------- /autoalign/dautoalign4warp.m: -------------------------------------------------------------------------------- 1 | function dautoalign4warp(warp_imod_dir, apix, fiducial_diameter_nm, nominal_rotation_angle, output_folder) 2 | %%%%% Automatic on-the-fly alignment of a set of tilt series from Warp 3 | %%% Parameters 4 | % warp_imod_dir - directory 'imod' created by warp containing tilt series directories 5 | % apix - pixel size in angstroms of tilt series 6 | % fiducial_diameter_nm - fiducial diameter in nanometers 7 | % nominal rotation angle - estimated tilt axis angle (CCW rotation from Y-axis) 8 | % output folder - a folder in which to store the 9 | 10 | %%% List of already processed tilt-series 11 | processed = {}; 12 | 13 | %%% Attempt to 14 | while true 15 | [ts_directory, processed] = next_dir(warp_imod_dir, processed); 16 | 17 | % 18 | if ischar(ts_directory) 19 | autoalign_sleep(processed) 20 | continue 21 | end 22 | 23 | % get paths to stack and rawtlt file 24 | [basename, stack, rawtlt] = ts_info_from_dir(ts_directory); 25 | 26 | % try to align tilt series 27 | if isfile(stack) 28 | try 29 | final_dir_name = autoalign(stack, basename, rawtlt, apix, fiducial_diameter_nm, output_folder); 30 | tiltalign(final_dir_name, nominal_rotation_angle, apix) 31 | catch ME 32 | handle_exception(ME) 33 | end 34 | autoalign_aux_cleanup() 35 | autoalign_summarise(output_folder) 36 | end 37 | end 38 | 39 | end 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /autoalign/dms2mod.m: -------------------------------------------------------------------------------- 1 | function dms2mod(markers_dms_file, model_file, image_file) 2 | %%%%% Convert Dynamo markers (.dms files) into IMOD format model files (.mod) 3 | %%%%% Requires MATLAB >= r2019a 4 | %%%%% Requires Dynamo >= 1.1.478 5 | %%%%% Requires IMOD >= 4.10.37 6 | %%% Reading marker file 7 | m = dread(markers_dms_file); 8 | 9 | %%% Extract useful objects 10 | markers = m.shapes; 11 | n_markers = size(markers, 2); 12 | 13 | tilt_angles = m.nominalTiltAngles; 14 | n_tilt_angles = size(tilt_angles, 1); 15 | 16 | %%% Extraction of coordinates in array resembling IMOD format (contour, x, y, z) 17 | output = []; 18 | for contour_idx = 1:n_markers 19 | current_contour = markers(1, contour_idx); 20 | xy = current_contour.coordinates; 21 | 22 | for z_idx = 1:size(xy, 2) 23 | c_xy = xy{z_idx}; 24 | if size(c_xy, 1) > 0 25 | x = c_xy(1); 26 | y = c_xy(2); 27 | z = z_idx - 1; 28 | output = [output; contour_idx, x, y, z]; 29 | end 30 | end 31 | end 32 | 33 | %%% Write text file containing points in IMOD format 34 | writematrix(real(output), 'tmp.csv', 'Delimiter', 'tab'); 35 | 36 | %%% Run point2model to obtain IMOD format model file 37 | command = ['point2model -ci 5 -w 1 -co 120,120,255 -image ', image_file, ' tmp.csv ', model_file]; 38 | [status, cmdout] = system(command); 39 | check_status_cmdout(status, cmdout); 40 | 41 | %%% Write out tilt angles 42 | tilt_angle_file = strrep(model_file, '.mod', '.tlt'); 43 | writematrix(tilt_angles, tilt_angle_file, 'FileType', 'text'); 44 | end -------------------------------------------------------------------------------- /autoalign/get_directories.m: -------------------------------------------------------------------------------- 1 | function directories = get_directories(path) 2 | files = dir(path); 3 | dir_flags = [files.isdir]; 4 | directories = files(dir_flags); 5 | directories(ismember( {directories.name}, {'.', '..'})) = []; 6 | end 7 | 8 | -------------------------------------------------------------------------------- /autoalign/get_tasolution.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | 4 | if len(sys.argv) == 1: 5 | print('provide filename as argument') 6 | else: 7 | filename = sys.argv[1] 8 | 9 | 10 | def check_line(line, printing): 11 | start_cue = 'At minimum tilt, rotation angle is' 12 | end_cue = '3-D point coordinates (with centroid zero)' 13 | 14 | if start_cue in line: 15 | printing = True 16 | elif end_cue in line: 17 | printing = False 18 | 19 | return printing 20 | 21 | 22 | with open(filename) as f: 23 | lines_to_keep = [] 24 | printing = False 25 | lines = f.readlines() 26 | for line in lines: 27 | printing = check_line(line, printing) 28 | if printing: 29 | lines_to_keep.append(line) 30 | 31 | with open('taSolution.log', 'w') as f: 32 | f.writelines(lines_to_keep) 33 | 34 | print('saved taSolution.log') 35 | 36 | -------------------------------------------------------------------------------- /autoalign/handle_exception.m: -------------------------------------------------------------------------------- 1 | function handle_exception(matlab_exception) 2 | % Handle specific cases with advice 3 | if contains(matlab_exception.message, 'point2model') 4 | autoalign_warn('Make sure IMOD is visible in the path from the MATLAB shell by typing\n !point2model\n') 5 | elseif contains(matlab_exception.message, 'writematrix') 6 | autoalign_warn('writematrix is not available in your version of MATLAB, please update to MATLAB r2019a or later') 7 | end 8 | 9 | % Warn anyway - silent warnings != good 10 | autoalign_warn(matlab_exception.message) 11 | autoalign_warn('Attempting to continue...') 12 | end 13 | 14 | -------------------------------------------------------------------------------- /autoalign/next_dir.m: -------------------------------------------------------------------------------- 1 | function [directory, processed] = next_dir(warp_imod_dir, processed) 2 | % get stack directories 3 | stack_directories = get_directories(warp_imod_dir); 4 | 5 | for idx = 1:size(stack_directories, 1) 6 | directory = stack_directories(idx); 7 | 8 | % return current directory if not in list of processed directories 9 | if ~any(strcmp(directory.name, processed)) 10 | [basename, stack, rawtlt] = ts_info_from_dir(directory); 11 | 12 | % add current basename to list of processed dirs 13 | processed{end + 1} = basename; 14 | return 15 | end 16 | end 17 | 18 | directory = ''; 19 | end 20 | 21 | -------------------------------------------------------------------------------- /autoalign/tiltalign.m: -------------------------------------------------------------------------------- 1 | function tiltalign(warp_folder, rotation_angle, pixel_size_angstrom) 2 | %%%%% Runs tiltalign on the .mod and .tlt files files in a warp tilt series directory 3 | %%% requires tiltalign_wrapper.sh to be on the path 4 | %%% tiltalign wrapper uses get_tasolution.py 5 | 6 | % Go to tilt series directory 7 | working_directory = pwd; 8 | cd(warp_folder); 9 | 10 | % Extract basename of files 11 | [p, n, ext] = fileparts(warp_folder); 12 | basename = [n, ext]; 13 | 14 | % Generate filenames for model, tilt angles and output tlt and xf files 15 | % Calc pixel size in nm 16 | model_file = [basename, '.mod']; 17 | tilt_angle_file = [basename, '.rawtlt']; 18 | pixel_size_nm = pixel_size_angstrom / 10; 19 | output_tilt_angle_file = [basename, '.tlt']; 20 | output_xf_file = [basename, '.xf']; 21 | 22 | % Call tiltalign_wrapper.sh to generate necessary transforms for Warp tomogram reconstruction 23 | command = ['tiltalign_wrapper.sh ', model_file, ' ', tilt_angle_file, ' ', num2str(rotation_angle), ' ', num2str(pixel_size_nm), ' ', output_tilt_angle_file, ' ', output_xf_file]; 24 | [status,cmdout] = system(command); 25 | check_status_cmdout(status, cmdout) 26 | 27 | 28 | % Return to working directory 29 | cd(working_directory); 30 | 31 | end -------------------------------------------------------------------------------- /autoalign/tiltalign_wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | USAGE=""" 3 | Wrapper function for calling tiltalign... 4 | 5 | \n\e[7mtiltalign_wrapper.sh\e[0m <\e[36mmodel_file\e[0m> <\e[36mtilt_angle_file\e[0m> <\e[36mrotation_angle\e[0m> <\e[36munbinned_pixel_size_nm\e[0m> <\e[36moutput_tilt_angle_file\e[0m> <\e[36moutput_transform_file\e[0m> 6 | """ 7 | 8 | 9 | 10 | 11 | if [ -z "$1" ] 12 | then 13 | echo -e $USAGE 14 | exit 0 15 | else 16 | MODEL_FILE=$1 17 | TILT_ANGLE_FILE=$2 18 | ROTATION_ANGLE=$3 19 | UNBINNED_PIXEL_SIZE=$4 20 | OUTPUT_TILT_ANGLE_FILE=$5 21 | OUTPUT_XF_FILE=$6 22 | fi 23 | 24 | 25 | tiltalign -ModelFile $MODEL_FILE \ 26 | -ImagesAreBinned 1 \ 27 | -OutputModelFile 3d_fiducial_model.3dmod \ 28 | -OutputResidualFile residual_model.resid \ 29 | -OutputFidXYZFile fiducials.xyz \ 30 | -OutputTiltFile $OUTPUT_TILT_ANGLE_FILE \ 31 | -OutputXAxisTiltFile xtiltfile.xtilt \ 32 | -OutputTransformFile $OUTPUT_XF_FILE \ 33 | -OutputFilledInModel model_nogaps.fid \ 34 | -RotationAngle $ROTATION_ANGLE \ 35 | -UnbinnedPixelSize $UNBINNED_PIXEL_SIZE \ 36 | -TiltFile $TILT_ANGLE_FILE \ 37 | -AngleOffset 0.0 \ 38 | -RotOption -1 \ 39 | -RotDefaultGrouping 5 \ 40 | -TiltOption 0 \ 41 | -TiltDefaultGrouping 5 \ 42 | -MagReferenceView 1 \ 43 | -MagOption 0 \ 44 | -MagDefaultGrouping 4 \ 45 | -XStretchOption 0 \ 46 | -SkewOption 0 \ 47 | -XStretchDefaultGrouping 7 \ 48 | -SkewDefaultGrouping 11 \ 49 | -BeamTiltOption 0 \ 50 | -XTiltOption 0 \ 51 | -XTiltDefaultGrouping 2000 \ 52 | -ResidualReportCriterion 0.5 \ 53 | -SurfacesToAnalyze 1 \ 54 | -MetroFactor 0.25 \ 55 | -MaximumCycles 1000 \ 56 | -KFactorScaling 1.0 \ 57 | -NoSeparateTiltGroups 1 \ 58 | -AxisZShift 0.0 \ 59 | -ShiftZFromOriginal 1 \ 60 | -TargetPatchSizeXandY 700,700 \ 61 | -MinSizeOrOverlapXandY 0.5,0.5 \ 62 | -MinFidsTotalAndEachSurface 8,3 \ 63 | -FixXYZCoordinates 0 \ 64 | -LocalOutputOptions 1,0,1 \ 65 | -LocalRotOption 3 \ 66 | -LocalRotDefaultGrouping 6 \ 67 | -LocalTiltOption 5 \ 68 | -LocalTiltDefaultGrouping 6 \ 69 | -LocalMagReferenceView 1 \ 70 | -LocalMagOption 3 \ 71 | -LocalMagDefaultGrouping 7 \ 72 | -LocalXStretchOption 0 \ 73 | -LocalXStretchDefaultGrouping 7 \ 74 | -LocalSkewOption 0 \ 75 | -LocalSkewDefaultGrouping 11 \ 76 | -RobustFitting \ 77 | > tiltalign.stdout 78 | 79 | get_tasolution.py tiltalign.stdout 80 | 81 | 82 | -------------------------------------------------------------------------------- /autoalign/ts_info_from_dir.m: -------------------------------------------------------------------------------- 1 | function [basename, stack, rawtlt] = ts_info_from_directory(directory) 2 | basename = directory.name; 3 | ts_folder = fullfile(directory.folder, directory.name); 4 | stack = fullfile(ts_folder, [basename, '.st']); 5 | rawtlt = fullfile(ts_folder, [basename, '.rawtlt']); 6 | end 7 | 8 | -------------------------------------------------------------------------------- /autoalign/warp2catalogue.m: -------------------------------------------------------------------------------- 1 | %%% This makes a Dynamo catalogue which has the 'deconvolved' tomogram as 2 | %%% the visualisation tomogram but particle cropping will be performed on 3 | %%% the warp 3d-ctf corrected tomogram 4 | 5 | function warp2catalogue(warp_reconstruction_dir, reconstruction_apix) 6 | mrc_files = dir(fullfile(warp_reconstruction_dir, '*.mrc')); 7 | vll_name = 'warp2catalogue.vll'; 8 | 9 | f = fopen(vll_name,'wt'); 10 | for k = 1:length(mrc_files) 11 | basename = mrc_files(k).name; 12 | cropping_volume = fullfile(warp_reconstruction_dir, basename); 13 | deconv_name = fullfile(warp_reconstruction_dir, 'deconv', basename); 14 | fprintf(f, '%s\n', deconv_name); 15 | fprintf(f, '* cropFromFile = %s\n', cropping_volume); 16 | fprintf(f, '* cropFromElsewhere = 1\n'); 17 | fprintf(f, '* label = %s\n', basename); 18 | fprintf(f, '* apix = %.3f\n\n', reconstruction_apix); 19 | end 20 | fclose(f) 21 | 22 | dcm -create warp_catalogue -fromvll warp2catalogue.vll 23 | delete warp2catalogue.vll 24 | end 25 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Install autoalign_dynamo for use on the current system 4 | # Make sure this file is executable (chmod +x install.sh) 5 | 6 | # Ask user where to install 7 | echo "Where would you like to install autoalign_dynamo?" 8 | DEFAULT_INSTALL_DIR="/opt/autoalign_dynamo" 9 | echo -ne "Install location (absolute path) (\e[36m${DEFAULT_INSTALL_DIR}\e[0m): " 10 | read install_dir 11 | 12 | # Check installation directory input 13 | # Add working directory if absolute path not given 14 | [ -z "$install_dir" ] && install_dir=$DEFAULT_INSTALL_DIR 15 | [[ ! $install_dir == /* ]] && install_dir=${PWD}/$install_dir 16 | 17 | # File Locations 18 | WORKING_DIR=$PWD 19 | ASSETS_DIR=${WORKING_DIR}/assets 20 | AUTOALIGN_DIR=${WORKING_DIR}/autoalign 21 | ACTIVATION_SCRIPT_EXAMPLE=${ASSETS_DIR}/autoalign_activate_example.m 22 | ACTIVATION_SCRIPT=${AUTOALIGN_DIR}/autoalign_activate.m 23 | 24 | # Prepare installation in autoalign directory 25 | # Put true install location in autoalign_activate script 26 | sed "s|XXX_INSTALL_LOC_XXX|${install_dir}|g" ${ACTIVATION_SCRIPT_EXAMPLE} > ${ACTIVATION_SCRIPT} 27 | 28 | # Add executable permissions to tiltalign_wrapper.sh and get_tasolution.py 29 | tiltalign_wrapper=${AUTOALIGN_DIR}/tiltalign_wrapper.sh 30 | get_tasolution=${AUTOALIGN_DIR}/get_tasolution.py 31 | 32 | for script in $tiltalign_wrapper $get_tasolution; 33 | do 34 | if [ ! -x $script ] 35 | then 36 | chmod +x $script 37 | fi 38 | done 39 | 40 | # Copy prepared autoalign directory to true install location 41 | mkdir -p $install_dir 42 | \cp -rf $AUTOALIGN_DIR/* $install_dir/ && echo -e "Successfully installed autoalign_dynamo in \e[36m${install_dir}\e[0m" 43 | \rm $ACTIVATION_SCRIPT 44 | 45 | 46 | --------------------------------------------------------------------------------