Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with float pixel spacing #317

Closed
smichi23 opened this issue Oct 21, 2022 · 1 comment · Fixed by #318
Closed

Issues with float pixel spacing #317

smichi23 opened this issue Oct 21, 2022 · 1 comment · Fixed by #318

Comments

@smichi23
Copy link
Contributor

Hi all!

In my work, I had to create RTDOSE files to store Monte Carlo data. When creating my DICOMs, I had pixel spacings of 0.3710000000000002325/0.37109999999931. When I tried to calculate the DVHs with dicompyler-core, I got this error:

File "/dvh_from_dosegrid/venv/lib/python3.8/site-packages/dicompylercore/dvhcalc.py", line 88, in get_dvh
calcdvh = _calculate_dvh(s, rtdose, limit, calculate_full_volume,
File "/dvh_from_dosegrid/venv/lib/python3.8/site-packages/dicompylercore/dvhcalc.py", line 218, in _calculate_dvh
planedata[z] = calculate_plane_histogram(plane, doseplane,
File "/dvh_from_dosegrid/venv/lib/python3.8/site-packages/dicompylercore/dvhcalc.py", line 283, in calculate_plane_histogram
hist, vol = calculate_contour_dvh(grid, doseplane, maxdose, dd, id,
File "/dvh_from_dosegrid/venv/lib/python3.8/site-packages/dicompylercore/dvhcalc.py", line 316, in calculate_contour_dvh
mask = ma.array(doseplane * dd['dosegridscaling'] * 100, mask=~mask)
File "/dvh_from_dosegrid/venv/lib/python3.8/site-packages/numpy/ma/core.py", line 6610, in array
return MaskedArray(data, mask=mask, dtype=dtype, copy=copy,
File "/dvh_from_dosegrid/venv/lib/python3.8/site-packages/numpy/ma/core.py", line 2906, in new
raise MaskError(msg % (nd, nm))
numpy.ma.core.MaskError: Mask and data not compatible: data size is 452188, mask size is 451242.

This error came from an int conversion of 477.9999999 to 477 in the intrapolated shapes. To solve that issue I simply rounded the lut new shapes.

Here is what I changed in file dvhcalc.py line 502 and 503:

col_samples = num_cols * min_pixel_spacing[1] / new_pixel_spacing[1]
row_samples = num_rows * min_pixel_spacing[0] / new_pixel_spacing[0]

to

col_samples = round(num_cols * min_pixel_spacing[1] / new_pixel_spacing[1])
row_samples = round(num_rows * min_pixel_spacing[0] / new_pixel_spacing[0])

Best,

Sam

@bastula
Copy link
Member

bastula commented Oct 21, 2022

Thanks Sam! Let me take a look and see if this needs to also be addressed anywhere else in the code and if it would affect normal usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants