Missing exposuretime in RF leads to "Warning! That study was not found"

Issue #547 resolved
Luuk created an issue

If the detailed page of an RF modality is requested and the "exposuretime" is missing for an event, the page will return with "Warning! That study was not found"

Reason is that the aggregate function is in the same try-except block in rf_detail_view. So code should be changed as follows:

        ........
        stu_time_totals = [None] * len(stu_irr_types)
        try:
            for idx, irr_type in enumerate(stu_irr_types):
                stu_time_totals[idx] = GeneralStudyModuleAttr.objects.filter(pk=pk,
                                                      projectionxrayradiationdose__irradeventxraydata__irradiation_event_type__code_meaning=
                                                      irr_type[0]).aggregate(
                    Sum('projectionxrayradiationdose__irradeventxraydata__irradeventxraysourcedata__exposure_time')).values()[0] / 1000
        except TypeError: #{TypeError}unsupported operand type(s) for /: 'NoneType' and 'int'
            stu_time_totals[idx] = None
        study_totals = np.column_stack((stu_irr_types, stu_dose_totals, stu_time_totals)).tolist()
        ........

(Btw this error may be caused by incomplete extraction of data instead of not recording of data by modality, I'll look into this)

Comments (25)

  1. Luuk reporter

    I see that "exposure time" is not recorded by the system, but "irradiation duration" is. I don't know if these are interchangable, but changing the code to:

            stu_time_totals = [None] * len(stu_irr_types)
            try:
                for idx, irr_type in enumerate(stu_irr_types):
                    stu_time_totals[idx] = GeneralStudyModuleAttr.objects.filter(pk=pk,
                                                          projectionxrayradiationdose__irradeventxraydata__irradiation_event_type__code_meaning=
                                                          irr_type[0]).aggregate(
                        Sum('projectionxrayradiationdose__irradeventxraydata__irradeventxraysourcedata__exposure_time')).values()[0] / 1000
            except TypeError: #{TypeError}unsupported operand type(s) for /: 'NoneType' and 'int'
                stu_time_totals[idx] = GeneralStudyModuleAttr.objects.filter(pk=pk,
                                                                             projectionxrayradiationdose__irradeventxraydata__irradiation_event_type__code_meaning=
                                                                             irr_type[0]).aggregate(
                    Sum(
                        'projectionxrayradiationdose__irradeventxraydata__irradeventxraysourcedata__irradiation_duration')).values()[0]
            study_totals = np.column_stack((stu_irr_types, stu_dose_totals, stu_time_totals)).tolist()
    

    works in my case. But in the table "exposure time" is not filled per event. Should we add "irradiation durration" here also (if exposure time is not filled)? In my case the unit for exposure time is in mS and irradiation duration in S.

  2. Luuk reporter

    According to DICOM 3.16: Irradiation Duration: Clock time from the start of loading time of the first pulse until the loading time trailing edge of the final pulse in the same irradiation event Exposure Time: Total time the patient has received X-Ray exposure during the irradiation event

    Not the same (I would say), especially for pulsed fluoroscopy. But I also see that for the total fluoroscopy/acquisition time "Irradiation Duration" should be used. So I would say that we should also prefer Irradiation Duration for the calculations (and code should be different than stated above).

    Irradiation Duration is not required (Type U) Exposure time is required (Type MC) if Exposure is missing (At least Exposure should be present or Exposure time and Tube current)

  3. Luuk reporter

    I looked somewhat more into this, this afternoon. What do you think @edmcdonagh, @dplatten?

    Seen the above I would suggest to use irradiation duration as default and fall back to exposure time if irradiation duration is not available. Would the column name "exposure time" still cover? This would mean the following changes:

    rfdetail.html:

    • add if construction for showing irradiation duration or exposure time.
    • add "template filter" to multiply irradiation duration with thousand

    view.py

    • add / register multiplication filter
    • change code to first use irradiation duration for aggregate function and if not available use exposure time
    • change code if using exposure time to prevent None dividing by 1000 (already committed by Ed)

    I played around and the above seems to work fine, but should it be done like that?

  4. Ed McDonagh

    I'm not sure why we are calculating this for the table... Total fluoro and acquisition times, RP dose and DAP are available pre-computed at study level.

    Also, as you point out we are displaying x-ray on time, whilst the total time at study level, and I think what people expect to see, is button pressed time.

  5. David Platten

    There wasn't a reason - I didn't realise there was more than one way to get the exposure time. Very happy for it to be changed.

  6. Luuk reporter

    If I remember correctly, this was the way that all acquisition types could be handled (also the rotational and stepping). I'll have a look at it.

  7. Luuk reporter

    If we want an overview of the DAP / Dose / duration of the fluoroscopy and different acquisition events as described in issue #497, we need to iterate over the different events (and can't use the totals from TID10004 except for fluoroscopy).

    When using the totals from TID10004 one should iterate over the planes (for biplane systems), but one can only differentiate in fluoroscopy and acquisition (not the different types of acquisition).

    I would suggest to use duration only (so the button pressed time) and if not available, don't display anything. For example we have a 20s rotational acquisition. This acquisition takes about 20 seconds, but exposure time is just about 4 seconds (which is a bit contra-intuitive for the user).

    To be able to show as much data as is available, I would suggest:

    • Use TID10004 for total fluoroscopy DAP, Dose at RP and duration.
    • Use iteration over all acquisition events for total stationary/stepping/rotational acquisition DAP, Dose at RP and duration
    • Use TID10004 for total DAP, Dose at RP
    • (show only duration and not exposure time)

    What do you think @edmcdonagh, @dplatten?

  8. Ed McDonagh

    I think we should use the total duration from TID10004 for both fluoroscopy and acquisition, as it is the only duration that is mandatory.

    You could then have an 'of which' section for stationary, stepping and rotational if more than one type of event exists?

    Does that make sense? (By the way, I'm not overruling, just throwing my opinion in!)

  9. Luuk reporter

    Refs #547 Code update concerning summary tabel information and exposure time vs duration

    • Exposure time replaced by Duration
    • Total DAP / Dose / Duration for acquisition and fluoroscopy taken from TID 10004
    • Total DAP / Dose / Duration for different acquistions types kept as was (except duration is taken instead of exposure time)
    • Updated look of summary table

    → <<cset 54f862787e5a>>

  10. Ed McDonagh

    Thanks @LuukO. I've thrown it onto testing.openrem.org so we can have a look.

    At this stage, I'm not convinced I want to lose actual exposure time completely. I'll have a think...

  11. Luuk reporter

    I was doubting about it too. Especially for (stationary) acquisitions exposure time can be interesting. For Fluoroscopy the ratio of duration and exposure time might also be interesting. We can have both duration and exposure time of course.

  12. Ed McDonagh

    Hi @LuukO. Did you want to put something together that shows both times? Otherwise I'll have a go.

  13. Luuk reporter

    Refs issue #547 Accomodate duration as well as exposure time

    Exposure time is only added in the detail table not in the accumulated data table as exposure time is not available in the accumulated data.

    → <<cset 4b6f67ad306f>>

  14. Ed McDonagh

    Looking good to me. Thanks @LuukO.

    @DPlatten - do you want to have a look at testing and see what you think? The Siemens examples have duration at study level and exposure time at event level; the Philips example has duration at study level and both at event level.

    We could of course work out the duration at event level, but I propose we don't at this stage!

  15. Ed McDonagh

    I think I'd prefer it as it is. The acquisition irradiation elements are not part of the total that is currently left aligned; if the italicised numbers were in the same column it wouldn't add up. They are the 'of which' numbers.

    Does that persuade you?

  16. Luuk reporter

    Actually that is the reason that I made it right aligned in the first place. But if there are better ideas / ways to make the distinction, I'm in.

  17. David Platten

    @edmcdonagh and @LuukO: I hadn't realised that the right-aligned values aren't part of the total. I think it's fine for the table to remain as it is. Regards, David

  18. Ed McDonagh

    A placeholder as much as anything. @LuukO - my reading of the standard is that the irradiation duration is in seconds at event level. We have it being in ms in the template column header, and the Philips system we have in there seems to be in ms. But surely it should be in seconds!

    I haven't looked at the original RDSR or the template yet.

  19. Luuk reporter

    Ed, The Philips RDSR does have it in seconds and it is extracted in seconds. Only when viewing the event duration time is multiplied by 1000 to get it in ms (the same as for exposure time, that seemed more clean to me).

  20. Log in to comment