Scripting with MapRT
Mike Tallhamer, DABR
Chief of Medical Physics
AdventHealth Parker, USA
Transcript
We’re going to talk about scripting in MapRT. MapRT is the surface-based planning tool that we’ve heard a lot about, so I won’t belabor that. But it does provide an API for writing your own applications against some of the powerful tools that have been developed within the software. So this is something that we like to explore because when we’re implementing new technologies, we also are implementing new ways to have failures within our process. We don’t go into that lightly. We don’t want to replace current working checks and tools with new processes and new technology without actually thinking about the implications of what’s going to happen. And Vision RT has been gracious enough to actually provide us with an API for those of us who like to tinker and check on these things, a way to delve into the inner workings of the software and write some of our own tools as well.
So with that, disclosures, I am from Colorado, so I have to give Adi a hard time every time. This is what Colorado—don’t thumbs down my pictures already over there, Adi. So, if you come to beautiful Colorado, that’s the advertisement for that. But as far as disclosures, we do have COE agreements with Vision RT, both here in Celebration, as well as Parker, Colorado, where I work.
And at AdventHealth, if you’ve done any of the site visits, you know that we believe in this entire workflow as far as sim, plan, treat, dose, and that we’re now with MapRT trying to bring this information back into planning. So we’re trying to include the information from dose, from treatment, from simulation. We’re trying to marry all of this information into working tools that allow us to do more effective planning at the time of the development phase of a plan, rather than trying to work our way back into it when we find issues at the treatment phase. MapRT allows us to do that. Some of the goals was to go through MapRT, but we’ve heard about MapRT ad nauseum, so I’m going to try to cut some time out, so I don’t get the evil eyes over here from the left. That’s you.
And so we will just do that very quickly. But largely, we’re going to talk about some case studies of how we can use scripting to address some of the concerns of new technology, but also develop some of our own tools to look deeper into what we want to do, how we want to shrink learning curves for our planning teams, and to use these new tools in a more effective way. So obviously, every vendor develops their own platform, but sometimes we are working within our own planning systems as the tools become more dispersed. So we have dosimetry teams that are largely completely remote at many of our institutions, and so working in multiple environments is sometimes difficult, and so can we bridge some of these concerns for those people as they work in these remote environments. And then hopefully at the end, just giving you guys some ideas and some availability of this API and know that it’s out there and some awareness. The tools that you see here are developed with the programming tools that you see along the bottom here. I’m a Python programmer. Anton is a big C# guy. So we’re using the ESAPI scripting within Eclipse, and then I’m developing software outside of the normal products made by the vendors themselves.
So MapRT, Anton’s already given this setup here. So we have two cameras. We have the surface. We won’t go through all of this. I don’t throw the plate on the floor because I don’t like to pay for the plates, so it just disappears from my couch when I do it. We register this in an optical geometry, so we now have this geometry. What this does is allows us to, based on the vendor that your CT has, so if you have a Philips CT or a Siemens CT or GE CT, you are able to basically register the optical geometry to the DICOM geometry. And since we do everything in planning, we do everything in our DICOM coordinate system. You have your convention for the coordinate system, whether that’s IEC or Varian, but we give them the vendor information, and they basically provide the transform from the optical calibration location to the CT DICOM location. That allows us to do all of the cool things that we’ve seen in all of the talks. So in this case, you can marry these surfaces that we’re capturing, and we’ve captured some relatively large surfaces at our institution in Parker. I think the largest individual we captured is around 6’6″, 6’8″ with his arms above his head. So you have a very large field of view that you can operate with. You can check that against machine geometry. So you see here geometries that represent the patient, that represent the machine in different orientations, and then you can go into this clearance mapping software that we’ve seen multiple times. So I won’t belabor that. But you can check plans, and this is largely what a lot of people are talking about doing. We’re checking. We’re doing a plan. We may prospectively start looking into MapRT to do plans. But what are some other tools? This is a very powerful technology, and I think it kind of gets underused with just being a plan checker or maybe a plan starter type of tool. There’s so many more things that we can do with MapRT.
And so to do that, on the left here, we are looking at a simulation procedure. So maybe you want to check a setup before you even CT the patient. So is this going to be a reasonable setup? You can do that in MapRT. You can set isocenters. You’ll see on the left, they’re going to manipulate the isocenter coordinate. They’re going to manipulate the couch coordinate. And this has no plan. We’re just literally checking if we place an isocenter in this location with this patient and this geometry, maybe arms up, maybe they have to be on a steep incline because they have some breathing problems or something like that, can we achieve this if we do a CT in this way? So you’re proactively checking the CT before you run the CT. So you could say, “Okay, this is not going to work. This isn’t going to be good for this isocenter location,” and then you can move on. But if you want to check this with the arms out, currently in the MapRT software, you would have to close this interface, select a different machine orientation, and then come back and do this work over again, making sure that you enter all the same information a second time and not make a mistake. When you watch this video, the person doing this, I’ll give you a clue, is me, and I actually make the mistake just for illustration here. I saw it last night while I was going through this talk. If you want to avoid that, you can actually write your own software. So in this case, we’re trying to use the tools and the input from our therapist to design tools that they’re familiar with. So in this case, on the right is an application that I wrote that has virtual lasers, so you’re using lasers instead of the three coordinate axes, because this is what they’re familiar to see inside of our CT sim room. So the patient surface now has lasers on it. They can move the patient around, get those lasers correct, and then when they check the surface maps, they can use caching. So they can check the isocenter location with the machine in two different geometries, and they can flip back and forth between the geometries. So the tool uses the same orientation that MapRT does. It also uses the same low-resolution to high-resolution maps. You can see when it switches from low resolution to high resolution, you’re using all of the tools that MapRT is providing you, but you’re doing it in a way where you can flip back and forth between different machine geometries very quickly in sim, and you’re not spending a lot of time potentially making fat-fingered mistakes checking the geometries on the plan. So using the API to just develop tools and workflows that make sense to the therapist, not trying to shoehorn your process into an interface that may be new and unfamiliar to them.
The next thing is looking at the surfaces that we grab anyway. So we’re grabbing these surfaces. In this case, this is a very simple, what we’d consider a standard or chip shop SRS. This surface has a sheet that was captured in the surface, and currently, we cannot edit those surfaces. So in this case, we have a false positive on the left and a true positive on the right. The false positive is a collision with the sheet, which we don’t care about. I’ve never injured a sheet, so I’m not super worried about them. But in the true positive, we’re actually colliding with a couch, and so this is something we need to know about. But we need to have ways of teasing out whether or not something is a true concern for the therapist, or is this something we can ignore or something that we can trim out of the surface and maybe get a more updated clearance map for something without maybe the sheet. So we need to address these types of things, and so what we can do is we can look at our SRS process. In this case, intracranial SRS cases we all know are high precision, high dose ablative treatments. At AdventHealth at least, we’re treating these in non-coplanar beam arrangements, typically four to six arcs. But you can do this and address the collision concerns in other ways. You don’t have to have surface-based planning. You can use something like Varian’s HyperArc. And the way Varian HyperArc works is that it artificially limits the solution space by limiting the beam arrangements that you’re allowed to use, so it drastically reduces the geometry you can explore. And then it also enforces a immobilization system that you must use. So they have a collision model based on these parameters, and you must live within that solution space. But if you look at these single isocenter multi-target plans that you see on the left here, this patient was originally treated with a ipsilateral arc arrangement because we knew that this patient was prone to probably be coming back for treatment. So we want to save some of that real estate. We don’t want to go all the way around the patient because that’s what HyperArc tells us to do. And so we chose an ipsilateral arc arrangement, and if you tell me, “I can visualize this. I know that I’m not going to have a collision with this beam arrangement,” that’s great. I could probably do the same thing. But if you look at the bottom picture here, the picture down here, if you can tell me that isocenter two of four, field eight, is going to have a collision in the synchronously optimized plan of 19 fields, you have much better spatial relationship than I do because I can’t visualize that one. And so we need tools that can do this, and we need tools that can do this rapidly because we’re developing these plans, and the last thing we want to do is find out there’s a collision and then have to redo the synchronously optimized plan overnight because the patient’s coming in from a long distance away. And so what the API allows us to do is write tools to integrate this directly into the planning system. So in this case, this patient plan is being checked with a script that Anton wrote with the Sappi scripting. This allows us to check isocenter one, and you can see that isocenter one, fields one through five, everything looks great. But in isocenter two, field eight, we actually have a collision. This means within the planning system, I can identify the collision, make the adjustments, and synchronously optimize this isocenter along with all the other isocenters without having to export all four plans, pull them all up in MapRT, look at all of them, make the change, then put them back into the treatment planning system, and then re-export this to validate it. We’re talking about saving about 30 to 40 minutes per isocenter, where we’re not spending a lot of time shipping data around. We can just pull this information and use the power and leverage the power of MapRT directly in the planning system itself. So it’s an incredibly powerful tool. If we are unsure, we can then pull this information in, and we can explore the solution space and choose the gantry angles right there in the planning system, and the dosimetrist who’s probably working from their couch or walking their dog, honestly, because they’re remote employees, they can do this very quickly, and they can get back to mowing their lawn or whatever they do during the day. And so it’s a great tool. My dosimetrists love it.
But you also have to be careful when you’re using tools that you’re not introducing errors, that you could potentially use the tool in an inappropriate way. So what you’ll see here are two, it’s the same patient, two different isocenters. One’s an SRS isocenter, one is an SBRT lung isocenter. At the top, you will notice as the user zooms in, you will see the isocenter indicator that is outside of the patient’s head, way up here. And I can guarantee you at AdventHealth, that’s not how we treat SRSs. That would be super cool, but that’s not how we do it. We like to see the isocenter inside the cranial vault, and so we can identify that this clearance map is not a valid clearance map. The system will give us a clearance map, but this is probably not a valid clearance map. Something went wrong here, and what we know is that the surface was captured incorrectly. The same patient, same sim session, is the one in the lung incorrect or is it correct? Is it okay? Well, we don’t know because we can’t see that isocenter. We don’t really know. And so we have to be very careful. This is on the old maps. This be where dragons lie. We don’t know what mistakes we can make because we have this fancy new tool, and we need to be able to validate what’s happening here. And at least in this orientation, we cannot tell if we’ve made the same mistake. It is not as blatant as the mistake up here. So we need to have tools that allow us to take the CTs that we take. This is what we want to calculate dose on, and we want to obey those ALARA principles, make sure we’re not CTing all the way down through the patient’s knees because we want to do a collision map or something like that inside of the planning system. But we want to be able to capture our optical surface and then maybe write a tool that merges those two surfaces together that gives us a validation. And so we know that we can validate this for lung SBRT. We have an SRS case. This is a very small volume CT, high resolution, but the patient is much larger, and if we fuse those, we can see that there’s much more patient to be concerned about. The interesting thing is, is we also have to be concerned about the things that we’re concerned about from a non-coplanar geometry all live outside of the CT. So we have CT information, and we have optical information, and all the things we’re worried about colliding with do not exist in our CT. So we have to have some way of marrying these ideas together. We can have issues. That same patient that we just looked at, we can have a much more blatant way of identifying that issue’s going to be a problem. We can take his CT in green, we can take his optical surface in purple, we can fuse them, and we can instantaneously see that there is a problem with isocenter. There’s something that’s not going to go along, which means we cannot trust the clearance map that we’ve generated. And if we don’t have a tool to rectify the situation, we cannot use the clearance information that we have because we can’t generate it because they’re not sitting in the same coordinate frame.
And so what we’ve done is used the scripting, and we can now use scripting to correct these things in different ways. One through just blatant identification, which you’ll see here on the left, and the other by actually correcting the surface and manipulating the surface at the time of planning so that we can generate the proper fusion so that we can actually generate a clearance map that’s correct. So in this case, you can see this is blatantly incorrect. That was easy for the therapist to see at the time of SIM. You can still generate a clearance map on it. That’s absolutely incorrect. And if you were trying to put a beam in one of those locations, probably not a good idea because you’re now going to put the patient at risk. But they were smart enough to say, “Oh, the body’s not on the head, its body’s supposed to be down here.” We can actually go ahead and recapture the surface, which is what they did, and now you can generate a clearance map, an actual clearance map for this patient. Over here, you can see they’re actually correcting it because they did not identify the error at the time of CT SIM, and so they’re just adjusting the optical surface, and then they’ll be able to get this. But you can see how drastically you’ve changed the clearance map here. If you were to put beams over here because you’re like, “Oh man, I’ve got all kinds of area and I’m not going to actually look at this fusion,” you could have actually placed beams through the patient and not known that that was the case because if you just blindly trust the new technology, you don’t have that extra kind of sanity check that’s going on. Here, the differences are much more subtle. So if you switch between with the caching, you can see that there is a collision here and there’s a chance for an additional collision here. So shortening up the arc to here would’ve probably not corrected that problem as well. So they can be subtle, they can be very drastic. Those are just two examples of that.
You can also address things that you like and don’t like about the interface. And I feel awkward saying that because I have Norman sitting here staring at me like, “What do you mean you don’t like the interface?” The interface is great. It’s awesome. But there’s things that you can tweak, and since you have the API, why not tweak it? And so we can look at things like this. So we have these fields are not real fields. These are port film fields. And this is because when you push DICOM, depending on where you place your port or when you put port films in your plan, they are showing up as fields. So you’ll notice that these four fields are actually just the open and shaped ports for these two fields. So these aren’t even real fields in my plan. These are just images. If you look at these, these all have funky names. These are all our imaging fields. And in the API interface, I can just look at these are my imaging fields, and I can see that they’re imaging fields because they say setup, and I know those are my treatment fields, and I don’t have all this extraneous information that I have to kind of sort through to see where did these magic four fields come from and why am I treating my patients with them? You can also identify here we have a bunch of fields, which ones are imaging fields, which ones are treatment fields. These are all static. You could probably say, well, imaging fields are probably on gantry zero, so those are maybe imaging fields. Those might be treatment fields. But over here we can color code them, where our imaging fields are teal and treatment fields are in green. And so you can give an indicator to your dosimetrist of which fields they’re actually worried about because I don’t necessarily need to use this imaging field. I can use the other imaging field, for example. So again, working with your staff, developing information and tools that work.
This is a tool that I’ve just been playing with. We now have these clearance maps, which are super interesting, but they are a kind of a pseudo 5D exploration of the space. So at every 3D position, you have a 2D graph that you can look at. So why not start optimizing plans based on the surface information where I can dynamically search the space as I move in three-dimensional space, what is happening to my 2D clearance map? And so this allows us to cache a bunch of maps using asynchronous calling to MapRT, which is going to do all of the heavy lifting for me, and then lets me explore these data cubes of all the different collisions as I move isocenter around in my target. So if you have very large targets like we saw in the last talk and you want to move isocenter around, you may, like in this case, open up a complete arc around the patient just by moving the isocenter laterally or in for something like that. So now you can dynamically explore that solution space in another dimension. So you’re now looking at, as I move isocenter around, what can I do with my plan? Instead of just saying, “Well, here’s where I chose my isocenter and I hope it works out,” you can just say, “Well, put the isocenter where it gives me the most arc angle that I can use.” And so you can use these tools to develop things like this, which makes your dosimetrist’s job and your therapist’s job much easier because now I can develop a plan that has this nice big long arc that they don’t have to worry about colliding with the patient. You can do additional things. You can extract these surfaces. So I can extract the surface, I can reconstruct the surface using a Poisson filter. That’s for Josh, whoever he’s at. I’m sure he’s smiling somewhere because I said it in the weird French way. The isolation of the surface, you can remove extraneous pieces of the surface, and then you can normalize the surface, which allows us to do interesting things like voxelization. This is a 2D surface that’s in 3D. It’s wrapping in 3D, but then I can voxelate it and create synthetic CTs. And everyone’s like, “Well, why the heck would I want a synthetic CT full of water?” Well, you can do lots of really cool things with them. So we’ve all seen, Aliner T, we can actually move these surfaces directly into our treatment planning systems as contours. We can actually pull in the synthetic CT, and if you pull in the synthetic CT, that means you can do Hounsfield mapping. You can see how you’ve matched up the surface to the shoulder. So if you need to extend your CT, typically they will only let you extend your CT inferior, but now I can actually extend my CT and actually include the rest of the shoulder. So how many times have we cut off an arm or an elbow or a shoulder or something like that and we’re like, “Eh, if we give it eight centimeters, it might be cool.” Now I can just actually add that information into the CT that I missed. We can do things like take out the sheets, take out whatever you want to take out of the surface that you don’t like, and then stick it in another clearance software. This happens to be Rad Formation’s clearance software within the treatment planning system. So I can trim out all the sheets that I want to worry about and stick it into that software and double-check MapRT. I can then take it and push it because it’s in my planning system. I can push it to Aliner T, and now I have elbows when I didn’t CT my elbows. I have hands when I didn’t CT up through the face and get my hands. I can, if I really wanted to collide with his knees, I could check out his knees. But I can use this information with postural video now to set up the entire posture from the soles of their feet to the top of their head without having to CT any of that information. And all this is all just the power of using the surfaces that MapRT gives us.
In summary, you have a basic introduction to MapRT. Everybody’s heard about MapRT. I think it’s one of the coolest things we get to play with in our clinics. We’ve seen some case studies of some of the things you can do with this data, play with it, go out, poke with it, do what you want. If you have MapRT, I really encourage anyone that has any propensity to program to really get in on the data and start playing with it. And then we highlighted how scripting can be used to leverage some of these new tools in new and kind of interesting ways and make things much more efficient for our dosimetrists. And hopefully, at least for this group, I hope you guys have at least seen something that spurs your interest and your curiosity, and you can go ahead and do that. Just to remember, Colorado’s way cooler than Florida. It’s not this hot or humid there. Just sales pitch, come out and see me.
*This transcript has been AI-generated. Contact us at secretary@sgrt.org if there are any issues.
