Plan Evaluation Tools

Hello, I’m heading a software effort building a research tool in the RadiationOncology area, it’s called OnkoDICOM. If you or are interested you can get it from GitHub.

As we move into 2021, I have some RTs asking whether it will do plan evaluation. At present it does not. So I thought that I would pose the question here as to the plan assessment tools that PyMedPhys has.

Does it poses a function to produce Dice Coefficients?

In addition are there functions to access clinical data from MOSAIQ?

Any discussion on these issues would be appreciated.

AAM

Hi @AAM,

Welcome to the PyMedPhys Discourse forum :slight_smile: :tada:

When you refer to Dice determination do you mean something like being able to pass two DICOM files and then produce a Dice coefficient for each structure name that has the same name?

To achieve this PyMedPhys does have within it a means to pull the x, y, and z coordinates from a DICOM file’s structure. From there shapely can be used to determine Dice:

If one of your students was happy to give a shot making this an officially supported part of the PyMedPhys’ API I’d be more than happy to help them do so :slight_smile:.

Regarding Mosaiq access, I’ll post a bit more later tonight.

Cheers :slight_smile:,
Simon

So PyMedPhys has a neat wrapper to support Mosaiq SQL queries. For example:

import pymedphys

mosaiq_hostname = 'msqsql'  # Your hostname here
patient_id = '000000'  # Your patient ID here

# Your query here
sql_query = """
    SELECT
        TxField.FLD_ID,
        TxField.Field_Label,
        TxField.Field_Name,
        TxField.Version,
        TxField.Meterset,
        TxField.Type_Enum,
        Site.Site_Name
    FROM Ident, TxField, Site
    WHERE
        TxField.Pat_ID1 = Ident.Pat_ID1 AND
        TxField.SIT_Set_ID = Site.SIT_Set_ID AND
        Ident.IDA = %(patient_id)s
"""

with pymedphys.mosaiq.connect(mosaiq_hostname) as cursor:
    results = pymedphys.mosaiq.execute(
        cursor, sql_query, {"patient_id", patient_id}
    )

print(results)

That SQL query above is used as part of a workflow to extract MLC positions from Mosaiq in the following demo:

There is one big caveat though. At this point in time there is no automated testing + CI being undergone of the Mosaiq API within PyMedPhys. To set up CI for the Mosaiq API we need to be able to create a database dump from a fresh Mosaiq instance that has some dummy testing data within it. This requires setting up a fresh Mosaiq install, creating some dummy data within it, and then run a database backup to file.

Until this dummy Mosaiq database is created the rigour around the Mosaiq API within PyMedPhys is limited. Unfortunately, as of yet, I have been unable to find someone for which this is a sufficiently high priority for them to undergo this task and as such it has not yet been undergone.

Cheers,
Simon

I was using “Dice Coefficient” is the setting of measuring conformality of isodose to ROI in a single plan. I was unaware of this other use.

Currently, my project OnkoDICOM enables the use of Standardised Naming very easily so my hope is that in time there will be no variation.

AAM

At the end of the day, if you have (x, y) coordinates of a shape within a single slice (such as an isodose curve) and you have the (x, y) coordinates of a contour, shapely can be used as linked to above to calculate Dice.

A dose grid can be converted to isodose (x, y) coordinates using the matplotlib library. Below is an approach where this is undergone to convert a mask into a structure contour, but to convert dose to (x, y) coordinates for an isodose the same approach can be used:

As before, I would be more than happy to have this become part of the stable API exported from PyMedPhys if one of your students wanted to take responsibility for it.

Cheers,
Simon

As an introduction, can you provide some quick help on using the Jupyter link.

My recollection is that it runs in the browser locally, so that I should be able to access my MQ if I am behind the firewall.

Correct?

A

Do you have PyMedPhys and Jupyter Lab installed on your machine?

No, I’ll look into that soon,

A

Kk, see the following for PyMedPhys installation:

Thanks, just finished Anaconda install.

Now working on opening the notebook file you provided.

AAM

How’d you go? Did you have much success? The key is running jupyter lab within a console/command prompt in the directory where your notebook file is.

slowly slowly. I’ll check out the jupyter lab suggestion next when in the department

A