polyTEM.crystal_peaks.flow_fields.determine_peaks¶
- polyTEM.crystal_peaks.flow_fields.determine_peaks(intensity_matrix, cutoff, peak_width)¶
Returns a matrix of peak positions derived from a matrix of diffraction data. A peak is present if it is brighter than the cutoff and brighter than all neighboring angles within the peak width. It is very important to tune the inputs of this function to your dataset and make sure they make sense. You may choose to set the cutoff automatically using some percentile value, or choose it manually. Make sure the number of peaks per grid square agrees qualitatively with your data.
If you prefer a different method of finding peaks, you may choose to replace this function. Make sure the output is in the same format.
- Inputs:
intensity_matrix: 3d matrix where the three dimensions are (real space x position, real space y position, angle) cutoff: minimum brightness to define a peak, in the same units as the pi matrix peak_width: twice the minimum distance between two peaks, in degrees
- Outputs:
peak_matrix: 3d matrix with the same shape as intensity_matrix, with a 1 where there is a peak and 0 everywhere else
The function also prints the total number of peaks and the average peaks per grid square. Make sure that these values agree qualitatively with your diffraction data. Don’t use multiple peaks per grid square unless you think your data justifies it.