Muscle X

What is Muscle X?

The Muscle X Application Suite is a collection of programs intended to assist with analyzing diffraction X-ray images.

Find out how to get it!

Features

Support

If you are having issues, please let us know. Submit feedback at https://github.com/biocatiit/musclex/issues.

How to Contribute

How to Cite

Click the following badge.

https://zenodo.org/badge/DOI/10.5281/zenodo.1195050.svg

J. Jiratrakanvong, J. Shao, M. Menendez, X. Li, J. Li, Weikang Ma. G. Agam, T. Irving, MuscleX: software suite for diffraction X-ray imaging V1.13.1, doi:10.5281/zenodo.1195050, March 2018.

License

The project is licensed under the IIT License.

Copyright 1999 Illinois Institute of Technology

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ILLINOIS INSTITUTE OF TECHNOLOGY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of Illinois Institute of Technology shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Illinois Institute of Technology.

Installation

We provide three ways to install Muscle X. See the following parts for details.

Instructions

Installation by Installer

For users who do not want to play with Python or Docker environment, we provide the pre-built installer for stand-alone MuscleX program.

Download MuscleX

Windows

Install through Windows Installer on Windows (64-bit).

Run

Find the shortcut of MuscleX on the Desktop or in the Start Menu, click it to run.

Some sample image data are installed to your Documents directory under folder MuscleX. Feel free to use them.

Mac OS X

Download the DMG file built for Mac OS X.

  1. Open the DMG file
  2. Drag the App Bundle MuscleX to the folder Applications
  3. Eject the image

You can always find the app in your Applications and click it to run.

python logo

Installation by Pip

In order to install the program, you need to install python 2.7 or 3.6.

Preparing

There are some modules need to be installed before installing Muscle X. They are Pip, OpenCV, PyQT4 or PyQT5, gfortran, PyFAI and Cython.

Linux
sudo apt-get update
sudo apt-get install python-pip libjpeg-dev libopencv-dev python-opencv python-qt4 cython pyfai gfortran
Mac OS
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install opencv
brew install cartr/qt4/pyqt
brew install gcc
sudo easy_install pip
sudo pip install pyfai
sudo pip install cython
Windows

For windows, we have built the Fortran source for you, so Fortran compiler is not required. But C compiler is still required to build C extensions during the installation process, and Microsoft Visual C++ (MSVC) is recommended.

Python 2.7 on Windows

The default MSVC chosen by Python 2.7 is MSVC 9.0. We recommend forcing the use of MSVC 14.0 instead. Follow the steps below.

  1. Uninstall Microsoft Visual C++ Compiler for Python 2.7 (MSVC 9.0) If Microsoft Visual C++ Compiler for Python 2.7 is installed, uninstall it (See Repair or remove programs in Windows 10).
  2. Install Microsoft Build Tools 2015 Update 3 (MSVC 14.0) The minimal customized installation of Microsoft Build Tools 2015 Update 3 is not enough. Make sure Windows SDK (8.1 or 10) is included.
  3. Temporarily set environment variable VS90COMNTOOLS Type the following command in your current cmd prompt: set VS90COMNTOOLS=%VS140COMNTOOLS%

Then install dependencies:

pip install numpy cython python-qt5 opencv-python pyfai
Python 3.6 on Windows

The default MSVC chosen by Python 3.6 is MSVC 14.0. The minimal customized installation of Microsoft Build Tools 2015 Update 3 is enough. Then install dependencies:

pip install cython numpy pyqt5 opencv-python pyfai

Note

Omit keyword sudo in the commands in following parts when working on Windows.

Installing

Run this command to install Muscle X programs

sudo pip install musclex

Running a program

Simply run

musclex [program shortcut]

For example, run this command to run Diffraction-Centroids

musclex dc

If you get ImportError: C extension: iNaT not built. If you want to import pandas from the source directory, you may need to run ‘python setup.py build_ext –inplace –force’ to build the C extensions first while you’re running the program, please re-install pandas by

pip install -U pandas

Updating

sudo pip install -U musclex

if you do not need to update other dependencies, you can run

