analyzing PTW mcc files

1,071 views
Skip to first unread message

tbe...@gmail.com

unread,
Oct 4, 2021, 9:20:03 AM10/4/21
to QATrack+
Hi,

just wanted to share that I uploaded my python code for analyzing PTW mcc files (mainly water tank scans) to github. The code is custom build to fit the needs of my department but still someone might find it interesting or use it as a starting point to implement other/more tests.
You can find it here: https://github.com/tbezo/pymcc

Dependencies:
re, numpy, scipy, pandas, matplotlib, pylinac

with kind regards
Thomas


fxarn...@gmail.com

unread,
Oct 7, 2021, 5:23:48 AM10/7/21
to QATrack+
Thanks a lot for the help !
I'm surprised that for PDDs you didn't fill the dictionnary with depth_max while you coded it. Is that normal ?

tbe...@gmail.com

unread,
Oct 7, 2021, 5:52:31 AM10/7/21
to QATrack+
That is a really good question, normally we use german DIN protocols for our tests, and the depth_max is part of the semi annual tests (DIN 60976 8.1.1). In our department someone decided to use the beam quality index Q from DIN 6800 (= TRS398 TPR20,10) instead of the depth of the maximum of the PDD. So by default I return that value.

fxarn...@gmail.com

unread,
Oct 7, 2021, 9:02:34 AM10/7/21
to QATrack+
Thanks for the answer.
Anyway I added it easily no problem with that. I wanted to be sure that it wasn't  because of something wrong in the code. 
Ok then, works fine for me and give nice results. 
Thanks a lot again, it saves me a lot of time !


James Murphy (Royal Cornwall Hospital)

unread,
Mar 23, 2022, 4:45:50 AM3/23/22
to QATrack+
Thomas, this is great. I had started working on something myself and then found this.
Thanks

James Kerns

unread,
Mar 24, 2022, 1:44:36 PM3/24/22
to QATrack+
This is awesome! Excellent work. You're even using types? Killer.

Paolo Togni

unread,
May 30, 2023, 5:10:02 AM5/30/23
to QATrack+
Hello,

I really needed something like these to get data from Starcheck.
BTW, sorry for the really basic question but I'm an expert at all:
how can I install the module in  QAtrack+?

Regards
Paolo

Paolo Togni

unread,
May 30, 2023, 5:17:28 AM5/30/23
to QATrack+
I've tried the followings but it does not work:

1.
(qatrack31) mdt@mdt:~/Downloads$ pip install pymcc-main.zip
Processing ./pymcc-main.zip
ERROR: file:///home/mdt/Downloads/pymcc-main.zip does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.

2.
(qatrack31) mdt@mdt:~/Downloads$ pip install "git+https://github.com/tbezo/pymcc.git"
Collecting git+https://github.com/tbezo/pymcc.git
  Cloning https://github.com/tbezo/pymcc.git to /tmp/pip-req-build-abss5c_6
  Running command git clone --filter=blob:none --quiet https://github.com/tbezo/pymcc.git /tmp/pip-req-build-abss5c_6
  Resolved https://github.com/tbezo/pymcc.git to commit b58565484cb435cef4d6c34919d7792ba203fcc3
ERROR: git+https://github.com/tbezo/pymcc.git does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.

tbe...@gmail.com

unread,
May 30, 2023, 5:27:21 AM5/30/23
to QATrack+
Hi Paolo,

1. put the folder inside the site-packages folder of your current virtual environment
2. put it inside your /home/$(whoami)/web/qatrackplus/qatrack folder

Sorry for the inconvenience!

Thomas

Paolo Togni

unread,
May 30, 2023, 6:04:41 AM5/30/23
to QATrack+
Thomas,

thanks a lot for the quick answer.
I fixed it with option 1.
BTW, testing the Starcheck example I get now the following error:

Invalid Test Procedure: read_mcc_0_6x.py", line 6, in Test: read_mcc_0_6x
AttributeError: 'list' object has no attribute 'analyze_center'

Any idea?
Regards
Paolo

tbe...@gmail.com

