[Gate-users] Using parameters for mac files

David Leibold D.Leibold at tudelft.nl
Mon Mar 21 12:29:07 CET 2022


Hi Mark,

I don’t think I can be of any more help. The only ways I could think of are trying to bypass your problem. You could for example create a string that contains your Gate command as follows:

#!/bin/bash
NumberPrimaries=0
read -p "Enter your number of primaries: “ NumberPrimaries
string="Gate –a [Prims,$NumberPrimaries][CTData,data/dcm/CT/br38f.mha][PETData,data/dcm/PT/nomaskPET.mha] mac/main1.mac &”
echo “$string"
#eval $string

In case the output string is correct, uncomment the “eval $string” command.

Best regards,
David


On 21 Mar2022, at 11:58, BAKER, Mark (THE CLATTERBRIDGE CANCER CENTRE NHS FOUNDATION TRUST) <mark.baker23 at nhs.net<mailto:mark.baker23 at nhs.net>> wrote:

Hi David

Thank you for your reply. I can’t recall exactly what combinations I have tried, so I have just gone through the options below one by one to confirm. I’m currently in trouble shoot mode, so my code looks more like this now (concentrating more on just getting one variable (Prims) working for now).

Gate –a [Prims,${NumberPrimaries}][CTData,data/dcm/CT/br38f.mha][PETData,data/dcm/PT/nomaskPET.mha] mac/main1.mac & -no spaces as per the bottom solution on github and your example

Gate “–a[Prims,${NumberPrimaries}][CTData,data/dcm/CT/br38f.mha][PETData,data/dcm/PT/nomaskPET.mha]” mac/main1.mac & -as per the other solution on github, with and without a space between –a and [Prims…]

Gate –a “’[Prims,${NumberPrimaries}][CTData,data/dcm/CT/br38f.mha][PETData,data/dcm/PT/nomaskPET.mha]’” mac/main1.mac & - as per Helge’s email below. I wasn’t sure if they were ‘ or ` so I tried both. With ` it ignored Prims and errored on CTData (both with the manually typed path and $CTDataFile)

The next examples were effectively me just guessing potential solutions:
Gate –a ‘[Prims,${NumberPrimaries}][CTData,data/dcm/CT/br38f.mha][PETData,data/dcm/PT/nomaskPET.mha]’ mac/main1.mac &
Gate –a `[Prims,${NumberPrimaries}][CTData,data/dcm/CT/br38f.mha][PETData,data/dcm/PT/nomaskPET.mha]` mac/main1.mac & - similar error on CTData
Gate –a [Prims,”${NumberPrimaries}”][CTData,data/dcm/CT/br38f.mha][PETData,data/dcm/PT/nomaskPET.mha] mac/main1.mac &

This code works though
Gate –a [Prims,1000][CTData,data/dcm/CT/br38f.mha][PETData,data/dcm/PT/nomaskPET.mha] mac/main1.mac &


The code for asking for the primaries is below, and seems to work fine according to the echo (just to confirm, it runs early in the script also, before Gate is ran)..
NumberPrimaries=0
read –p “How many primaries per core? “ NumberPrimaries
echo “You have chosen $NumberPrimaries primaries to run on each core”

and the code calling {Prims} in main1.mac is
/gate/application/setTotalNumberOfPrimaries {Prims}

Thank you very much

Mark Baker
Principal Clinical Scientist (Interim)
Imaging Physics (Ionising)
The Clatterbridge Cancer Centre NHS Foundation Trust
(he, him)

CCCW Tel:  0151 556 5030
CCCL Tel: 0151 318 8438
Email: mark.baker23 at nhs.net<mailto:mark.baker23 at nhs.net>
Microsoft Teams (click here)<https://urldefense.proofpoint.com/v2/url?u=https-3A__teams.microsoft.com_l_chat_0_0-3Fusers-3Dmark.baker23-40nhs.net&d=DwMGaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=lfXR69GFfS7NT-Wp5HZqbtBDrbYoilDdmNEG7fKW7aM&m=jFEsVlJw7a8Jr64ONw_NUE9Tky3pwCzd0IBHRkPnmnc&s=qKBUsL42Jr14sw_jYVs7EDRVEqCebIxSdvDWHP-19RQ&e=>