sudo pip install -U --no-deps musclex

docker logo

Installation on Docker

In order to install the program, you need to install Docker first.

Installing Docker

To install Docker follow the docker website instructions and post-install instructions.

For Ubuntu:

sudo apt-get update
sudo apt-get install curl
sudo curl -sSL https://get.docker.com/ | sh

For Windows: you might need to do more steps as described here

Create docker group and add a user

You need to add a user to docker group in order to give docker run permission to the user

sudo groupadd docker                
sudo usermod -aG docker [username] # replace [username] with your user name

Installing and updating Muscle X program suite

You need to have the muscle.sh script available in order to update, and run a Muscle X program on docker. You can download muscle.sh by

curl https://raw.githubusercontent.com/biocatiit/musclex/master/musclex.sh -o musclex.sh

Make it executable by

chmod +x musclex.sh

Run this command to install or update Muscle X programs on Docker

./musclex.sh update

Running a Muscle X program

Running the program by running musclex.sh following by a program shortcut

./musclex.sh [program shortcut]

For example, run this command to run Bio-Muscle

./musclex.sh bm

Application Suite

Equator

Introduction

The purpose of the Equator program is to analyze the equatorial portion of muscle X-ray diffraction patterns.

The Equator program is designed to:

  • Determine the inter filament lattice spacing, d10
  • Fit Voigt or Gaussian model functions to the diffraction peaks in order to estimate their integrated intensities
  • Determine I11/I10 intensity ratios
  • Obtain estimates for σd and σs from the peak widths

screenshot

The program does this with as little user intervention as possible in order to improve reproducibility , reduce operator bias and increase efficiency. It can operate on a whole directory of images and produce results in hours instead of many weeks required for manual processing. Not all patterns are amenable to this approach, however. Any failed cases are flagged for manual processing, either within the Equator program or using other manual approaches. Typically the program succeeds with ~90% of patterns showing diffraction.

The Equatorial Diffraction Pattern from Striated Muscle

A good introduction to X-ray diffraction of vertebrate muscle can be found in Chapter 2 of Squire, JM, The Structural Basis of Muscular Contraction, Plenum 1981. A treatment of X-ray diffraction from insect flight muscle can be found in Irving (2006) X-ray Diffraction of Indirect Flight Muscle from Drosophila (in Nature’s Versatile Engine: Insect Flight Muscle Inside and Out, J Vigoreaux editor Landes Biosciences, Georgetown, TX).

Figure 1

The equatorial pattern arises from the projected density of mass in the A-band of the sarcomere. The thick filaments are packed into a hexagonal lattice with thin filaments interdigitated between them either in the trigonal positions (vertebrate muscle - Figure 1A) or half way between adjacent thin filaments (many insect flight muscles - Figure 1B). The density of the filaments projected onto a plane therefore represents a two dimensional crystal with the hexagonal lattice points occupied by thick filaments. One can draw imaginary planes through the crystallographic unit cell (see Figure 1A for vertebrate muscle) corresponding to various values of the so-called Miller indices h & k. In figure 1A are drawn the lattice planes corresponding to the h=1, k=0 (separated by d10) and h=1, k=1 separated by d11). These lattice planes give rise to the two strongest pairs of X-ray reflections in the X-ray diffraction pattern, the 1,0 and 1,1 reflections respectively with intensities I1,0 and I1,1. In insect muscle, the two strongest pairs of reflections are the 1,0 and 2,0 reflections because of its different lattice geometry (Figure 1B).

Figure 2

Figure 2 shows the geometry of a muscle diffraction experiment. The muscle sample is separated from the detector by a distance L. The spacing between thick filaments is ~ 40 nm, large compared to the wavelength of X-rays (~0.1nm). Bragg’s Law, n λ = 2dsinθ, describes the relationship between the lattice spacing d and the scattering angle 2θ. If d is large, θ will be small. L therefore is typically 2-3 m so that the distance S10, the distance from the center of the pattern to the 1,0 reflection, is of the order of a few mm. The scattering angle, 2θ, can be calculated from tan -1 (S10/L). At small angles however, tan2θ ≅ sin2θ ≅ 2θ. Substitution into Bragg’s law and solving for d10 gives a simplified expression: d10= nλL/S

