pylidc icon indicating copy to clipboard operation
pylidc copied to clipboard

centroid to physical coordinates

Open longchingkwok331 opened this issue 1 year ago • 1 comments

Hi, I am doing lung nodule predictions on the LIDC-IDRI-0069 sample, and I got the center and the size of the nodule detection to be "center": [-59.54512023925781, 84.96267700195313, 1369.8218994140625], "orientation": [-1.0, -0.0, -0.0, -0.0, -1.0, -0.0, 0.0, 0.0, 1.0], "size": [9.868255615234377, 10.00336456298828, 19.705078125],

I am pretty sure that this lung nodule location corresponds to the first annotation, which is the one available if I run

pid = 'LIDC-IDRI-0069' annotations = pl.query(pl.Annotation).filter(pl.Scan.patient_id == pid).first() print("centre>>", annotations.centroid) => [169.19642857, 360.81122449, 46.20153061] If I convert back to the real-world coordinate: The following is the metadata Spacing: [0.741, 0.741, 2.0] (in millimeters) Origin (RAS): [184.3750, 188.2812, 1288.5] 169 * 0.741-184 = -58, 360 * 0.741-188=78, 46 * 2 + 1288.5 = 1380.5

This actually very much matches the coordinates provided by my prediction, however, I am adding the origin z value while I am minusing the origin x, y value in order to reproduce the value I predicted This is not consistent, may I know is this formula correct?

I try to check on the second and third lungs nodules in the sample to cross check but I didn't find a way to get the second and third lung nodule annotations. I use this method from poe to get the second lung nodule but It doesn't seem right

pid = 'LIDC-IDRI-0069' scan = pl.query(pl.Scan).filter(pl.Scan.patient_id == pid).first() Query annotations for that specific scan annotations = pl.query(pl.Annotation).filter(pl.Annotation.scan_id == scan.id).all() second_annotation = annotations[1]

longchingkwok331 avatar Apr 06 '24 20:04 longchingkwok331

Also may I know why pid = 'LIDC-IDRI-0069' ann = pl.query(pl.Annotation).filter(pl.Scan.patient_id == pid).first() print(ann) => Annotation(id=1,scan_id=1) while scan = pl.query(pl.Scan).filter(pl.Scan.patient_id == pid).first() print("cluster_annotations>>", scan.cluster_annotations(return_distance_matrix=True)) cluster_annotations>> ([[Annotation(id=16,scan_id=2), Annotation(id=18,scan_id=2), Annotation(id=20,scan_id=2), Annotation(id=22,scan_id=2)], [Annotation(id=15,scan_id=2)], [Annotation(id=14,scan_id=2), Annotation(id=17,scan_id=2), Annotation(id=19,scan_id=2), Annotation(id=21,scan_id=2)]] The Annotation(id=1,scan_id=1) is not inside the cluster_annotations

To my understanding, each sample contains a number of lung nodules and each lung nodule contain a number of annotations. in the 0069 sample, there are 3 lung nodules and the first contain 4 annotations, the second contain 1 annotations, and the third contains 4 annotations. But why the The Annotation(id=1,scan_id=1) is not inside the cluster_annotations ?

The centroid method is only for accessing each annotation's centroid,

I wish to find a way to locate all the lung nodules' centroids given a pid, is there a way to do that

Thank you very much

longchingkwok331 avatar Apr 06 '24 20:04 longchingkwok331