Hello all,
pylinac version 1.1 is now out. Changes are listed below:
Hello James,
Happy new year !
James, I would like to do live analysis each 5-10 seconde I get the last .bin file
def do_something(sc):
print(“Analysis Log…”)
start
#filelist = os.listdir(os.getcwd())
#filelist = filter(lambda x: not os.path.isdir(x), filelist)
#newest = max(filelist, key=lambda x: os.stat(x).st_mtime)
path = “Z:\TrajectoryLog\Treatment”
dst = “X:\QA\Linacs\LinacLA1\Logs”
os.chdir(path)
f = max(glob.iglob(‘*.bin’), key=os.path.getctime)
if “KV” in f:
print(f + “is kv file”)
elif “MV” in f:
print(f + “is MV file”)
else:
log = MachineLog(f)
print(f)
log.report_basic_parameters()
#log.fluence.actual.calc_map(resolution=0.1)
#log.fluence.actual.plot_map()
#log.fluence.expected.plot_map()
#log.fluence.gamma.plot_map()
#newest_txt = max(glob.iglob(‘*.txt’), key=os.path.getctime)
#shutil.move(path, dst)
“”"
if gamma_pct < 0.99: # How I can get gamma_pct from Log Analysis Module ??
server = smtplib.SMTP(‘smtp.gmail.com:587’)
server.ehlo()
server.starttls()
msg = “\r\n”.join([
“From: rachid.boucenna@gmail.com”,
“To: rachid.boucenna@gmail.com”,
“Subject: Just a message”,
“”,
“Why, oh why”
])
“”"
sc.enter(5, 1, do_something, (sc,))
s.enter(5, 1, do_something, (s,))
s.run()
But I would like to do an condition on gamma_pct value to get an email or to have a alerte.
Could you please help me to get gamma_pct value
Rachid,
- To get the gamma percent of the log, use the ``pass_prcnt’’ property of the gamma. Docs here. E.g.
`
load logs and do stuff
log.fluence.gamma.calc_map()
log.fluence.gamma.pass_prcnt # <----------
`
- To watch a directory, consider using the script I’ve already written. This will watch a directory for you and analyze anything pylinac can. It doesn’t do everything you want (like move files elsewhere or send an email), but it’s a start. I’d use/hack that first if you can (link to the script). If you still want to roll your own, I’d strongly urge you to use a file-watching library. For example I use watchdog and it allows an easy, OO-based way to watch and process files that move in and out of directories. Don’t reinvent the wheel if you don’t have to.
Let me know if you get it working! I’d incorporate any good parts into the watcher script.
James
Ok Thank you James, I will test the file watching library
James,
the watcher.py is very good idea.
But at the moment after module name correction pylinac.xxxx replace by pylinac, the script don’t reconized the field.bin file.
" was added but was not deemed a file to be analyzed* ok for kv_MV_CBCT file, but I am sur we have the same message for field file.
Rachid,
I’m sorry but I don’t understand what’s going on. Can you give me a screenshot or error traceback or a link to a file where I could reproduce the problem? Thanks
James