Skip to content

Commit

Permalink
Minor changes to align.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewHerzing committed Mar 20, 2024
1 parent aaa9416 commit 8f8a15b
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions tomotools/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import tqdm
from pystackreg import StackReg
import logging
# from numpy.fft import fft, fftshift, ifftshift, ifft
from skimage.registration import phase_cross_correlation as pcc
from skimage.transform import hough_line, hough_line_peaks
from skimage.feature import canny
Expand All @@ -41,16 +40,16 @@ def get_best_slices(stack, nslices):
Returns
----------
slice_locations : NumPy array
locs : NumPy array
Location along the x-axis of the best slices
"""
total_mass = stack.data.sum((0, 1))
mass_std = stack.data.sum(1).std(0)
mass_std[mass_std == 0] = 1e-5
mass_ratio = total_mass / mass_std
slice_locations = mass_ratio.argsort()[::-1][0:nslices]
return slice_locations
best_slice_locations = mass_ratio.argsort()[::-1][0:nslices]
return best_slice_locations


def get_coms(stack, slices):
Expand Down Expand Up @@ -131,11 +130,11 @@ def pad_line(line, paddedsize):
"""
npix = len(line)
start_idx = (paddedsize - npix) // 2
end_idx = start_idx + npix
padded = np.zeros(paddedsize)
padded[start_idx:end_idx] = line
return padded
start_index = (paddedsize - npix) // 2
end_index = start_index + npix
padded_line = np.zeros(paddedsize)
padded_line[start_index:end_index] = line
return padded_line


def calc_shifts_cl(stack, cl_ref_index, cl_resolution, cl_div_factor):
Expand Down

0 comments on commit 8f8a15b

Please sign in to comment.