From: David Leibold <D.Leibold at tudelft.nl<mailto:D.Leibold at tudelft.nl>>
Sent: 21 March 2022 10:22
To: BAKER, Mark (THE CLATTERBRIDGE CANCER CENTRE NHS FOUNDATION TRUST) <mark.baker23 at nhs.net<mailto:mark.baker23 at nhs.net>>
Cc: gate-users at lists.opengatecollaboration.org<mailto:gate-users at lists.opengatecollaboration.org>
Subject: Re: [Gate-users] Using parameters for mac files

Hi Mark,

do you mind posting the variants you tried and that didn’t work?

 In your example, I would use the following command in my bash script:

Gate -a [CTData,${CTDataFile}][NoOfPrimaries,${NumberPrimaries}][PETData,${PTDataFile}] mac/main1.mac &

That always works for me (the only difference is that my bash script starts the main.mac from the same directory, but you mentioned that this works when putting in the values manually, so it’s unlikely to cause the issue I guess). As mentioned in that second link of yours, this doesn't use any spaces within or between the square brackets.

Let us know whether that helps.

Best regards,
David




On 21 Mar2022, at 11:03, BAKER, Mark (THE CLATTERBRIDGE CANCER CENTRE NHS FOUNDATION TRUST) <mark.baker23 at nhs.net<mailto:mark.baker23 at nhs.net>> wrote:

Hi all

Well it turns out that I was a little premature in my celebration. Whilst my script works perfectly if I manually put in the values I want but if the values is in the form of a $variable then I alias errors. I’ve tried various combinations of “” `` and ‘’ to no avail unfortunately. In addition to this email chain, I also found this github posthttps://github.com/OpenGATE/Gate/issues/69<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_OpenGATE_Gate_issues_69&d=DwMGaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=lfXR69GFfS7NT-Wp5HZqbtBDrbYoilDdmNEG7fKW7aM&m=JXkYrD_N3zHhNT53wVMyxPpl-Vu7G4qlA8lefFcef9A&s=0q-TW5D7-_virjlOyAZt3gCt4gst7HGeKexff8I6Nlw&e=> and a similar mailbase post (http://lists.opengatecollaboration.org/pipermail/gate-users/2015-March/008227.html<https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.opengatecollaboration.org_pipermail_gate-2Dusers_2015-2DMarch_008227.html&d=DwMGaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=lfXR69GFfS7NT-Wp5HZqbtBDrbYoilDdmNEG7fKW7aM&m=JXkYrD_N3zHhNT53wVMyxPpl-Vu7G4qlA8lefFcef9A&s=mJQ0a9zm2AD3Aj5uNENEbWGAZ6_aYNgX_riUAeuJcpg&e=>) about the issue but the solution didn’t work me either. I’m on VGate9.0 if that makes a difference, as both of those posts are possibly a version or two earlier based on their date.

I know little about bash scripts, but I believe the variable is being stored correctly as it works with echo and displays what I expect.

Does anyone have any suggestions or alternatives that I can explore?

Thank you very much

Mark Baker
Principal Clinical Scientist (Interim)
Imaging Physics (Ionising)
The Clatterbridge Cancer Centre NHS Foundation Trust
(he, him)

CCCW Tel:  0151 556 5030
CCCL Tel: 0151 318 8438
Email: mark.baker23 at nhs.net<mailto:mark.baker23 at nhs.net>
Microsoft Teams (click here)<https://urldefense.proofpoint.com/v2/url?u=https-3A__teams.microsoft.com_l_chat_0_0-3Fusers-3Dmark.baker23-40nhs.net&d=DwMGaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=lfXR69GFfS7NT-Wp5HZqbtBDrbYoilDdmNEG7fKW7aM&m=JXkYrD_N3zHhNT53wVMyxPpl-Vu7G4qlA8lefFcef9A&s=jcYxmFfI9EQDmwEWN9bPm0xKwKHlfnGIwAtpSUG-XQE&e=>

