Пример #1
0
                                       correlation_threshold=avg_threshold, aligning_option='dft',
                                       method=avg_method, debugging=debug)
    avg_counter = avg_counter + flag_avg

avg_obj = avg_obj / avg_counter
print('\nAverage performed over ', avg_counter, 'reconstructions\n')
del obj, ref_obj
gc.collect()

################
# unwrap phase #
################
phase, extent_phase = pu.unwrap(avg_obj, support_threshold=threshold_unwrap_refraction, debugging=debug)

print('Extent of the phase over an extended support (ceil(phase range))~ ', int(extent_phase), '(rad)')
phase = pru.wrap(phase, start_angle=-extent_phase/2, range_angle=extent_phase)
if debug:
    gu.multislices_plot(phase, width_z=2*zrange, width_y=2*yrange, width_x=2*xrange,
                        plot_colorbar=True, title='Phase after unwrap + wrap')

#############################################
# phase ramp removal before phase filtering #
#############################################
amp, phase, rampz, rampy, rampx = pu.remove_ramp(amp=abs(avg_obj), phase=phase, initial_shape=original_size,
                                                 method='gradient', amplitude_threshold=isosurface_strain,
                                                 gradient_threshold=threshold_gradient)
del avg_obj
gc.collect()

if debug:
    gu.multislices_plot(phase, width_z=2*zrange, width_y=2*yrange, width_x=2*xrange,
Пример #2
0
        indexing='ij')
    phase = z + y + x

if debug and not flat_phase:
    gu.multislices_plot(phase,
                        sum_frames=False,
                        plot_colorbar=True,
                        width_z=200,
                        width_y=200,
                        width_x=200,
                        vmin=-phase_range,
                        vmax=phase_range,
                        cmap=my_cmap,
                        title='Phase before wrapping\n')

phase = pru.wrap(phase, start_angle=-np.pi, range_angle=2 * np.pi)

support[abs(amp) < support_threshold * abs(amp).max()] = 0
del amp

volume = support.sum() * voxel_size**3  # in nm3
print('estimated volume', volume, ' nm3')

phase[support == 0] = 0

if ref_axis_outplane == "x":
    _, _, strain = np.gradient(
        planar_dist / (2 * np.pi) * phase,
        voxel_size)  # q is along x after rotating the crystal
elif ref_axis_outplane == "y":
    _, strain, _ = np.gradient(
Пример #3
0
                phase, (numz // 2 - zcom, numy // 2 - ycom, numx // 2 - xcom),
                axis=(0, 1, 2))

        support = np.zeros(amp.shape)
        support[amp > isosurface * amp.max()] = 1
        zcom, ycom, xcom = center_of_mass(support)
        zcom, ycom, xcom = [
            int(np.rint(zcom)),
            int(np.rint(ycom)),
            int(np.rint(xcom))
        ]  # used for the reference phase
        phase, extent_phase = pu.unwrap(amp * np.exp(1j * phase),
                                        support_threshold=0.05,
                                        debugging=debug)
        phase = pru.wrap(phase,
                         start_angle=-extent_phase / 2,
                         range_angle=extent_phase)
        phase = phase - phase[zcom, ycom, xcom]
        phase, extent_phase = pu.unwrap(amp * np.exp(1j * phase),
                                        support_threshold=0.05,
                                        debugging=debug)
        phase = pru.wrap(
            phase, start_angle=-extent_phase / 2,
            range_angle=extent_phase)  # rewrap after modifying phase
        ref_amp = np.copy(amp)
    else:  # align it with the reference object
        # TODO: interpolate object if the shape is different from ref_amp (different voxel sizes between datasets)
        shiftz, shifty, shiftx = reg.getimageregistration(ref_amp,
                                                          amp,
                                                          precision=1000)
        print('Shift of array', index, 'with the reference array:', shiftz,