I maintain useful code that I like to use on github, please feel free to use or make improvements, but please cite my original authorship. Thank you.


Most of the code below are scripts that have been written in various languages to solve specific analysis problems. Code available upon request where not available to download. If you use in your work, redistribute any code and/or modify anything, please make sure the contribution of Kyle Morris is acknowledged appropriately.

Relion - make_grouped_star_bash

Code for shell script available here (make_grouped_star_bash).

When working with micrographs with few particles you may need to group particles with similar defocus together for Relion to work well, as described here. Sjors Scheres (LMB, Cambridge) describes a procedure here for re-grouping your particles to achieve this using the Relion-1.3 distribution and also a csh script, available here.

For functionality on my system I have rewritten this for bash shells. Follow the same grouping procedure outlined here but use the bash script I have written, available here (make_grouped_star_bash). 

CTFFIND4 control bash shell script

Code for shell script available here (ctffind4_script_v1).

If run from a directory of micrographs it will look for all the .mrc files in that directory and run CTFFIND4 for defocus determination on each micrograph. The box size needs to be given at command line but other parameters adjusted in the script itself. This will be changed in a later revision to be more friendly with an input parameter file that the script reads in. Outputs are organised in a directory structure so you can run with different box sizes without fear of overwriting previous results. 

Results formatted to fit the conventions for downstream processing by SAM scripts (Prof. Maofu Liao, Harvard).

CTFFIND4 was written by Alexis Rohou in the Grigorieff Lab. Available here.

Frealign - Bash shell script to plot SCORE or CHANGE data from a single or series or *.par files to monitor convergence

Code available here (frealign_convergence_script_v3).

Frealign - Bash shell script to plot FSC curves from a single or series or *.par files

Code available here (frealign_FSC_script_v2).

Relion - Bash shell script to plot class occupancy over classification iterations

Code available here (

TEM Immunogold Particle Size Characterisation

Code available on request.

This matlab script runs a GUI that can read .dm3 or .tiff files from Gatan electron microscope cameras. Using circle detection algorithms it is able to find immunogold particles in labelled thin tissue sections. Although not tested it should be able to detect other types of circular particle which have a contrast difference over the background. The identified particle sizes and distribution is calculated; this data can be exported to a tab-delimited file. A number of other functionalities are implemented. (MATLAB GUI)

Gatan File Name Reformat

Code available here (TEM_rename_v4).

A useful bash shell script that takes the last four characters of a folder of files and in batch moves them to the start of the file. I find this is the only useful way to reformat Gatan .dm3 micrographs such that they appear in order in a Finder window. Save the code as a text file, without an extension and make it executable in the terminal with 'chmod 755' command.

Note: Path to files shouldn't contain any special characters or spaces

ImageJ Fibril Morphology Picker

Code available here (Morphology_picker_v3.2.txt).

A java style ImageJ script for rapidly selecting fibril morphologies from TEM micrographs, rotating, cropping and bandpass filtering. The latter sometimes helps visualisation of structural features. The script is semi automated.

Tobacco Mosaic Virus (a kind gift from Ian Hands-Portman, University of Warwick). Close inspection reveals the lattice spacing along the viral long axis.

X-ray Fibre Diffraction Time Course Analysis

Code available on request.

A few integrated packages that can process time course data from fXRD. It can output graphically the equatorial and meridional signals as a functions of time. (MATLAB GUI)

X-ray Fibre Diffraction Azimuthal Analysis

Code available on request.

A small program to radially integrate fXRD pattern signals over user defined limits, output to text is available for plotting. (MATLAB GUI)

Shell scripts and useful bash commands

Show_Hide_Files - a script to toggle visibility of OS X Finder hidden files (.filename)

# Open .profile alias
alias profile='touch ~/.profile; open -e ~/.profile'