It should be clear from this analysis that the lattice spacing is inversely proportional to S10. In skinned cardiac muscle the 1,1 and 1,0 equatorial reflections are often the only reflections visible. In skeletal muscle additional diffraction peaks past the 1,1 are frequently visible corresponding to other, higher order diffraction planes in the crystallographic unit cell denoted by larger values of h and k. In vertebrate muscle the first 5 such equatorial reflections are the 1,0; 1,1; 2,0; 2,1 and 3,0. In insect flight muscle, one can observe as many as 20 equatorial reflections. In addition, in skeletal muscle there is a peak located between the 1,0 and 1,1 reflections coming from the insertion of the thin filaments into the Z-band and is called the Z-band reflection. The position of this reflection from the center of the pattern is about 1.46 x S10 (Yu et al., 1977 J. Mol. Biol. 115:455-464). In general, the positions of the A-band reflections, excluding the Z-band reflection, obey a hexagonal lattice selection rule where S(h,k) = sqrt( h2+k2+hk)S10. Thus, d10 may be calculated from any equatorial reflection and applying the hexagonal selection rule. The d10 lattice spacing can be converted to inter-thick filament spacing by multiplying d10 by 2/√3).

The intensities of the 1,0 and 1,1 equatorial reflections may be determined from one-dimensional projections along the equator. When cross bridges bind to the thin filaments in vertebrate muscle there are radial and azimuthal movements of the crossbridges so there is a loss of mass on the 1,0 planes (containing only thick filaments) and a gain of mass on the 1,1 planes (Huxley, H. E. 1968. J. Mol. Biol. 37:507-520. and Haselgrove, J. C., and H. E. Huxley. 1973. J. Mol. Biol. 77:549-568). As a consequence, the intensities of the 1,0 reflections decreases and the 1,1 increases. I11/I10 intensity ratios, therefore, can be used to estimate shifts of mass from the region of the thick filament to region of the thin filament. Graded levels of isometric force

There is additional information in the equatorial patterns in the form of the widths of the diffraction peaks. It has been shown, Yu et al., 1985 Biophys J 47 :311-321, that the width of the Gaussian or Voigtian functions used to approximate the shape a given peak σh,k may be expressed (Yu et al., 1985 Biophys J 47 :311-321, Irving & Millman 1989) J Muscle Res Cell Motil. 10:385-94) as √(σc2d2Shk2s2Shk2), where Shk=√(h2+k2+hk)*S10 as above. σc is the known width of the X-ray beam, σd is related to amount of heterogeneity in inter-filament spacing among the myofibrils, and σs is related to the amount of paracrystalline (liquid-like) disorder of the myofilaments in the hexagonal lattice. Liquid-like disorder is sometimes called disorder of the second kind (Vainshtein, B. K. 1966. Diffraction of X-rays by Chain Molecules.Elsevier, Amsterdam.). σd can be expressed relative to Δd10/d10 as a measure of the width of the distribution of lattice spacings between the different myofibrils in the sample. σs can be expressed in terms of ΔX/d10 where ΔX is the standard deviation in the distribution of distances between nearest-neighbor unit cells in a given myofibril. σs increases substantially during contraction in skeletal muscle (Yu et al., 1985 op. cit.). Because of the dependency of the peak width on the square of the scattering angle, liquid like disorder rapidly causes the peaks to become indistinguishable from the background at higher scattering angles. The muscle lattice can also exhibit disorder of the first kind (Vainstein, 1966 op. cit.) which is the tendency of objects to vibrate isotropically around the lattice positions due to thermal energy resulting in a linear decrease in diffracted intensities with increasing scattering angle. This is often called “temperature factor type disorder” in crystallography. There is no direct way to estimate the degree of this kind of disorder without invoking a model structure.

How it works

When an image is selected, if there is an image in the same folder named “calibration.tif”, the calibration settings window will pop up (How to set calibration settings will be explained in the next section). If there’s no calibration image or it’s set already, the image will be processed automatically with the default parameters. However, if the image has ever been processed with the same version of the program, the cache will be downloaded, so the image won’t be processed again.

Image processing and fitting model

The program will process an image by going through multiple processes in the order

4. Calculate Box Width

The image will be rotated by the rotation angle determined above, and the area inside R-min removed as in this image. The image will be cropped by using R-min x 1.5.

-

Then, the program will find the horizontal histogram from this image, calculate the background assuming a convex hull function to the histogram, and the integrated area will be selected as between the start and end point of the histogram. From the image above, the horizontal histogram was

-

5. Get Intensity Histogram

When integrated area is calculated, the program will produce a histogram from the rotated image inside the integrated area. (If the blank image and mask is set, the original image will be subtracted by the blank image before rotation)

-

6. Apply Convex hull to intensity histogram

The original histogram will be split into left and right sides. Then, the convex hull to each half pattern will be calculated in order to remove the background by using R-min as a starting point.

-

7. Find Diffraction Peaks

The program will find peaks from left and right histograms which have had the convex hull background subtracted. This process will find all locations of the peaks. If the image is noisy, it is possible that the program will find too many peaks. ( In the image below, the program found only 2 peaks because the image was not noisy, so it worked very well )

-

8. Managing Diffraction Peaks

This process prepares and corrects the background-subtracted, intensity histogram before fitting a model. It is possible that the program found peaks from noise, misplaced peaks, or both false positive peaks and false negative peaks. Therefore, these peaks need to be re-positioned in case this process fails. The algorithm will try to find first symmetric peaks, and find S10 which is the distance from center to the first peak on the equator. After that, all peak locations will be calculated by using S10 and theta(h,k). The number of peaks on each side to be fit needs to be specified by the user (default and minimum is 2)

9. Fit Model

The program will fit the model to the histogram by using the specified model (currently Gaussian and Voigtian models are supported), initial S10,and the area of the reflection peaks. Finally, we will obtain the new parameters we want from the fitting results. This will include the area of each peak, S10, sigma D, sigma S, gamma, and I11/I10. However, if you see only 4 reflection from the pattern (Only I11 and I10 on each side), it will be overdetermined if you use Voigt as a fitting model. To solve this problem, sigma S or gamma should be fixed.

If there are some parameters that need to be configured manually to obtain good fits, the program will run these processes again, but it will not start from the beginning. Instead, it will start from the process after the manual one. For example, if the Box Width is set manually, the program will run processes from Get Intensity Histogram to Fit Model because the center, rotation angle and r-min do not need to be recalculated.

How to use

Once the program run, you will see an input file dialog, so you can select the file you want to process. If you want to process multiple files in a folder, please select a file in that folder, and click “Process Current Folder”.

When the processing window opened, there are 3 tabs on the top,

Image

In this tab, you will see the selected image, Display Options section, and Image Processing section, Reject check box, next button previous button, and Process This Folder button.

imagetab

Display Options

In Display Options section, you are able to select what you want to see in the image. All check boxes are all about displaying information in the image. In image above,

  • Center : blue dot
  • Integrated Area (Box Width) : green lines
  • R-min : red dotted circle
  • Histogram : white plot as original histogram and red line as fitting model
  • Peaks : yellow lines

display_options

You can also set min and max intensity for displayed image in this section. To zoom the image, you can click “Zoom In” button and select the zoom in area in the image, or using mouse wheeling in the image directly. This options in this section will not affect the image processing.

Image Processing

display_options

In Image Processing section, you will see multiple buttons allow you to calibrate the image and set some properties manually.

Calibration Settings

After “Calibration Settings” is pressed, there’s a window popped up. This window will allow you to select the calibration image by clicking on Browse or setting parameters manually. See Calibration Settings for more details

Set Rotation and Center

Before setting manual rotation and center, it’s better to zoom the image to the area of the diffraction because it will be easier to set these parameters correctly. To set the rotation and center, you need to click 2 positions of the image. The first one will be a reflection peak on one side of the equator, and the second one will be the corresponding (opposite) reflection peak on the other side of the equator. To cancel, press ESC.
-

