Compare doses between x-ray systems on the charts

Issue #332 resolved
David Platten created an issue

I would find it useful to be able to compare doses from x-ray systems on the charts. For example, a chart showing CT head requests for CT scanner A vs. CT scanner B.

Comments (185)

  1. David Platten reporter

    Altered some of the CT plot data to produce data split by system as well as requested procedure name. Unfinished, but a start. References issue #332.

    → <<cset 8c65d4ed385b>>

  2. David Platten reporter

    I'm going to get the CT plot of DLP per requested procedure working as a test case.

    Users will sometimes want to view a global mean or median, rather than values split by system. Need to make this possible.

    Chart code is likely to need updating to cope with the more complex data being sent to it.

  3. David Platten reporter

    Need to ensure that there is one list of requested procedure names that is used for each scanner, even if some scanners have no requests under some of the names.

  4. David Platten reporter

    Order of data sorted out (no pun intended). At the moment the plot only works if all scanners have some data for every requested procedure type being displayed. Drilldown and sorting do not work at the moment. References issue #332

    → <<cset b340988ee33d>>

  5. David Platten reporter

    For each requested procedure, forced all scanners to use the same histogram bins: enables histograms to be plotted together for comparison. References issue #332

    → <<cset 10ee0bf16434>>

  6. David Platten reporter

    Ensured that there is an entry for every requested procedure for each scanner, even if some scanners have zero requests for some procedures. References issue #332

    → <<cset 84e3a7b8dcbf>>

  7. David Platten reporter

    There was a problem with the drilldown which was preventing all the histograms from being displayed. Fixed this now. I think that the fix may help increase the speed of other charts. References issue #332

    → <<cset 80fd92e2904a>>

  8. David Platten reporter

    The histograms were in a different order to the median values, so there was a mis-match between the main series and the drilldown. It turns out that this is because the python sorting routines sort in a different way to that of the Django database queries. I've fixed it by ordering the requestSummary data to match the database-provided list of names. References issue #332

    → <<cset dfc8a740cc6a>>

  9. David Platten reporter

    Added user option to plot a series per system, or to group all systems into one series. Also fixed an error in the colour calculations that was causing a divide by zero when there was only one series. References issue #332 and issue #342.

    → <<cset ec745250d1f6>>

  10. Ed McDonagh

    On the currently installed demo of this, if I click on CT Head I get a histogram that I'm assuming has all the different scanners plotted.

    If I click on CT Abdomen or CT Chest, I only get one scanner plotted. Is this what you get? Maybe its something that has been fixed here, but I don't remember a commit message referencing this...

    Looks lovely by the way!

  11. David Platten reporter

    You're probably looking at a plot that is showing mean and median data for each system. There will be two series for each system on the initial plot, one for mean and the other for median. When you drilldown you only see half the number of series, because the histogram data for the mean and median points is the same. So, clicking on CT head (showing eight series) will take you to four histograms; clicking on either of the others (two series) will take you to a single histogram.

  12. David Platten reporter

    Plots per system

    Done:

    • Added universal option to plot per system or group all systems into one series

    • DLP per CT requested procedure name can now be per system or one series

    • DLP per CT study description can now be per system or one series

    • Added display of requested procedure on radiographic tabulated data

    • DAP per radiographic requested procedure name can now be per system or one series

    • Added requested procedure name as a form filter on radiographic page

    • Added new charts of DAP per radiographic study description and DAP per requested procedure name

    • Added new charts of radiographic study description frequency and requested procedure name frequency

    • DAP per radiographic study description can now be per system or one series

    • DAP per radiographic acquisition protocol can now be per system or one series

    • kVp per radiographic acquisition protocol can now be per system or one series

    • mAs per radiographic acquisition protocol can now be per system or one series

    • DLP per CT acquisition protocol can now be per system or one series

    • CTDI per CT acquisition protocol can now be per system or one series

    Notes:

    There is little agreement in acquisition protocol names and study descriptions between the systems that I look after. For me, these plots won't really allow a comparison between systems in an easy side-by-side way. The plots of requested procedure name should work well, as all systems are populated with the same range of names.

  13. David Platten reporter

    Added code to CT request charts to ensure that links from individual system histogram points take the user to only that system data. References issue #332

    → <<cset ba5631884512>>

  14. David Platten reporter

    Updated radiographic charts to use new colour scheme. Also fixed a couple of errors: put back in some code that should not have been removed. References issue #332 and issue #342

    → <<cset 04b29547f7dc>>

  15. David Platten reporter

    Modified logic for mean and median data calculation for requested radiographic data. Should help to speed things up when plotting per system. Need to implement this for the CT requests too. Investigate whether simplifying the field used for num_req or num_acq or num_stu speeds things up too. References issue #332

    → <<cset acede37050c3>>

  16. David Platten reporter

    Improved chart calculation code to avoid unnecessary blocks that won't be needed. Also simplified the field that is used to count how many requests, acquisition, studies have been carried out. References issue #332

    → <<cset 88cfd2d871d6>>

  17. David Platten reporter

    I've been looking at histograms of DAP for several rooms together, plotted on one chart. There is quite a discrepancy between the number of examinations for some of the rooms, making it difficult to compare the shape of the histograms. I thought it would be useful to be able to normalise each histogram, setting it's maximum value to 1.0. This then makes comparison of the shape easier. The code below does this, and can be attached to a button below each relevant chart. Does anyone think this is a useful feature?

    It's a bit rough-and-ready at the moment: if the user clicks on the button when viewing the histogram plots then nothing happens; once they return to the main plot and then drill down again the histogram plots will be updated with the normalised values.

    var histogramNormalised = false;
    
    function normaliseHistograms(chartContainer) {
        var chart, histogram_data, i, j, series_max;
        if (histogramNormalised == false) {
            chart = $(chartContainer).highcharts();
            histogram_data = [];
            for (i = 0; i < chart.options.drilldown.series.length; i++) {
                histogram_data.push({
                    id: chart.options.drilldown.series[i].id,
                    name: chart.options.drilldown.series[i].name,
                    useHTML: true,
                    data: []
                });
                series_max = Math.max.apply(Math, chart.options.drilldown.series[i]["data"].map(function(v) {return v[1];}));
                for (j = 0; j < chart.options.drilldown.series[i]["data"].length; j++) {
                    histogram_data[i]["data"].push([
                        chart.options.drilldown.series[i]["data"][j][0],
                        chart.options.drilldown.series[i]["data"][j][1] /= series_max
                    ]);
                }
            }
            chart.options.drilldown.series = histogram_data;
            histogramNormalised = true;
        }
    }
    

    A button can be created in dxfiltered.html that will run the code:

    <a onclick="normaliseHistograms('#plotDXRequestMeanDAPContainer')" class="btn btn-default btn-sm" role="button">Normalise histograms</a>
    
  18. David Platten reporter

    Added the ability to normalise the histogram data. This makes it easier to compare dose distributions from different systems when the number of entries varies greatly between them. References issue #332

    → <<cset 9d386cce06e7>>

  19. David Platten reporter

    @edmcdonagh, I've put this latest code on the djp demo site. Have a look at the "DLP per requested procedure type" chart. It's now possible to normalise the histograms.

    It only works for the CT data on that site, as the radiograph data doesn't have any values in "Requested procedure".

  20. David Platten reporter

    Updated JavaScript histogram normalisation code so that the histogram plots are updated live, rather than the user having to return to the main series and then drilldown again. Much, much better now. References issue #332

    → <<cset 45c68227a619>>

  21. David Platten reporter

    That is my next job. I may be able to hide it, and then change it's visibility using the chart's drilldown event.

  22. David Platten reporter

    Enabled radiographic plot of DAP per study description to be displayed with a series per x-ray system. Just the mean plot so far. References issue #332

    → <<cset 53d4b625553c>>

  23. David Platten reporter

    Enabled radiographic plot of DAP per study description for median and combined plot of mean and median to be displayed with a series per x-ray system. References issue #332

    → <<cset 5ff6cfee2038>>

  24. David Platten reporter

    Ensured that CTDI and DLP histograms only calculated if required. Moved returnStructure element assigment out of a for loop in two places. References issue #332. Also references issue #217.

    → <<cset cb9bde6604de>>

  25. David Platten reporter

    Made calculation of DLP and CTDI histogram data more efficient if they are both required. Also fixed error when assigning median CTDI data to the chart. References issue #332. Also references #217.

    → <<cset 83a9a0b38082>>

  26. David Platten reporter

    CTDI and DLP per acquisition can now be plotted with a series per CT scanner. Removed the plots that showed DLP and CTDI on the same plot. Also simplified some template code. References issue #332

    → <<cset e4ca2174eee9>>

  27. David Platten reporter

    CT acquisition pie chart works. Other CT pie charts currently showing too many items if viewed without the associated DLP chart.

  28. David Platten reporter

    @edmcdonagh, I think that this issue is sorted out now. I'm not going to close it yet so that I can spend a little more time to check. It would be useful if you'd take a look at the djp demo site at some point to see if you can see any problems with the charts. Thanks, David

  29. David Platten reporter

    The current chart code in views.py is very memory-inefficient, as there are lots of places where variables are assigned data, and then another variable is set to the value of the first one. Reorganising the code so that only one variable is assigned should reduce the memory footprint.

  30. Ed McDonagh

    I'd guess so, unless/until the second variable's value is changed, in which case you'd have a new copy in memory.

    Just going by the page you linked to though, I don't have any expertise in the area!

  31. David Platten reporter

    Removed duplicate variables in ct chart calculations in views.py. Corrected error in CTDI units displayed on the charts. Changed variables to use lower-case. References issue #332

    → <<cset 20dd255dc77c>>

  32. David Platten reporter

    Corrected an error in the if logic that was preventing CT charts from working when both DLP and CTDI per acquisition protocol are selected. References issue #332

    → <<cset ec0df6babebf>>

  33. David Platten reporter

    Updated series labels of average plots so that (mean) or (median) is added to the series labels when plotting both mean and median values. It's so good to be able to update the code in one place and know that all the charts of this type will be up-to-date with the change (thanks, issue #351). References issue #332 and issue #351.

    → <<cset 38b9ffa6aebf>>

  34. David Platten reporter

    Altered some of the CT plot data to produce data split by system as well as requested procedure name. Unfinished, but a start. References issue #332.

    → <<cset 8c65d4ed385b>>

  35. David Platten reporter

    Order of data sorted out (no pun intended). At the moment the plot only works if all scanners have some data for every requested procedure type being displayed. Drilldown and sorting do not work at the moment. References issue #332

    → <<cset b340988ee33d>>

  36. David Platten reporter

    For each requested procedure, forced all scanners to use the same histogram bins: enables histograms to be plotted together for comparison. References issue #332

    → <<cset 10ee0bf16434>>

  37. David Platten reporter

    Ensured that there is an entry for every requested procedure for each scanner, even if some scanners have zero requests for some procedures. References issue #332

    → <<cset 84e3a7b8dcbf>>

  38. David Platten reporter

    There was a problem with the drilldown which was preventing all the histograms from being displayed. Fixed this now. I think that the fix may help increase the speed of other charts. References issue #332

    → <<cset 80fd92e2904a>>

  39. David Platten reporter

    The histograms were in a different order to the median values, so there was a mis-match between the main series and the drilldown. It turns out that this is because the python sorting routines sort in a different way to that of the Django database queries. I've fixed it by ordering the requestSummary data to match the database-provided list of names. References issue #332

    → <<cset dfc8a740cc6a>>

  40. David Platten reporter

    Added user option to plot a series per system, or to group all systems into one series. Also fixed an error in the colour calculations that was causing a divide by zero when there was only one series. References issue #332 and issue #342.

    → <<cset ec745250d1f6>>

  41. David Platten reporter

    Added code to CT request charts to ensure that links from individual system histogram points take the user to only that system data. References issue #332

    → <<cset ba5631884512>>

  42. David Platten reporter

    Updated radiographic charts to use new colour scheme. Also fixed a couple of errors: put back in some code that should not have been removed. References issue #332 and issue #342

    → <<cset 04b29547f7dc>>

  43. David Platten reporter

    Modified logic for mean and median data calculation for requested radiographic data. Should help to speed things up when plotting per system. Need to implement this for the CT requests too. Investigate whether simplifying the field used for num_req or num_acq or num_stu speeds things up too. References issue #332

    → <<cset acede37050c3>>

  44. David Platten reporter

    Improved chart calculation code to avoid unnecessary blocks that won't be needed. Also simplified the field that is used to count how many requests, acquisition, studies have been carried out. References issue #332

    → <<cset 88cfd2d871d6>>

  45. David Platten reporter

    Added the ability to normalise the histogram data. This makes it easier to compare dose distributions from different systems when the number of entries varies greatly between them. References issue #332

    → <<cset 9d386cce06e7>>

  46. David Platten reporter

    Updated JavaScript histogram normalisation code so that the histogram plots are updated live, rather than the user having to return to the main series and then drilldown again. Much, much better now. References issue #332

    → <<cset 45c68227a619>>

  47. David Platten reporter

    nabled radiographic plot of DAP per study description to be displayed with a series per x-ray system. Just the mean plot so far. References issue #332

    → <<cset 53d4b625553c>>

  48. David Platten reporter

    nabled radiographic plot of DAP per study description for median and combined plot of mean and median to be displayed with a series per x-ray system. References issue #332

    → <<cset 5ff6cfee2038>>

  49. David Platten reporter

    Ensured that CTDI and DLP histograms only calculated if required. Moved returnStructure element assigment out of a for loop in two places. References issue #332

    → <<cset cb9bde6604de>>

  50. David Platten reporter

    Made calculation of DLP and CTDI histogram data more efficient if they are both required. Also fixed error when assigning median CTDI data to the chart. References issue #332

    → <<cset 83a9a0b38082>>

  51. David Platten reporter

    CTDI and DLP per acquisition can now be plotted with a series per CT scanner. Removed the plots that showed DLP and CTDI on the same plot. Also simplified some template code. References issue #332

    → <<cset e4ca2174eee9>>

  52. David Platten reporter

    Removed duplicate variables in ct chart calculations in views.py. Corrected error in CTDI units displayed on the charts. Changed variables to use lower-case. References issue #332

    → <<cset 20dd255dc77c>>

  53. David Platten reporter

    Corrected an error in the if logic that was preventing CT charts from working when both DLP and CTDI per acquisition protocol are selected. References issue #332

    → <<cset ec0df6babebf>>

  54. David Platten reporter

    Updated series labels of average plots so that (mean) or (median) is added to the series labels when plotting both mean and median values. It's so good to be able to update the code in one place and know that all the charts of this type will be up-to-date with the change (thanks, issue #351). References issue #332 and issue #351.

    → <<cset 38b9ffa6aebf>>

  55. Log in to comment