Matlab code and example files for manuscript Click-ExM enables expansion microscopy for all biomolecules, by De-en Sun, et al.
Uploaded and last edited by Yujie Shi (yujieshi@scripps.edu) Oct-06-2020.
The script Process_click_EXM.m in this repo is created for expansion microscopy data processing. This includes rigid registration, calculation of expansion factor,
B-spline non-rigid registration, calculation of distortion field and RMS error. For detailed explanation of the code, see the annotations inside the script.
All dependencies (registerImages.m, nr_registerImages.m, RMSE_cal.m, and RMSE_MS.m) are included in this repo. The code was written and used under Matlab R2018a on Windows 10 system.
The pre-expansion images were first stretched by a scaling factor Festi of 3.8~4.8 with bicubic interpolation to approximately
match the scale of the post-expansion images.
This estimated expansion factor was decided based on the macroscopic measurement of gel size.
The stretched pre-expansion image was used as the ‘fixed image’ for rigid registration, and the post-expansion images as the ‘moving image’.
Rigid registration was performed using the monomodal intensity-based registration with imregtform function.
Affine transformation was used in the function to correct the shear deformation of the gel.
The X- and Y- scaling elements (xcorr and ycorr) in the transformation matrix calculated by the imregtform function were used to correct the rough
scaling factor (Festi).
The final corrected expansion factor (Fcorr) was therefore calculated as
Fcorr = Festi×√(xcorr×ycorr)
The registered pre- and post-expansion images were then subjected to B-spline non-rigid registration.
To exclude regions with no features, masks of the rigid registered pre- and post-expansion images were generated by Gaussian blur to suppress the background.
The displacement field and B-spline registered images were then acquired with the imregdemons function,
and the distortion vector field was visualized with the quiver function.
RMSE was quantified by calculating the difference of distance between each pair of matching features before and after B-spline registration,
and plotted as a function of the distance between the matching features. The calculated RMSE-to-measurement length curve was smoothed for better visualization.
- Download all files into a same folder.
- Run scirpt
Process_click_ExM.min Matlab. This will process the included example filespre_Click_ExM_tubulin.tifandpost_Click_ExM_tubulin.tifincluded in this folder. - The rigid registration and non-rigid registration will finish automatically.
- Select a small region to calculate RMS error when prompted (Use your mouse to draw a square on the figure, double click the selected region when finished).
- Wait for RMSE calculation (may take a long time if a large region is selected). A "Process finished" message box will show up when all calculations are finished.
- All results will be written into a newly created folder called
processed_data
(i) compare pre and post (registered).svgshows the rigid-registered post-ExM image and the original pre-ExM image;(ii) rigid registration and exp fac.svgmerges the rigid-registered post-ExM image with the pre-ExM image; the estimated and corrected expansion factors are shown in the title;(iii) non-rigid registration and distortion field.svgshows the post-ExM image before and after non-rigid registration and the distortion field;(iv) Cropped area for RMSE analysis (Distortion field).svgshows the cropped area for RMSE analysis selected manually by the user;(v) RMSE plot.svgshows the RMSE plot, with mean value ± standard deviation.
The .xlsx files saves RMSE related values, which can be used to make RMSE plot using other softwares
RMSE mean.xlsxis the calculated mean RMSE valueRMSE mean+std.xlsxis the calculated mean RMSE value + standard deviationRMSE mean-std.xlsxis the calculated mean RMSE value - standard deviationRMSE measurement_length.xlsxis the measurement lengths correlated to the mean RMSE values