MultiValue kV causes skin map server error
Study with multiple kV values per exposure causes server error when detail view opened due to skin map calculations.
Refs #584
Internal Server Error: /openrem/rf/261383/skin_map/ Traceback (most recent call last): File "/home/user/veOpenREM/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/user/veOpenREM/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 22, in _wrapped_view return view_func(request, *args, **kwargs) File "/home/user/bbOpenREM/openrem/remapp/views.py", line 858, in rf_detail_view_skin_map make_skin_map(pk) File "/home/user/veOpenREM/local/lib/python2.7/site-packages/celery/local.py", line 188, in __call__ return self._get_current_object()(*a, **kw) File "/home/user/veOpenREM/local/lib/python2.7/site-packages/celery/app/task.py", line 420, in __call__ return self.run(*args, **kwargs) File "/home/user/bbOpenREM/openrem/remapp/tools/make_skin_map.py", line 171, in make_skin_map kvp = float(irrad.irradeventxraysourcedata_set.get().kvp_set.get().kvp) File "/home/user/veOpenREM/local/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/user/veOpenREM/local/lib/python2.7/site-packages/django/db/models/query.py", line 338, in get (self.model._meta.object_name, num) MultipleObjectsReturned: get() returned more than one Kvp -- it returned 22!
Comments (16)
-
-
reporter Thanks David.
-
Calculate the median kVp per exposure. Fixes error that otherwise occurs if a single exposure contains multiple kVp values stored for it. However, is calculating the median the best thing to do? References issue
#602→ <<cset 43270ace05b5>>
-
I've just realised that calculating the median is a bad idea because only users with PostgreSQL have access to the median function.
I could use the mean or max aggregate function instead.
I think the mean is the way to go.
@edmcdonagh, what do you think?
-
Calculate the median kVp per exposure using the numpy median function. Will work for any OpenREM install. Fixes error that otherwise occurs if a single exposure contains multiple kVp values stored for it. However, is calculating the median the best thing to do? References issue
#602→ <<cset 7df793cc1ef0>>
-
Updating skin dose map docs to say how we deal with an irradiation event that has multiple kVp values. References issue
#602and#540→ <<cset 2bb34a054be6>>
-
reporter I think it probably is. This RDSR is the only I have ever seen with per pulse data, and generally of the two that I have been sent the value is mostly the same, except one of the series has a 0 value at the start. If you used mean then that wouldn't be representative. The only other thing you could do is exclude any zeros before taking a mean, but I think median is probably the way to go. We just need to put it in the docs somewhere.
-
@edmcdonagh, your comment must have crossed paths with my commit just now. I'm now using numpy's median function, which I think is the best way forward. I've also updated the docs to reflect this.
-
- changed status to resolved
-
reporter Thanks David. Will you create a PR?
-
Updating changes files. References issue
#602→ <<cset 4648f128d9c3>>
-
Added a check for
np.isnan(kvp)
, and if true setkvp
toNone
. I think this addresses the comment that Ed made in the pull request. References issue#602→ <<cset 83379155dcf4>>
-
reporter Merged in issue602multiplekVpError (pull request #162)
Approved-by: Ed McDonagh ed@mcdonagh.org.uk
→ <<cset bba534d5588a>>
-
Now calculating the mean kVp, excluding any None or zero values, for events with multiple kVp values. References issue
#602→ <<cset 03af6df6c564>>
-
reporter Merged in issue602multiplekVpErrorMean (pull request #164)
Now calculating the mean kVp, excluding any None or zero values, for events with multiple kVp values. References issue
#602Approved-by: Ed McDonagh ed@mcdonagh.org.uk
→ <<cset 86994c6983d4>>
-
reporter - changed component to openSkin integration
- Log in to comment
@edmcdonagh, can you send me an RDSR of a study that has this problem, then I'll take a look at it?