From: Gate-users <gate-users-bounces at lists.opengatecollaboration.org<mailto:gate-users-bounces at lists.opengatecollaboration.org>> On Behalf Of BAKER, Mark (THE CLATTERBRIDGE CANCER CENTRE NHS FOUNDATION TRUST)
Sent: 17 March 2022 14:03
To: Helge Pettersen <helge.e.s.pettersen at gmail.com<mailto:helge.e.s.pettersen at gmail.com>>; Schneider Tim <Tim.Schneider at curie.fr<mailto:Tim.Schneider at curie.fr>>
Cc: gate-users at lists.opengatecollaboration.org<mailto:gate-users at lists.opengatecollaboration.org>
Subject: Re: [Gate-users] [BULK ?] Using parameters for mac files

Thank you very much Tim and Helge, that is working now. I won’t tell you how embarrassingly long I spent trying to fix what was effectively just the wrong order.

I have a few other small bugs to iron out, such as it thinks the extension is missing from the PET data etc. now, but it is at least triggering Gate to open.

Thank you

Mark Baker
Principal Clinical Scientist (Interim)
Imaging Physics (Ionising)
The Clatterbridge Cancer Centre NHS Foundation Trust
(he, him)

CCCW Tel:  0151 556 5030
CCCL Tel: 0151 318 8438
Email: mark.baker23 at nhs.net<mailto:mark.baker23 at nhs.net>
Microsoft Teams (click here)<https://urldefense.proofpoint.com/v2/url?u=https-3A__teams.microsoft.com_l_chat_0_0-3Fusers-3Dmark.baker23-40nhs.net&d=DwMGaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=lfXR69GFfS7NT-Wp5HZqbtBDrbYoilDdmNEG7fKW7aM&m=JXkYrD_N3zHhNT53wVMyxPpl-Vu7G4qlA8lefFcef9A&s=jcYxmFfI9EQDmwEWN9bPm0xKwKHlfnGIwAtpSUG-XQE&e=>

From: Helge Pettersen <helge.e.s.pettersen at gmail.com<mailto:helge.e.s.pettersen at gmail.com>>
Sent: 17 March 2022 13:37
To: Schneider Tim <Tim.Schneider at curie.fr<mailto:Tim.Schneider at curie.fr>>
Cc: BAKER, Mark (THE CLATTERBRIDGE CANCER CENTRE NHS FOUNDATION TRUST) <mark.baker23 at nhs.net<mailto:mark.baker23 at nhs.net>>; gate-users at lists.opengatecollaboration.org<mailto:gate-users at lists.opengatecollaboration.org>
Subject: Re: [Gate-users] [BULK ?] Using parameters for mac files

Hi,

I don't know if this is the issue, but I usually have to escape the parameter list when I use bash $variables. See example below:

Gate -a "'[phantom,$phantom] [spotx,$x]
[spoty,$y] [theta,$theta] [axisx,$axis_x] [axisy,$axis_y]
[rotation,90]'" Main_phantom.mac





Good luck,

Helge Egil Seime Pettersen, PhD
Particle Therapy / Imaging / Proton CT
Department of Oncology and Medical Physics
Haukeland University Hospital
Bergen, Norway


On Thu, Mar 17, 2022 at 2:15 PM Schneider Tim <Tim.Schneider at curie.fr<mailto:Tim.Schneider at curie.fr>> wrote:
Hi Mark,

When I run macros with parameters, I call them like this:

Gate -a [param,value] mac/macro.mac

Not sure if your way of doing it is correct as well, but the above always worked for me.

Cheers,
Tim

Am 17/03/2022 um 13:11 schrieb BAKER, Mark (THE CLATTERBRIDGE CANCER CENTRE NHS FOUNDATION TRUST) <mark.baker23 at nhs.net<mailto:mark.baker23 at nhs.net>>:

Hi all

I am trying to run some parameters into my Gate simulation, but it doesn’t seem to be working and Gate sticks at the PreInit stage (although the CPU does ramp up to 100%). I am running multiple instances of Gate (up to 8 simultanouely), so it is laborious to go into each of the macs every time I want to change a parameter, so I was hoping this would help. My project is hoping to calculate dose distributions from PET scans using CT scans as the geometry. Previously it was working fine until I tried to add the parameters.

The relevant parts of my code are below (there is obviously a lot more so I’ve attached the files also in case anyone wants to look deeper, some bits commented out during the debugging)

In the main1.mac, I have changed the geometry to
/gate/world/daughters/name patientCT
/gate/world/daughters/insert ImageNestedParametrisedVolume
/gate/patientCT/geometry/setImage {CTData}