Set Rotation Angle

This assumes that the center of diffraction is correct. After the button is clicked, the program will allow users to select an angle by moving a line. Clicking on image when the line is on the equator of the diffraction will set manual rotation angle. To cancel, press ESC. (Make sure that “Fixed Angle” is not checked)
-

Set Manual R-min

After the button clicked, you will see the red circle when you move the cursor around. To set manual R-min, please click on image when the circle size is the size of R-min you want. To cancel, press ESC.
-

Set Box Width (Integrated Area)

To set the integrated area, you need to click 2 positions of the image. The first one will be the start line, and the second one will be the end line. To cancel, press ESC.
-

Blank image and Mask

This option is available on version 1.6 or upper. Click Here to see more details

Fixed Angle

This feature will allow users to fixed rotation angle for every image which has not been processed. After the checkbox is checked, the manual rotation angle which is set by buttons will be ignored.

Fixed Box Width (Integrated Area)

This feature works in the same way as fixed angle, but the fixed value will be start and end position (pixel) of the box

Fitting

In this tab, you will see the graph produced from the intensity histogram in the integrated area, and fitting information. -

General Settings

In the section, you are able set necessary parameters for fitting process including skeletal muscle checkbox, number of peaks on each side, and fitting model. The model functions for the peaks currently supported are Voigtian and Gaussian. If the Number of Peaks selected are more than the number of peaks, the program still tries to fit the model with the selected Number of Peaks.

-

In cases where the program misplaces the peak locations, you can do peak selection manually by clicking on “Start Manual Peak Selection”. After the button clicked, you can select the how many peak locations you want by clicking on the graph. However, it’s sufficient to just select S10 of left and right side. Click “Done” when you are done. To cancel, press ESC.

-

Display Options

In this section, you will be able to select what you want to see in the graph. All check boxes are all about displaying information in the graph. In the image above,

  • Original Histogram : black line
  • After Convex hull : green line
  • Peaks : red lines
  • Fitting Graph (Best fit function graph) : blue line
  • Z line : yellow line
  • Center X : magenta line

-

You can also zoom-in to see more detail by the same mechanism as in Image tab. All options in this section will not affect the fitting results.

Settings

In this section, once a setting is changed, the fit will be recalculated. You can manually configure and lock all parameters of fitting model including Sigma C, Sigma S, Sigma D, gamma and skeletal parameters. These parameters are independent on each side, so you have to choose the side by choosing left or right tab before setting these parameters. Press “Re-fitting” when you want to re-fitting will the new settings.

-

