Hello,
Thank you for this useful library! I have used platipy for calculating the AHA-17 segments in cardiac CT data. I noticed that for some patients, the function generate_left_ventricle_segments fails, giving the following error:
File ~/Desktop/segmentointi/test_env/lib/python3.13/site-packages/platipy/imaging/utils/ventricle.py:397, in generate_left_ventricle_segments(contours, label_left_ventricle, label_left_atrium, label_right_ventricle, label_heart, myocardium_thickness_mm, hole_fill_mm, optimiser_tol_degrees, optimiser_max_iter, min_area_mm2, verbose)
395 for n in range(inf_limit_lv, apical_extent):
396 lv_com_apical_list.append(get_com(working_contours[label_left_ventricle][:, :, n]))
--> 397 rv_com_apical_list.append(get_com(working_contours[label_right_ventricle][:, :, n]))
399 lv_com_apical = np.mean(lv_com_apical_list, axis=0)
400 rv_com_apical = np.mean(rv_com_apical_list, axis=0)
File ~/Desktop/segmentointi/test_env/lib/python3.13/site-packages/platipy/imaging/label/utils.py:86, in get_com(label, as_int, real_coords)
84 if as_int:
85 print(com)
---> 86 com = [int(i) for i in com]
88 return com
ValueError: cannot convert float NaN to integer
To me, it seems that the get_com function tries to calculate the center of mass slice by slice for the left and right ventricle, but fails since some of the slices in the right ventricle contain only zeros (that's why the center of mass is NaN).
Do you think this error could be resolved by allowing the center of mass to be zero for some slices, or would it break some essential functionality? Does the function assume that left and right ventricle have equal length (from inf_limit_lv to apical_extent)? I suppose this is rarely the case in reality.
Thank you for your help!
Best,
Hanna
Hello,
Thank you for this useful library! I have used platipy for calculating the AHA-17 segments in cardiac CT data. I noticed that for some patients, the function generate_left_ventricle_segments fails, giving the following error:
To me, it seems that the get_com function tries to calculate the center of mass slice by slice for the left and right ventricle, but fails since some of the slices in the right ventricle contain only zeros (that's why the center of mass is NaN).
Do you think this error could be resolved by allowing the center of mass to be zero for some slices, or would it break some essential functionality? Does the function assume that left and right ventricle have equal length (from inf_limit_lv to apical_extent)? I suppose this is rarely the case in reality.
Thank you for your help!
Best,
Hanna