ciampluca / counting_perineuronal_nets

Apache License 2.0
9 stars 1 forks source link

yellow file as output #9

Open Noy987 opened 3 months ago

Noy987 commented 3 months ago

Hey, I've been using the code for counting PNNs on a few images and it as worked nicely. Recently, the output picture files are all yellow. Also, the patches are first mentioned as 234 and later and in the excel file are 54. I would very much appreciate your help in understanding why. Thanks so much!

The code in the terminal: PS C:\Users\Desktop\counting_perineuronal_nets-0.5> python predict.py pnn_v2_fasterrcnn_640/ -r pnn_v2_scoring_rank_learning/ -t 0.0 C:\Users\Desktop\Project\new\C1-e3_enr_2_wfa_pv_merged_downsized.tif [ DATA] PatchedMultiImageDataset: 1 image(s), 234 patches [ MODEL] detection - FasterRCNN(in_channels=1, out_channels=1, backbone=resnet50, backbone_pretrained=False, model_pretrained=True, max_dets_per_image=200, nms=0.3, det_thresh=0.05, cache_folder=./model_zoo) [DEVICE] cpu [ CKPT] pnn_v2_fasterrcnn_640\best.pth [PARAMS] thr = 0.00 [OUTPUT] localizations.csv
[ DATA] RandomAccessMultiImageDataset: 1 image(s), 54 patches
[ MODEL] ConvNet(in_channels=1, num_classes=1) [DEVICE] cpu [ CKPT] pnn_v2_scoring_rank_learning\best.pth io.imsave(out_path, drawn) Saving: high_predictions_C1-e3_enr_2_wfa_pv_merged_downsized.png draw_predictions.py:87: UserWarning: high_predictions_C1-e3_enr_2_wfa_pv_merged_downsized.png is a low contrast image io.imsave(out_path, drawn) Saving: loc_C1-e3_enr_2_wfa_pv_merged_downsized.png draw_predictions.py:93: UserWarning: loc_C1-e3_enr_2_wfa_pv_merged_downsized.png is a low contrast image io.imsave(out_path, drawn)

image

fabiocarrara commented 3 months ago

Can you also provide the content of the output file localizations.csv?

Noy987 commented 3 months ago

<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">

X | Y | class | score | imgName | thr | rescore -- | -- | -- | -- | -- | -- | -- 3195.046 | 639.9374 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.039958 7039.94 | 1600 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.042483 3199.981 | 2240 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.083928 7650.468 | 2559.973 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.03685 609.5144 | 2559.994 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.023485 3839.976 | 2880 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.050107 1919.947 | 3520 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.492849 4479.941 | 3520 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.039336 2559.966 | 4160 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.067137 5119.974 | 4160 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.050234 5759.974 | 4160 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.030111 3839.994 | 4800 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.071894 1889.232 | 5119.945 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.104583 3862.85 | 5119.957 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.15545 7649.845 | 5119.968 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.030831 7039.971 | 5200.402 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.031196 7039.979 | 5245.449 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.035805 7039.96 | 5264.851 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.028216 5119.963 | 5440 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.048684 5759.967 | 5440 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.032413 6399.983 | 5440 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.052409 2559.963 | 6080 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.048215 3199.956 | 6080 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.075119 4479.971 | 6434.289 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.045559 3839.952 | 6720 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.041288 4479.936 | 6720 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.053373 5119.944 | 6720 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.041288 6399.941 | 6720 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.047817 4479.964 | 7360 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.034603 5119.937 | 7360 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.03962 5759.944 | 7360 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.122521 1275.156 | 7679.935 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.048502 5067.972 | 7679.983 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.062388 3199.993 | 8000 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.039917 5759.965 | 8000 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.059435 5759.995 | 8000 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.059435 5759.944 | 8937.26 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.041341 646.5934 | 8959.938 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.026069 646.214 | 9599.978 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.029056 1884.402 | 10239.95 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.024003 1244.426 | 10239.95 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.023626 6.656007 | 10239.95 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.034613 5726.914 | 10239.96 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.032791 7644.343 | 10239.97 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.025334 1287.775 | 10239.98 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.027145 2567.708 | 10239.99 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.021677 2566.832 | 10879.94 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.028561 5766.557 | 10879.94 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.023681 3846.687 | 10879.96 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.027956 7646.819 | 10879.98 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.020486 7047.76 | 10879.98 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.022071 7004.387 | 10879.99 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.031689 1927.663 | 10879.99 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.038003 3806.838 | 10879.99 | 0 | 0.448782 | C1-e3_enr_2_wfa_pv_merged_downsized.tif | 0 | 0.03004

fabiocarrara commented 3 months ago

The number of patches in the two phases are correct. In the first stage, the image is divided into 234 squared patches and 54 PNNs are found in total. In the second stage, 54 image patches around the found PNNs are considered and restored.

It's a bit strange that the score given at the first stage are all equal to 0.448782. Moreover, also the second stage scores (rescore column) are quite low, maybe also below the second stage threshold. It might be that for this image and the default threshold, no PNNs are counted.

Can you share also the input image and the all yellow output image?

Noy987 commented 3 months ago

Yes. Thank you for your check. What is the range of values that can be given to the threshold?

Here i tried half a brain scan, but the same happens for a whole brain scan. In the output image you can see some marks of the patches. image image

fabiocarrara commented 3 months ago

I am assuming you are using the draw_prediction.py script to produce these images. In that script, the thersholds are fixed in the code, e.g.: https://github.com/ciampluca/counting_perineuronal_nets/blob/9ea18287b612b8ba6da7cbe614a5f34be5a33292/draw_predictions.py#L71-L75

Low-scored predictions should appear only in the all_predictions_... and low_predictions_... PNG files.

The yellow images may come from bad intensity scaling of the input image. Can you check the values of the image variable before and after this line? https://github.com/ciampluca/counting_perineuronal_nets/blob/9ea18287b612b8ba6da7cbe614a5f34be5a33292/draw_predictions.py#L60

Noy987 commented 2 months ago

Is there a difference between the types of image files in the code? And which values of the image should i check? how do i do that? Thanks!