Sikerdebaard / dcmrtstruct2nii

DICOM RT-Struct to mask
MIT License
93 stars 26 forks source link

[KeyError] 'name' #2

Closed xfuren closed 5 years ago

xfuren commented 5 years ago

dcmrtstruct2nii/adapters/convert/rtstructcontour2mask.py, line 29, in convert:

logging.info(f'Skipping contour {contour["name"]}, unsupported type: {contour["type"]}')

It should be noted that contour is actually sequence, so it only has keys 'type' and 'points'. This line will always raise exception of [KeyError] 'name'.

Sikerdebaard commented 5 years ago

This should not be the case as this specific function uses an intermediate format generated by rtstructinputadapter.py.

Did you run into this exception? If so, rtstructinputadapter.py was probably unable to extract the name of the structure from the rtstruct file, meaning you have an unnamed structure in your rtstruct file.

xfuren commented 5 years ago

BTW, your code should be able to support Contour Geometric Type 'INTERPOLATED_PLANAR' as well. Right?

ref:

https://github.com/jmil/osirix/blob/master/osirix/DCMPix.m

xfuren commented 5 years ago

I ran into this exception. I print contour before the logging line and get... {'type': 'INTERPOLATED_PLANAR', 'points': {'x': ["36.984168", "36.936199", "36.886294", "36.743338", "36.596805", "36.361678", "36.121863", "35.799131", "35.471258", "35.067066", "34.657944", "34.179809", "33.697509", "33.154101", "32.607652", "32.008574", "31.407699", "30.763285", "30.118196", "29.439331", "28.760467", "28.058529", "27.356491", "26.643167", "25.929480", "25.215794", "24.502108", "23.799047", "23.097008", "22.415478", "21.736613", "21.087382", "20.442968", "19.831837", "19.228002", "18.671251", "18.123513", "17.631319", "17.149360", "16.731198", "16.323760", "15.988126", "15.662794", "15.416878", "15.179852", "15.029194", "14.885082", "14.833251", "14.784894", "14.833251", "14.885082", "15.029195", "15.179853", "15.416879", "15.662795", "15.988127", "16.323761", "16.731199", "17.149361", "17.631320", "18.123514", "18.671253", "19.228004", "19.831839", "20.442970", "21.087384", "21.736615", "22.415480", "23.097010", "23.799048", "24.502109", "25.215795", "25.929482", "26.643168", "27.356492", "28.058530", "28.760468", "29.439332", "30.118197", "30.763286", "31.407700", "32.008574", "32.607653", "33.154102", "33.697510", "34.179810", "34.657945", "35.067066", "35.471259", "35.799131", "36.121863", "36.361678", "36.596805", "36.743338", "36.886293", "36.936199"], 'y': ["-125.740652", "-126.454185", "-127.167449", "-127.868150", "-128.567840", "-129.243201", "-129.916513", "-130.554647", "-131.189651", "-131.779550", "-132.365458", "-132.897179", "-133.424506", "-133.889318", "-134.349948", "-134.740409", "-135.127588", "-135.437599", "-135.745889", "-135.970706", "-136.195523", "-136.332162", "-136.468403", "-136.516946", "-136.562584", "-136.522528", "-136.476890", "-136.348842", "-136.212602", "-135.998282", "-135.773465", "-135.475724", "-135.165714", "-134.785574", "-134.392102", "-133.936085", "-133.467676", "-132.942622", "-132.406769", "-131.820953", "-131.226454", "-130.589602", "-129.946473", "-129.269698", "-128.589038", "-127.884678", "-127.178467", "-126.459800", "-125.740651", "-125.021501", "-124.302834", "-123.596623", "-122.892263", "-122.211603", "-121.534828", "-120.891700", "-120.254847", "-119.660348", "-119.074532", "-118.538679", "-118.013625", "-117.545216", "-117.089200", "-116.695728", "-116.315588", "-116.005578", "-115.707838", "-115.483021", "-115.268701", "-115.132460", "-115.004413", "-114.958775", "-114.918719", "-114.964357", "-115.012900", "-115.149141", "-115.285781", "-115.510597", "-115.735414", "-116.043704", "-116.353715", "-116.740894", "-117.131356", "-117.591986", "-118.056797", "-118.584124", "-119.115846", "-119.701754", "-120.291652", "-120.926656", "-121.564791", "-122.238103", "-122.913463", "-123.613153", "-124.313854", "-125.027118"], 'z': ["-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000", "-29.250000"]}}

Sikerdebaard commented 5 years ago

Unfortunately I have no experience with contour type INTERPOLATED_PLANAR.

I've created a feature branch that adds this contour to rtstructcontour2mask.py. Maybe you can try it out and let me know if it produces the correct results?

You can find the feature branch here: d635c97cd96418983377c53a347cc33f42a5006a

xfuren commented 5 years ago

This branch worked and generated the expected result for me.