unread,
May 30, 2023, 7:24:15 AM5/30/23
to QATrack+
Hi Paolo,

I was not able to reproduce the error. I did a fresh download from github and tried with python 3.8 and 3.10.
Could you post your code and the full error trace?

regards
Thomas
Message has been deleted

Paolo Togni

unread,
May 30, 2023, 7:57:46 AM5/30/23
to QATrack+
Hello Thomas,

I've just copy/paste the code from your github readme in the 2 qatrack+ macros:

Starcheck

File Upload Test: read_mcc_0_6x (macro name)

import pymcc
# read Starcheck mcc file
mystar = pymcc.readmcc.read_file(FILE.name)
# analyze center inplane and crossplane profiles
mcc_dict = mystar.analyze_center() # provide object dict for composite tests read_mcc_0_6x = mcc_dict

Access single result from dict in composite test: fs_0_y_py (macro name)

fs_0_y_py = read_mcc_0_6x["INPLANE_PROFILE"]["FWHM"]["fwhm"]

enclosed you have the mcc file I'm trying to upload

my python version is Python 3.9.7

Regards
Paolo
TrueBeam_01 X 6.0 10.0x10.0 2023-05-15 12'07'08.mcc

tbe...@gmail.com

unread,
May 30, 2023, 9:46:36 AM5/30/23
to QATrack+
Hi Paolo,

thanks for providing your mcc file. The reason you get that error is, that you use the Starcheck Maxi which was not supported until now, since I did not have any measurement files.
I used your file as a reference and updated the code on github. Please download and try again, it should now work with the latest changes.

regards
Thomas

Paolo Togni

unread,
May 31, 2023, 2:07:47 AM5/31/23
to QATrack+
Hello Thomas,

thanks a lot for your incredible support.
I tried the new code from github but still I get the following error uploading the starcheck mcc file I sent you:

Invalid Test Procedure: read_mcc_0_6x.py", line 6, in Test: read_mcc_0_6x
  File "/home/mdt/venvs/qatrack31/lib/python3.9/site-packages/pymcc/array.py", line 235, in analyze_center
    "CROSSPLANE_PROFILE": self.center_crossplane.calc_results(),
  File "/home/mdt/venvs/qatrack31/lib/python3.9/site-packages/pymcc/wtscans.py", line 812, in calc_results
    "Flatness": self.calc_dinflat(),
  File "/home/mdt/venvs/qatrack31/lib/python3.9/site-packages/pymcc/wtscans.py", line 487, in calc_dinflat
    None,pylinac.core.profile.Interpolation.NONE,False,0.1,10,
AttributeError: module 'pylinac.core.profile' has no attribute 'Interpolation'

I've also tied to open some of the test file from github also I get some error (x1000.mcc):

Invalid Test Procedure: read_mcc_0_6x.py", line 6, in Test: read_mcc_0_6x
AttributeError: 'OCT1000' object has no attribute 'analyze_center'

Thus, it looks like something else is missing in my system.
I checked the dependence (re, numpy, scipy, pandas, matplotlib, pylinac) but everything seems to be there....

Regards
Paolo

tbe...@gmail.com

unread,
May 31, 2023, 4:25:49 AM5/31/23
to QATrack+
Hi Paolo,

may I ask which version of pylinac you use? It could be that the error "AttributeError: module 'pylinac.core.profile' has no attribute 'Interpolation'" hints at an pylinac version below 3.0. QAtrack+ by default installs an old 2.5.x version.
pymcc needs at least pylinac 3.x.

The second error is due to the fact, that the OCT classes do not have the analyze_center function. pymcc creates objects depending on the type of the mcc file you read. The Ocatavius classes are still not useful and have no analyze functions.
Which IDE do you use? I tried to document my source code well, so you should be able to use the tooltips and object explorer of your IDE.

regards
Thomas

Paolo Togni

unread,
May 31, 2023, 4:48:00 AM5/31/23
to QATrack+
Bingo!
I've installed pylinac 3.11.0 and it is now working!

Thanks a lot

Paolo