The main1.mac calls sourceF18.mac as its source, which contains the link to the PET data. The relevant part is
/gate/source/addSource patientPET voxel
/gate/source/patientPET/imageReader/readFile {PETData}

I also change the number of primaries on the fly, so I set that to the following in main1.mac
/gate/application/setTotalNumberOfPrimaries {NoOfPrimaries}

I’ve a got a script to run the multiple instances of Gate, alongside a lot of housework for moving files and merging them etc. I have checked the input to the parameters, and as far as I can tell, they are fine.

I call Gate using the following
Gate mac/main1.mac [CTData,$CTDataFile] [NoOfPrimaries,$NumberPrimaries] [PETData,$PTDataFile] &

where the user could select the following information, for example,
$CTDataFile is data/dcm/CT/br38f.mha
$PTDataFile is data/dcm/PT/brainmaskPET.mha
$NumberPrimaries is 1000

If I go back to my main1.mac etc. and manually change the parameters to the data above and change my run.sh script to Gate mac/main1.mac &  it works perfectly, so presumably I am doing something wrong with passing the parameters through.

I’d appreciate it if anyone had any thoughts on this?

Thank you

Mark Baker
Principal Clinical Scientist (Interim)
Imaging Physics (Ionising)
The Clatterbridge Cancer Centre NHS Foundation Trust
(he, him)

CCCW Tel:  0151 556 5030
CCCL Tel: 0151 318 8438
Email: mark.baker23 at nhs.net<mailto:mark.baker23 at nhs.net>
Microsoft Teams (click here)<https://urldefense.proofpoint.com/v2/url?u=https-3A__teams.microsoft.com_l_chat_0_0-3Fusers-3Dmark.baker23-40nhs.net&d=DwMGaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=lfXR69GFfS7NT-Wp5HZqbtBDrbYoilDdmNEG7fKW7aM&m=JXkYrD_N3zHhNT53wVMyxPpl-Vu7G4qlA8lefFcef9A&s=jcYxmFfI9EQDmwEWN9bPm0xKwKHlfnGIwAtpSUG-XQE&e=>

Honorary Lecturer, Dept. of Physics
University of Liverpool





************************************************************************************** ******************************

This message may contain confidential information. If you are not the intended recipient please:
i) inform the sender that you have received the message in error before deleting it; and
ii) do not disclose, copy or distribute information in this e-mail or take any action in relation to its content (to do so is strictly prohibited and may be unlawful).
Thank you for your co-operation.

NHSmail is the secure email, collaboration and directory service available for all NHS staff in England. NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and other accredited email services.

For more information and to find out how you can switch visit Joining NHSmail – NHSmail Support<https://urldefense.proofpoint.com/v2/url?u=https-3A__support.nhs.net_article-2Dcategories_joining-2Dnhsmail_&d=DwMGaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=lfXR69GFfS7NT-Wp5HZqbtBDrbYoilDdmNEG7fKW7aM&m=JXkYrD_N3zHhNT53wVMyxPpl-Vu7G4qlA8lefFcef9A&s=M8imf9aq39eFDsb-v-iGGZFZTuiWsLfNed_U-qhUja0&e=>
_______________________________________________
Gate-users mailing list
Gate-users at lists.opengatecollaboration.org<mailto:Gate-users at lists.opengatecollaboration.org>
http://lists.opengatecollaboration.org/mailman/listinfo/gate-users<https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.opengatecollaboration.org_mailman_listinfo_gate-2Dusers&d=DwMGaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=lfXR69GFfS7NT-Wp5HZqbtBDrbYoilDdmNEG7fKW7aM&m=JXkYrD_N3zHhNT53wVMyxPpl-Vu7G4qlA8lefFcef9A&s=jXjPsPRa6e7YuYjPEiMC7JXQ1XND4i9zugV_k4LLHdM&e=>
_______________________________________________
Gate-users mailing list
Gate-users at lists.opengatecollaboration.org<mailto:Gate-users at lists.opengatecollaboration.org>
http://lists.opengatecollaboration.org/mailman/listinfo/gate-users<https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.opengatecollaboration.org_mailman_listinfo_gate-2Dusers&d=DwMGaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=lfXR69GFfS7NT-Wp5HZqbtBDrbYoilDdmNEG7fKW7aM&m=JXkYrD_N3zHhNT53wVMyxPpl-Vu7G4qlA8lefFcef9A&s=jXjPsPRa6e7YuYjPEiMC7JXQ1XND4i9zugV_k4LLHdM&e=>



