SBC-Utrecht / pytom-match-pick

GPU-accelerated template matching for cryo-ET
https://sbc-utrecht.github.io/pytom-match-pick/
GNU General Public License v2.0
28 stars 9 forks source link

add gold and carbon film removal through LoG filter and ridge detection algorithm #2

Closed McHaillet closed 8 months ago

McHaillet commented 1 year ago

Some example code using scipy.ndimage.gaussian_laplace and skimage.filters.meijering. The scikit-image filters library contains 3 more ridge detection algorithms .

from pytom_tm.io import read_mrc, write_mrc
import scipy.ndimage as ndimage
import skimage.filters
import numpy as np

voxel_size = 13.76
fiducial_size = 100

sigma_fiducial = (fiducial_size / voxel_size) / (2 * np.sqrt(3))

tomo = read_mrc('tomogram_14A.mrc')
tomo = (tomo - tomo.mean()) / tomo.std()

filter_fiducial = ndimage.gaussian_laplace(tomo, sigma_fiducial)
filter_carbon = skimage.filters.meijering(tomo, sigmas=[3], black_ridges=True)

write_mrc('ridge_carbon.mrc', filter_carbon, voxel_size)
write_mrc('log_fiducial.mrc', filter_fiducial, voxel_size)

carbon = (filter_carbon > 0.06) * 1
fiducial = (filter_fiducial > 0.3) * 1

mask = ndimage.binary_dilation((carbon + fiducial > 0) * 1, iterations=3)
write_mrc('tomogram_14A_mask.mrc', mask.astype(np.float32), voxel_size)

scores = read_mrc('matching/tomogram_14A_scores_bak.mrc')
scores[mask == 1] = -1

write_mrc('matching/tomogram_14A_scores.mrc', scores, voxel_size)
McHaillet commented 1 year ago

Ridge detectors from skimage can be set to detect black or white ridges (via the black_ridges boolean keyword). I guess cryo-et artifacts are usually recognized by black and white ridges directly next to each other, both carbon edges and gold markers have this as they both scatter very strongly.

McHaillet commented 8 months ago

This is not going to happen. For gold bead removal its best to use other software (e.g. IMOD) and do it direclty on the micrograph level.