haesleinhuepf / BioImageAnalysisNotebooks

Python Jupyter notebooks for BioImageAnalysis, GPU-accelerated image processing, bio-image data science and more
https://haesleinhuepf.github.io/BioImageAnalysisNotebooks
BSD 3-Clause "New" or "Revised" License
114 stars 31 forks source link

Questions on page /29_algorithm_validation/validate-spot-counting.html #27

Open ClementCaporal opened 1 year ago

ClementCaporal commented 1 year ago

Hello,

Thank you for your work. I have two questions concerning the 29_algorithm_validation/validate-spot-counting

Maximum or sum projection ?

def compute_true_positives(distance_matrix, thresh): 
    dist_mat = cle.push(distance_matrix)
    count_matrix = dist_mat < thresh

    ...

    detected = np.asarray(cle.maximum_y_projection(count_matrix))[0, 1:]
    # [0, 1:] is necessary to get rid of the first column which corresponds to background

    ...

    # ambiguous matches occur when one annotation corresponds to multiple detected spots 
    ambiguous_matches = len(detected[detected>1])

    ...

I think maximum_y_projection -> sum_y_projection otherwise we cannot detect ambiguous matches. (everything will be 0 or 1 using the maximum projection)

Who should be in the column position : detected or annotation ?

Considering that annotation is 16 points. Considering that detected_spots is 31 points.

When distance_matrix is defined:

distance_matrix = cle.generate_distance_matrix(detected_spots, annotations.T)

It will put the detection as columns of the matrix (it's shape will be (16, 31))

But for the F1 score quantification:

print(f'We are detecting {distance_matrix.shape[0]} cells when there are {distance_matrix.shape[1]}')

The detections are in row, not in columns. Also in def compute_true_positives(distance_matrix, thresh): the y_projection suggest also that annotation should be in the columns.

If distance_matrix.T is used from the definition maybe the legend of this figure will need to change image

haesleinhuepf commented 1 year ago

Let me just get @Shannon-E-Taylor in the loop for this question :-)