This message originated from outside of NHSmail. Please do not click links or open attachments unless you recognise the sender and know the content is safe.




************************************************************************************** ******************************

This message may contain confidential information. If you are not the intended recipient please:
i) inform the sender that you have received the message in error before deleting it; and
ii) do not disclose, copy or distribute information in this e-mail or take any action in relation to its content (to do so is strictly prohibited and may be unlawful).
Thank you for your co-operation.

NHSmail is the secure email, collaboration and directory service available for all NHS staff in England. NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and other accredited email services.

For more information and to find out how you can switch visit Joining NHSmail – NHSmail Support<https://urldefense.proofpoint.com/v2/url?u=https-3A__support.nhs.net_article-2Dcategories_joining-2Dnhsmail_&d=DwMGaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=lfXR69GFfS7NT-Wp5HZqbtBDrbYoilDdmNEG7fKW7aM&m=JXkYrD_N3zHhNT53wVMyxPpl-Vu7G4qlA8lefFcef9A&s=M8imf9aq39eFDsb-v-iGGZFZTuiWsLfNed_U-qhUja0&e=>



This message originated from outside of NHSmail. Please do not click links or open attachments unless you recognise the sender and know the content is safe.




************************************************************************************** ******************************

This message may contain confidential information. If you are not the intended recipient please:
i) inform the sender that you have received the message in error before deleting it; and
ii) do not disclose, copy or distribute information in this e-mail or take any action in relation to its content (to do so is strictly prohibited and may be unlawful).
Thank you for your co-operation.

NHSmail is the secure email, collaboration and directory service available for all NHS staff in England. NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and other accredited email services.

For more information and to find out how you can switch visit Joining NHSmail – NHSmail Support<https://urldefense.proofpoint.com/v2/url?u=https-3A__support.nhs.net_article-2Dcategories_joining-2Dnhsmail_&d=DwMGaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=lfXR69GFfS7NT-Wp5HZqbtBDrbYoilDdmNEG7fKW7aM&m=JXkYrD_N3zHhNT53wVMyxPpl-Vu7G4qlA8lefFcef9A&s=M8imf9aq39eFDsb-v-iGGZFZTuiWsLfNed_U-qhUja0&e=>

_______________________________________________
Gate-users mailing list
Gate-users at lists.opengatecollaboration.org<mailto:Gate-users at lists.opengatecollaboration.org>
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.opengatecollaboration.org_mailman_listinfo_gate-2Dusers&d=DwIGaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=lfXR69GFfS7NT-Wp5HZqbtBDrbYoilDdmNEG7fKW7aM&m=JXkYrD_N3zHhNT53wVMyxPpl-Vu7G4qlA8lefFcef9A&s=jXjPsPRa6e7YuYjPEiMC7JXQ1XND4i9zugV_k4LLHdM&e=






This message originated from outside of NHSmail. Please do not click links or open attachments unless you recognise the sender and know the content is safe.




************************************************************************************** ******************************

This message may contain confidential information. If you are not the intended recipient please:
i) inform the sender that you have received the message in error before deleting it; and
ii) do not disclose, copy or distribute information in this e-mail or take any action in relation to its content (to do so is strictly prohibited and may be unlawful).
Thank you for your co-operation.

NHSmail is the secure email, collaboration and directory service available for all NHS staff in England. NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and other accredited email services.

For more information and to find out how you can switch visit Joining NHSmail – NHSmail Support<https://urldefense.proofpoint.com/v2/url?u=https-3A__support.nhs.net_article-2Dcategories_joining-2Dnhsmail_&d=DwMGaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=lfXR69GFfS7NT-Wp5HZqbtBDrbYoilDdmNEG7fKW7aM&m=jFEsVlJw7a8Jr64ONw_NUE9Tky3pwCzd0IBHRkPnmnc&s=huE9psZ_2HQXl7aY6eZE8dwcM0pQaee_q2RMkvX5kd8&e=>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opengatecollaboration.org/pipermail/gate-users/attachments/20220321/0a0c3194/attachment-0001.html>


More information about the Gate-users mailing list