예제 #1
0
def _analyze_matrix(matrix, min_dist_between_max_peaks, calibration):
    intensities = np.asarray(_mean_columns(matrix), dtype=np.int16)
    (max_peaks_positions,
     min_peaks_positions) = calculate_peaks(intensities,
                                            min_dist_between_max_peaks)
    max_peaks_intensities = _intensities_in_positions(intensities,
                                                      max_peaks_positions)
    min_peaks_intensities = _intensities_in_positions(intensities,
                                                      min_peaks_positions)

    return ({
        "intensities":
        intensities,
        "max_peaks_positions":
        max_peaks_positions,
        "max_peaks_intensities":
        max_peaks_intensities,
        "min_peaks_positions":
        min_peaks_positions,
        "min_peaks_intensities":
        min_peaks_intensities,
        "amplitudes":
        calculate_amplitudes(max_peaks_intensities, min_peaks_intensities),
        "times_to_peaks":
        calculate_time_to_peaks(max_peaks_positions, min_peaks_positions,
                                calibration),
        "times_to_half_peaks":
        calculate_times_to_half_peaks(intensities, max_peaks_positions,
                                      min_peaks_positions, calibration),
        "tau_s":
        calculate_taus(intensities, max_peaks_positions, min_peaks_positions,
                       calibration)
    })
예제 #2
0
 def test_raise_error_if_the_only_founded_peak_is_in_the_last_position_of_the_vector(
         self):
     vector = [0, 0, 0, 0, 0, 0, 2]
     min_dist_between_max_peaks = 2
     self.assertRaises(
         ValueError,
         lambda: calculate_peaks(vector, min_dist_between_max_peaks))
예제 #3
0
    def test_raise_error_when_no_max_peak_found_due_to_possible_peaks_bellow_threshold(
            self):
        # The threshold is calculated as 1.0 / max(vector)
        # We use the threshold to avoid false positives

        vector = [0, 1, 0, 0, 0, 1, 0, 0]
        min_dist_between_max_peaks = 2
        self.assertRaises(
            ValueError,
            lambda: calculate_peaks(vector, min_dist_between_max_peaks))
예제 #4
0
    def test_with_one_peaks_there_are_two_minimum_peaks(self):
        vector = [-1, 2, 3, 10, 9, 11, 6, 1, 3]
        min_dist_between_max_peaks = 2
        (max_peaks, min_peaks) = calculate_peaks(vector,
                                                 min_dist_between_max_peaks)

        self.assertEqual(len(max_peaks), 1)
        self.assertEqual(max_peaks[0], 5)
        self.assertEqual(len(min_peaks), 2)
        self.assertEqual(min_peaks[0], 0)
        self.assertEqual(min_peaks[1], 7)
예제 #5
0
    def test_finds_max_and_minumum_peaks(self):
        vector = [-1, 2, 3, 10, 9, 8, 7, 15, 3]
        min_dist_between_max_peaks = 2
        (max_peaks, min_peaks) = calculate_peaks(vector,
                                                 min_dist_between_max_peaks)

        self.assertEqual(len(max_peaks), 2)
        self.assertEqual(max_peaks[0], 3)
        self.assertEqual(max_peaks[1], 7)
        self.assertEqual(len(min_peaks), 3)
        self.assertEqual(min_peaks[0], 0)
        self.assertEqual(min_peaks[1], 6)
        self.assertEqual(min_peaks[2], 8)
예제 #6
0
 def test_raise_error_when_no_max_peak_found(self):
     vector = [0, 0, 0, 0]
     min_dist_between_max_peaks = 2
     self.assertRaises(
         ValueError,
         lambda: calculate_peaks(vector, min_dist_between_max_peaks))