Diffraction data taken on integrating detectors such as CCD detectors will have read noise. This can result in a constant offset to the background subtracted diffraction peaks from zero. This can lead to systematic error(“BAckgeos in your peak measurement. In this case it is possible to add a user selected constant offset (“Background K”) that is added to the fitting function prior to fitting the data. In practice this number is selected as the number that provides the best “eyeball” fit to the residual background. Since this residual background often has some residual structure that is hard to model, the constant is not adjusted by the fitting proces.s

Results

Important fitting results are shown in this tab. If the calibration parameters are set, the program will also show d10.

-

Blank Image and Mask

There 2 settings you can set here, blank image and mask

Blank Image

Once the window launches, you will see “Select Blank Image(s)” at the bottom. Then, you can select a blank image or multiple images. The program will average them all if you select multiple images. If the image is from Pilatus detector. The program will initial mask threshold, and paint the mask as orange color. You can change it in order to make correct mask.

- -

Additional Mask

The mask threshold can create mask from the threshold value. If you have additional area which you want to ignore, you can click “Draw Additional Mask”. This button will available only when the blank image is selected. After the button is clicked, there will be a new window pops up. This dialog is a toolkit from PyMca

-

Before drawing additional mask, you can zoom in by disable the arrow by just pressing it

-

You can also change color type or intensity range by pressing the palette icon, and flip the image vertically by pressing Mona Lisa icon. To draw the mask, there’re several options.

-

  1. Drawing by rectangle selection -
  2. Drawing by brush -
  3. Drawing by polygon selection -

To clear the mask, press - To erase some mask, press - and erase them from the image

Save

- After every thing is set, and OK is pressed, the blank image and mask will be saved to settings folder which is created under original selected image directory (not the blank image). When this settings is launched again, these images will be downloaded.

Summary

Once the image is processed, the results of the analysis will be saved to a file called “summary.csv”. This summary file will be in the “eq_results” folder that is created as a sub-directory of the folder containing the selected file. Therefore, one folder will have one summary file.

-

Quadrant Folding

Introduction

The equator and the meridian of a fiber diffraction pattern divides a pattern into four quadrants. Because of Friedel’s Law each of the 4 quadrants will contain the same information. If you add the four quadrants together you effectively have 4 times the signal improving the signal to noise by factor of 2 (square root of 4). You can regenerate a full diffraction pattern by simply rotating the summed quadrant.

It usually better to analyze this “quadrant folded” image than the original image because of the improved signal to noise will make the data easier to fit as well as allow better estimates of the backgrounds. Quadrant Folding is a program for generating such a quadrant-folded image. Other advantages of quadrant folding is that it can compensate for detector imperfections by substituting data from the unaffected quadrants for the affected area. This is particularly useful for data collected using Pilatus detectors which have substantial gaps between the detector elements.

The program also can estimate and remove the diffuse background scattering from an image using a number of different algorithms, alone or in combination. It includes all the background subtraction routines from the CCP13 suite (https://github.com/scattering-central/CCP13) plus one based on a two dimensional convex hull and another on white top hat filtering. It is possible to merge different background estimates to apply one algorithm at low scattering angles and a different one at high scattering angles.

Once set up, the program can process an entire directory of images without user intervention

-

More Details

How it works

When an image is selected, the program will immediately process the image automatically. The resulting image will be saved as [image_name].result.tif in the qf_results folder that is created as a subdirectory of the folder containing the selected file. The program will process an image by going through a series of processes in the order described below

Processes
3. Calculate Average Quadrant

To find the average fold, the image will be split into 4 quadrants, and each quadrant is flipped to be in the same orientation as below.

-

After all quadrants are flipped, a new image will be generated by averaging each pixel from all quadrants. The mask threshold will be used to determine if that pixel will be included in averaging process. In this case, the mask threshold is 0. That means if the pixel intensity is less than 0, the program will ignore that pixel. Finally, the result image will look like the image on the right. The full 2D pattern can then be regenerated by rotations of this image.

-

4. Calculate R-min and R-max

For the background subtraction algorithms to work, it is necessary to define a minimum radius R-min and a maximum radius R-max to define the region that is assumed to contain real data. To find R-max, the radial histogram will first be re-computed from the average folded image. R-max (blue line) is initially chosen to be simply 60% of the diagonal of the image. These two values are intended as just approximate starting points, that users can change manually.

-

5. Apply Background Subtraction

Fiber diffraction patterns from muscle have a substantial diffuse background arising from non-crystalline parts of the muscle that do not diffract coherently including membranes and mitochondria as well as diffuse scattering from the myosin heads. Intact cardiac muscle, in particular has a very strong background. This background pattern has a complex structure making it hard to model and effectively remove. Various algorithms exist that attempt to remove the background. No one technique so far can effectively remove background in all parts of the image without over subtraction in some parts of the pattern but some techniques work better than others depending on the muscle and specific preparation. Quadrant folding implements several different algorithms that can be used individually or in combination that can be used to background subtracted images for display or subsequent analysis.

Generally speaking, the “White Top-Hat” algorithm works well at large radii from the center and some other algorithm will work better than others, depending on the type of muscle generating the X-ray pattern, at low radii. Two images will be produced from this process. The first image will be created using one of several background subtraction approaches, and the second image will be created using the White-top-hat approach. These 2 images will be merged as described below. At present, there are 4 options for background subtraction in the first (low radius) image, Circularly symmetric, 2D Convex hull, and White-top-hat.