Acquisition-level filters don't really filter the displayed data or charts

Issue #221 resolved
David Platten created an issue

The filters work at a study level.

If a user chooses a maximum acquisition DLP filter of 1000 mGy.cm then all studies with at least one acquisition at or below 1000 mGy.cm will be shown. This will pretty much show everything, as the scan-projection radiographs all have very small DLP values.

The corresponding chart of mean acquisition DLP includes lots of data that exceeds the user's maximum value of 1000 mGy.cm. Not really what they want, I suspect. Certainly not what I wanted when I used this earlier on this afternoon.

The solution? I don't think that it's straightforward so sort out the tabulated data that is displayed. However, I think the acquisition-related charts can be sorted out.

In view.py the acquisition_events variable is designed to contain all acquisitions that are in the currently filtered studies:

acquisition_events = CtIrradiationEventData.objects.exclude(
    ct_acquisition_type__code_meaning__exact = u'Constant Angle Acquisition'
).exclude(
    dlp__isnull=True
).filter(
    ct_radiation_dose__general_study_module_attributes__study_instance_uid__in = expInclude
)

This variable needs to be more strictly filtered to remove values that are not required. It's ugly because you have to check that there is a valid value in the filter before you try and apply it. The example below is missing the acquisition protocol filter too, which will make it a whole lot more ugly:

        if requestResults.get('acquisition_dlp_max') and requestResults.get('acquisition_dlp_min'):
            acquisition_events = CtIrradiationEventData.objects.exclude(
                ct_acquisition_type__code_meaning__exact = u'Constant Angle Acquisition'
            ).exclude(
                dlp__isnull=True
            ).filter(
                ct_radiation_dose__general_study_module_attributes__study_instance_uid__in = expInclude,
                dlp__lte=requestResults.get('acquisition_dlp_max'),
                dlp__gte=requestResults.get('acquisition_dlp_min')
            )
        elif requestResults.get('acquisition_dlp_max'):
            acquisition_events = CtIrradiationEventData.objects.exclude(
                ct_acquisition_type__code_meaning__exact = u'Constant Angle Acquisition'
            ).exclude(
                dlp__isnull=True
            ).filter(
                ct_radiation_dose__general_study_module_attributes__study_instance_uid__in = expInclude,
                dlp__lte=requestResults.get('acquisition_dlp_max')
            )
        elif requestResults.get('acquisition_dlp_min'):
            acquisition_events = CtIrradiationEventData.objects.exclude(
                ct_acquisition_type__code_meaning__exact = u'Constant Angle Acquisition'
            ).exclude(
                dlp__isnull=True
            ).filter(
                ct_radiation_dose__general_study_module_attributes__study_instance_uid__in = expInclude,
                dlp__gte=requestResults.get('acquisition_dlp_min')
            )
        else:
            acquisition_events = CtIrradiationEventData.objects.exclude(
                ct_acquisition_type__code_meaning__exact = u'Constant Angle Acquisition'
            ).exclude(
                dlp__isnull=True
            ).filter(
                ct_radiation_dose__general_study_module_attributes__study_instance_uid__in = expInclude
            )

I don't know of a way of elegantly implementing this at the moment, but I think it needs to be done. It probably also applies to the DX acquisition-related charts too.

Comments (7)

  1. David Platten reporter

    Applied acquisition-level filters to the CT plot data so that only acquisitions that fall within the acquisition-related filters are shown in the plots. I need to add similar code to the radiographic views. This references issue #221.

    → <<cset 2e77a3612e64>>

  2. David Platten reporter

    My solution to this uses a dictionary of key-value pairs to do the filtering. Much better than the long-handed mess in my initial post on this issue.

  3. David Platten reporter

    Applied acquisition-level filters to the radiographic plot data so that only acquisitions that fall within the acquisition-related filters are shown in the plots. Fixes issue #221.

    → <<cset 58630cc42651>>

  4. Log in to comment