Display additional fields in detailed fluoroscopy view

Issue #497 resolved
David Platten created an issue

I'd like to add columns to the detailed event table in rfdetail.html for the following:

  • Secondary angle (primary angle is already displayed). Need to amend title for primary angle to include the word primary too.
  • Pulse rate
  • Dose at reference point

These could be added by including the following lines in the appropriate place in the file, together with suitable additions for the column headings:

<td>{{ event.irradeventxraymechanicaldata_set.get.positioner_secondary_angle|floatformat:1 }}</td>
<td>{{ event.irradeventxraysourcedata_set.get.pulse_rate|floatformat:2 }}</td>
<td>{{ event.irradeventxraysourcedata_set.get.dose_rp|floatformat:2 }}</td>

(Note: dose_rp is stored in the database as Gy - can is there a built-in conversion in OpenREM to display this as mGy?)

Comments (18)

  1. David Platten reporter

    Add a new function to the IrradEventXRaySourceData class in models.py to allow display of dose_rp in mGy in the web interface:

        def convert_gy_to_mgy(self):
            """Converts Gy to mGy for display in web interface
            if self.dose_rp:
                return 1000*self.dose_rp

    Then in the template use the following line:

    <td>{{ event.irradeventxraysourcedata_set.get.convert_gy_to_mgy|floatformat:2 }}</td>
  2. Luuk

    What also would be great is to see acquisition type in the table (fluoroscopic, static acquisition, rotational acquisition)

    Also in the header information it would be nice if you could see how much of the DAP and Dose is caused by fluoroscopic runs and how much by acquisitions:

    • Total DAP, Single Plane: 1.9 cGy.cm2 (fluoro: 1.3, acquisitions: 0.6)
    • Total dose at RP, Single Plane: 1.90 Gy (fluoro: 1.3, acquisitions: 0.6)
  3. David Platten reporter

    There are four possible irradiation event types defined at the moment (http://dicom.nema.org/MEDICAL/Dicom/2015c/output/chtml/part16/sect_CID_10002.html):

    • Fluoroscopy
    • Stationary Acquisition
    • Stepping Acquisition
    • Rotational Acquisition

    I could calculate the total DAP and dose at reference point for each of these in rf_detail_view within views.py each time the user selects a study.

    Alternatively these values could be calculated at import and stored in the database.

    The easy option for me now is too add code to rf_detail_view that calculates these values each time they are needed.

  4. David Platten reporter

    Added additional fields to table on rfdetail.html page: irradiation_event_type, pulse_rate, positioner_secondary_angle and dose_rp (in mGy). Need to add the display of DAP and dose at RP for each irradiation event type. References issue #497

    → <<cset dd15a600341b>>

  5. David Platten reporter

    I think I should be able to annotate the DAP sum for each irradiation type to the objects corresponding to the required study, but it doesn't work: I just get a single total DAP. Any thoughts on how to do this anyone? The code below would go in rf_detail_view within views.py instead of the simple study = GeneralStudyModuleAttr.objects.get(pk=pk) line:

    from django.db.models import Sum
    testing = GeneralStudyModuleAttr.objects.filter(pk=pk).annotate(sum_dap = Sum('projectionxrayradiationdose__irradeventxraydata__dose_area_product')).order_by('projectionxrayradiationdose__irradeventxraydata__irradiation_event_type')

    PS: I have since realised that the above code does work

  6. David Platten reporter

    Added code to calculate and display DAP and dose at reference point for each irradiation type (fluoro, stationary acquisition etc). Works fine, but at the moment the values aren't formatted (loads of decimal places) and I think the code is a bit ugly. Happy to accept suggestions as to how to improve it. References issue #497

    → <<cset 062b57861dd9>>

  7. David Platten reporter

    Modified code so that I can format the total DAP and reference point dose values. These are now formatted in a similar way to the study totals on the same page. The dose at reference point per irradiation type is shown with three significant figures. The DAP totals for each irradiation type are shown with two decimal places. References issue #497

    → <<cset c325e23f2ed4>>

  8. David Platten reporter
    • changed status to open

    I'd like to include the total exposure time for each type of irradiation event, in addition to the DAP and dose at reference point. This can easily be added to the existing table.

  9. David Platten reporter

    In view.py the rf_detail_view code needs to be changed to:

            study = GeneralStudyModuleAttr.objects.get(pk=pk)
            stu_inc_totals = GeneralStudyModuleAttr.objects.filter(pk=pk).annotate(
                sum_dap = Sum('projectionxrayradiationdose__irradeventxraydata__dose_area_product')*1000000,
                sum_dose_rp = Sum('projectionxrayradiationdose__irradeventxraydata__irradeventxraysourcedata__dose_rp')
            stu_dose_totals = stu_inc_totals.values_list('sum_dap', 'sum_dose_rp').order_by('projectionxrayradiationdose__irradeventxraydata__irradiation_event_type')
            stu_irr_types = stu_inc_totals.values_list('projectionxrayradiationdose__irradeventxraydata__irradiation_event_type__code_meaning').order_by('projectionxrayradiationdose__irradeventxraydata__irradiation_event_type').distinct()
            stu_time_totals = [None] * len(stu_irr_types)
            for idx, irr_type in enumerate(stu_irr_types):
                stu_time_totals[idx] = GeneralStudyModuleAttr.objects.filter(pk=pk,
                    Sum('projectionxrayradiationdose__irradeventxraydata__irradeventxraysourcedata__exposure_time')).values()[0] / 1000
            study_totals = np.column_stack((stu_irr_types, stu_dose_totals, stu_time_totals)).tolist()

    and the table in rfdetail needs to be:

                <table class="table table-condensed table-bordered small">
                    <th>Irradiation type</th><th>Total DAP (cGy.cm<sup>2</sup>)</th><th>Total dose at RP (Gy)</th><th>Total time (s)</th>
                    {% for irr_type in study_totals %}
                        <td>{{ irr_type.0 }}</td>
                        <td><script>document.write({{ irr_type.1 }}.toFixed(2));</script></td>
                        <td><script>document.write({{ irr_type.2 }}.toPrecision(3));</script></td>
                        <td><script>document.write({{ irr_type.3 }}.toFixed(2));</script></td>
                    {% endfor %}
  10. Ed McDonagh

    @dplatten - I think this might be fixed? Can you cast your eye over it and if it is, change the assignee to yourself and mark it fixed/closed?


  11. Log in to comment