Marcin

unread,
Oct 16, 2023, 9:05:30 AM10/16/23
to QATrack+
Hi!
Could you share configured test, or some guidelines to create a test to analyze PDDs and profiles according to IAEA398 protocol (from PTW_Data Analyze)?
From PDD I need QI and R100;
From profiles Symmetry [%], Flatness [%] and Field Size [cm].
If it makes things easier, only photon beams.
I am a beginner in configuration.
I use Python 3.8 if it does matter

tbe...@gmail.com

unread,
Oct 17, 2023, 8:25:52 AM10/17/23
to QATrack+
Hi Marcin,

for the sake of completness pymcc is for analyzing water tank scans for routine qa and not intended for reference dosimetry (like trs398 and tg51) which can be done with pylinac (https://pylinac.readthedocs.io/en/latest/calibration_docs.html)

Regarding the parameter you asked, there are examples at the github page:

For the PDD you would need to get the data from your results dictionary via macroname['PDD'][ 'Q Index'] and results_dict['PDD'][ 'D100']
For the profiles you should get what you need from a.e macroname['INPLANE PROFILE'][ 'FHWM']['fhwm'], results_dict['INPLANE PROFILE'][ 'Flatness'] and results_dict['INPLANE PROFILE'][ 'Symmetry']

Please compare the pymcc results to your local ones, there are many definitions for those parameters (data analyze has a.e. 5 different options for flatness and 3 for symmetry), pymcc implements only one (except for one german DIN defintion for electrons pdds).

I attached one of our a test packs for 6MeV photons for QAtrack (pdd and profiles for different field sizes) in case that helps. Descriptions are in german but it might still be a bit more helpul than the github page.

regards
Thomas
wts2.tpk

Marcin

unread,
Oct 18, 2023, 3:31:18 AM10/18/23
to QATrack+
Thank You for the response Thomas
Your test pack helped me a lot.
I assume, that 3 protocols for symmetry are Varian, Elekta and Siemens, as defined in Pylinac?
Sorry for the confusion the IAEA398 I referred to was name in the PTW application, but I did not check, that as default this protocol calculates data only for PH PDD, EL PDD and Bragg Peak. After creating copy we edited it under the same name :)
Flatness is more for out statistics, and having this parameter calculated as we are used to would be for statiscics only, according to new regulations we will have to compare profile to the reference one. Symmetry is defined by polish law so it would be perfect if I could modify the protocol according to this, but I asume that it would have to be in Pylinac?
regards,
Marcin

tbe...@gmail.com

unread,
Oct 18, 2023, 4:38:51 AM10/18/23
to QATrack+
Hi Marcin,

if you want to customize flatness and symmetry you will have to change the code.
Symmetry (calc_sym()) can be found at line 695 in wtscans.py, this function uses pylinac so you have the full pylinac options available. Default is symmetry = pylinac.field_analysis.symmetry_point_difference(profil, 0.8). If pylinac does not have the correct definition (see https://pylinac.readthedocs.io/en/latest/field_analysis.html#supporting-classes) you can either change the code directly or create a custom protocol for pylinac according to the documentation (https://pylinac.readthedocs.io/en/latest/field_analysis.html#creating-using-custom-protocols).

Flatness in pymcc is defined according to german DIN standard (method at line 472 of wtscans.py) which is not readily available in pylinac. Hence I used the pylinac.core.profile.SingleProfile class (https://pylinac.readthedocs.io/en/latest/topics/profiles.html#api) to extract the information I needed for this definition of flatness. So, if the flatness you need is also not part of pylinac (https://pylinac.readthedocs.io/en/latest/field_analysis.html#supporting-classes) you could do the same for your local regulations definition.

I hope that helps

regards
Thomas

Marcin

unread,
Oct 18, 2023, 6:45:03 AM10/18/23
to QATrack+
I changed to Elekta protocol (it seemed to be the closest to our local needs) and after some minor modification of displayed result it seems to shows in accordance to PTW protocol. 
Thank you for helping me :)

Reply all
Reply to author
Forward
0 new messages