Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load RT ion plans #25

Closed
cpinter opened this issue Sep 15, 2017 · 71 comments
Closed

Load RT ion plans #25

cpinter opened this issue Sep 15, 2017 · 71 comments

Comments

@cpinter
Copy link
Member

cpinter commented Sep 15, 2017

Example datasets:

  • HIT-C12-cubePhantom
  • HIT-H1-head

Migrated from https://app.assembla.com/spaces/slicerrt/tickets/419-load-rt-ion-plans/details

@cpinter cpinter added this to the Future milestone Sep 15, 2017
@cpinter cpinter modified the milestones: Future, SlicerRT 1.0 Feb 16, 2019
@cpinter
Copy link
Member Author

cpinter commented Feb 16, 2019

An additional dataset and contributor has arisen from the Slicer community. We will attempt to add the ion plan support together. See
https://discourse.slicer.org/t/beam-data-in-slicer-rt-not-loading/5718/12

cpinter added a commit to cpinter/SlicerRT that referenced this issue Feb 16, 2019
cpinter added a commit to cpinter/SlicerRT that referenced this issue Feb 16, 2019
@cpinter
Copy link
Member Author

cpinter commented Feb 16, 2019

I have created a branch where I added placeholders for the RT ion plan import/load part.

To start, you will need to

  1. Have a GitHub account, fork the SlicerRT repository (probably easier to clone my fork because it has the branch), clone it to your computer, switch to the 25-add-ion-plan-support branch
  2. Build Slicer. Instructions are here. The instructions are very good and thorough. People still tend to have difficulty with it, but mainly because they miss some information (for example on Windows you need to choose a short path like c:\d\S4D). So please pay very close attention.
  3. Build SlicerRT. Some instructions here
  4. Please contact me if you have any issues (comment here or we can video chat if you need closer guidance)

Thank you so much and good luck!

@samshyllon
Copy link

thanks for laying out the steps for me,
I look forward to attempting to add the ion plan support.

@cpinter
Copy link
Member Author

cpinter commented Feb 18, 2019

Excellent! Please let me know if you encounter any issue :)

@samshyllon
Copy link

I have gotten as far as trying the build stage, and I am currently getting the error shown below (towards the end of the Cmake report listed below), am not sure how to proceed. any assistance would be much appreciated.

Setting C++ standard
Setting C++ standard - C++11
The C compiler identification is MSVC 19.0.24215.1
The CXX compiler identification is MSVC 19.0.24215.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Check if the system is big endian
Searching 16 bit integer
Looking for sys/types.h
Looking for sys/types.h - found
Looking for stdint.h
Looking for stdint.h - found
Looking for stddef.h
Looking for stddef.h - found
Check size of unsigned short
Check size of unsigned short - done
Using unsigned short
Check if the system is big endian - little endian
Found Subversion: C:/Program Files/TortoiseSVN/bin/svn.exe (found version "1.11.1")
Found Git: D:/D/Git/cmd/git.exe
CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
Could NOT find Patch (missing: Patch_EXECUTABLE)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
CMake/FindPatch.cmake:67 (find_package_handle_standard_args)
CMakeLists.txt:156 (find_package)

Configuring incomplete, errors occurred!
See also "D:/D/S4D/CMakeFiles/CMakeOutput.log".

@cpinter
Copy link
Member Author

cpinter commented Feb 19, 2019

You will need a newer CMake. Please download the latest stable.

@lassoan
Copy link
Member

lassoan commented Feb 19, 2019

I think patch.exe is not bundled with CMake but with git. Probably patch.exe is not found because you have not installed git in standard location.

See how to specify patch.exe location here: https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build_Instructions/Prerequisites#Common_Prerequisites_2

@samshyllon
Copy link

I have succesfully configured and generated using Cmake, but i am having trouble understanding the steps that I need to take using Visual Studio in order to continue the build process. For example giving the scope of what I am trying to do, should I use release or debug mode?

@cpinter
Copy link
Member Author

cpinter commented Feb 19, 2019

In any case, I think a new CMake will be needed, since the paths show a version of 3.7, and although Slicer specifies a minimum of 3.5, I think we need a newer one.

@cpinter
Copy link
Member Author

cpinter commented Feb 19, 2019

Open Slicer.sln, choose Debug mode (I see in your build path that you wanted debug build, and I think you may need it for the development), and start build.

@samshyllon
Copy link

yeah i downloaded the newest stable release of CMake

@samshyllon
Copy link

the build has been completed with a message stating "52 succeeded, 4 failed 3 skipped"
I am not sure if this is the expected result ?

However i am having trouble locating the Slicer.exe file mentioned in the Documentation, it is not in the Slicer-build folder, does this mean something as gone wrong or is there a work around.

@cpinter
Copy link
Member Author

cpinter commented Feb 20, 2019

There should be 0 failed. Please check out the error list and tell us at least the first one. Thanks!

@samshyllon
Copy link

i cant find the error list, but i realised that i selected the wrong complier x32 instead of x64, so I have restarted the build with the correct complier, will let you know how it goes

@cpinter
Copy link
Member Author

cpinter commented Feb 20, 2019

The error list is a window in Visual Studio. Please find it, you will need it later.
Also you can get the build log at ...\S4D\x64\Debug\Slicer\Slicer.log or ...\S4D\Testing\Temporary

@samshyllon
Copy link

After retrying the build, this was the output, ended up with 55 succeeded and 1 fail

image

image

@cpinter
Copy link
Member Author

cpinter commented Feb 20, 2019

Interesting. These errors do not indicate any error with actual builds. Does the file ...S4D\Slicer-build\Slicer.exe exist? If so, then consider the build successful.

@samshyllon
Copy link

yes it does i was able to run slicer

@cpinter
Copy link
Member Author

cpinter commented Feb 20, 2019

Excellent! One hard part is done! Keep us posted about the next steps and I'll help if I can.

@samshyllon
Copy link

i have tried to build Slicer RT a per the instructions and i got this message
image

however when i check the error list there is nothing
image

So i am assuming the Slicer RT build was succesful, but when i open Slicer, the Radiotherapy module is not vissible, is there an extrastep required for that?

@cpinter
Copy link
Member Author

cpinter commented Feb 21, 2019

Your screenshot says 15 errors. Can you please send me at least the first few? Thanks.

@samshyllon
Copy link

I tried to run the build process again to generate the error list but this time there was no errors
image

However heres the error list showing the warnings:
image

@cpinter
Copy link
Member Author

cpinter commented Feb 21, 2019

Warnings are fine. This looks good, thanks!

Next is to run Slicer in Debug mode with SlicerRT.

  1. You'll need to add the three build directories of SlicerRT to the Additional module paths list in Application settings. For example: C:\d\_Extensions\SlicerRT_R\inner-build\lib\Slicer-4.11\qt-loadable-modules\Release, C:\d\_Extensions\SlicerRT_R\inner-build\lib\Slicer-4.11\qt-scripted-modules, C:\d\_Extensions\SlicerRT_R\inner-build\lib\Slicer-4.11\cli-modules\Release
  2. Start Visual Studio with SlicerRT environment to enable debugging in SlicerRT if necessary, for example: .\S4D\Slicer-build\Slicer.exe --VisualStudio --launcher-no-splash

@samshyllon
Copy link

I have been able to run slicer with the SlicerRT extenstion and evrything works as expected.
I believe the next step is to begin modifying the code to include ion RT beams, is this to be done within the SlicerRT source directory?

@cpinter
Copy link
Member Author

cpinter commented Feb 24, 2019

Great, you're making fast progress! Yes the next step will be the code. Please refer to the second part of my descriprion above, with the bullet points. You'll need to clone the branch to your computer, check out my commit so see where these parts need to be added, and try to fill the gaps. Please ask away if you have any questions!

cpinter pushed a commit to cpinter/SlicerRT that referenced this issue Oct 22, 2019
followed the direction listed by cpinter to modify :
vtkSlicerDicomRtImportExportModuleLogic
vtkSlicerDicomRtReader

Re SlicerRt#25
@cpinter
Copy link
Member Author

cpinter commented Oct 22, 2019

@MichaelColonel I rebased the branch to the master, fixed the errors and the style, and pushed the new branch here: https://github.com/cpinter/SlicerRT/tree/25-add-ion-plan-support

Please fork SlicerRT, add my fork as a remote, check out the branch, then do your changes, and push the updated branch to your remote. Please let me know if you have any questions.

cpinter pushed a commit to cpinter/SlicerRT that referenced this issue Oct 22, 2019
followed the direction listed by cpinter to modify :
vtkSlicerDicomRtImportExportModuleLogic
vtkSlicerDicomRtReader

Re SlicerRt#25
@MichaelColonel
Copy link
Collaborator

MichaelColonel commented Oct 23, 2019

@cpinter I forked and added remote
git remote -v
origin https://github.com/MichaelColonel/SlicerRT.git (fetch)
origin https://github.com/MichaelColonel/SlicerRT.git (push)
upstream https://github.com/cpinter/SlicerRT.git (fetch)
upstream https://github.com/cpinter/SlicerRT.git (push)

I'm going to use testing branch, and only after testing i will merge and push the results.

I would like to start with implementation of MLC support, pretending there is only one mutileaf collimator per beam.

@cpinter
Copy link
Member Author

cpinter commented Oct 23, 2019

Sounds Great! Before you start implementing MLCs can we please agree on the way it will be done? Some MLC support was added in SlicerRT before, but it never really worked.

Could we tackle the MLC work separately in its own issue please? I'll add a comment on what is there and what I would start with if I had time working on it now. It's #115

@MichaelColonel
Copy link
Collaborator

Bare minimum of ion plan support in vtkSlicerDicomRtReader.

For a possible future setup with a fixed beam in our institute i'm going to implement some sort of a minimum support for rt ion plan and rt plan (since both have many common elements). Major part of the code that had been already done remains (with minimum refactoring of BeamEntry class). Public methods of vtkSlicerDicomRtReader will be the the same.

As a template:

  1. Fraction sequence (partially)
    1.1. Referenced beam sequence within fraction sequence (partially)
    https://github.com/MichaelColonel/SlicerRT/blob/25-add-ion-plan-support/DicomRtImportExport/Logic/vtkSlicerDicomRtReader.cxx#L116-#L147

  2. Ion beam sequence with control point sequence (MLC, RS, primary particle info).
    https://github.com/MichaelColonel/SlicerRT/blob/25-add-ion-plan-support/DicomRtImportExport/Logic/vtkSlicerDicomRtReader.cxx#L183-#L229

  3. Control point with info about MLC position, binary range shifter setting, energy of primary particle.
    https://github.com/MichaelColonel/SlicerRT/blob/25-add-ion-plan-support/DicomRtImportExport/Logic/vtkSlicerDicomRtReader.cxx#L149-#L181

Some members from BeamEntry class will go to the ControlPointEntry class.

What do you think about that structure?

@cpinter
Copy link
Member Author

cpinter commented Dec 7, 2019

Thanks again for working on this and to ask our opinion! It looks great.

Just one question: I don't quite understand the ReferencedBeamEntry structure. The fractions use the same beams but with different weights, and this is why we need to reference them like this?

Also could you please run the automated tests to see if your changes break any existing use cases? Just run this from command line from the inner-build folder:
ctest -C Release

@MichaelColonel
Copy link
Collaborator

Referenced beam sequence is used only for correct order order of beams from fraction to fraction, but any critique is useful.

I have run tests on my local PC using master branch after MLC support had been added:

The following tests FAILED:
12 - py_DicomRtImportTest (Failed)
18 - vtkSlicerDoseVolumeHistogramModuleLogicTest_EclipseProstate_Base (Failed)
19 - vtkSlicerDoseVolumeHistogramModuleLogicTest_EclipseProstate_CERR (Failed)
20 - vtkSlicerDoseVolumeHistogramModuleLogicTest_EclipseEnt_CERR (Failed)
21 - vtkSlicerDoseVolumeHistogramModuleLogicTest_EclipseProstate_Eclipse (Failed)
22 - vtkSlicerDoseVolumeHistogramModuleLogicTest_EclipseEnt_Eclipse (Failed)
23 - vtkSlicerDoseVolumeHistogramModuleLogicTest_EclipseProstate_CERR_AutomaticOversampling (Failed)
24 - vtkSlicerDoseVolumeHistogramModuleLogicTest_EclipseEnt_CERR_AutomaticOversampling (Failed)
25 - vtkSlicerDoseVolumeHistogramModuleLogicTest_EclipseProstate_Eclipse_AutomaticOversampling (Failed)
26 - vtkSlicerDoseVolumeHistogramModuleLogicTest_EclipseEnt_Eclipse_AutomaticOversampling (Failed)
27 - vtkSlicerDoseVolumeHistogramModuleLogicTest_DoseSurfaceHistogram_EclipseEnt_Base_Inside (Failed)
28 - vtkSlicerDoseVolumeHistogramModuleLogicTest_DoseSurfaceHistogram_EclipseEnt_Base_Outside (Failed)
29 - vtkSlicerDoseVolumeHistogramModuleLogicTest_DoseSurfaceHistogram_EclipseProstate_Base_Inside (Failed)
30 - vtkSlicerDoseVolumeHistogramModuleLogicTest_DoseSurfaceHistogram_EclipseProstate_Base_Outside (Failed)
37 - vtkSlicerSegmentMorphologyModuleLogicTest_EclipseProstate_Expand (Failed)
38 - vtkSlicerSegmentMorphologyModuleLogicTest_EclipseProstate_Shrink (Failed)
39 - vtkSlicerSegmentMorphologyModuleLogicTest_EclipseProstate_Union (Failed)
40 - vtkSlicerSegmentMorphologyModuleLogicTest_EclipseProstate_Intersect (Failed)
41 - vtkSlicerSegmentMorphologyModuleLogicTest_EclipseProstate_Subtract (Failed)
42 - vtkSlicerSegmentMorphologyModuleLogicTest_EclipseProstate_Intersect_ApplyTransform (Failed)
45 - vtkSlicerSegmentComparisonModuleLogicTest_EclipseProstate_Base (Failed)
46 - vtkSlicerSegmentComparisonModuleLogicTest_EclipseProstate_SameInput (Failed)
47 - vtkSlicerSegmentComparisonModuleLogicTest_EclipseProstate_Transformed (Failed)

@Sunderlandkyl
Copy link
Collaborator

Sunderlandkyl commented Dec 9, 2019

Just FYI, the vtkSlicerSegmentMorphologyModuleLogicTest and vtkSlicerDoseVolumeHistogramModuleLogicTest failures are due to some changes loading Segmentations. I'm working to fix the problem.

They shouldn't be related to the MLC changes.

@cpinter
Copy link
Member Author

cpinter commented Dec 9, 2019

Thanks, @Sunderlandkyl !

@MichaelColonel I asked because if it's only for referencing a beam from within the class, then the BeamEntry pointer can be used. If it's for referencing from outside the class, then the beam number is enough. I saw the vector<pair<double, int> > and thought the double meant the weight of the beam in the fraction ("Cumulative Meterset Weight (300A,0134)"). So if additional information is needed other than identifying the beam, then this reference structure has a place, but otherwise it seems redundant.

@MichaelColonel
Copy link
Collaborator

It looks like for correct ion plan support i need to add a MRML node for ion beam, because some elements have additional parameters. SAD becomes VSAD with x and y component, scan mode without jaws and MLC, etc.

What is a better way?

  1. class vtkMRMLRTIonBeamNode : public vtkMRMLModelNode
    or
  2. class vtkMRMLRTIonBeamNode : public vtkMRMLRTBeamNode

When loading beams for ion plan, additional code will be added to LoadExternalBeamPlan method to check if RTPlan or RTIonPlan have been loaded.

bool vtkSlicerDicomRtImportExportModuleLogic::vtkInternal::LoadExternalBeamPlan(

@cpinter
Copy link
Member Author

cpinter commented Dec 16, 2019

Again, thanks for checking with us!

Given that many beam features are the same in an ion beam as in the original beam class (geometry etc.), and that we should be able to identify all beams by doing a type check against the beam class, I think the ion beam should definitely be a subclass of the beam, so option 2.

@MichaelColonel
Copy link
Collaborator

HIT examples from SlicerRtData all have modulated ion beam, with scan spot position map, and i am going to calculate rectangle borders of the position map just like jaws to draw the simplest beam border.

Do you have any other suggestions how to make a correct poly data for beam visualization?

@cpinter
Copy link
Member Author

cpinter commented Dec 20, 2019

Sorry I'm not sure what the question is exactly. Also can you please briefly describe what are scan spot position maps? Thank you!

@gregsharp
Copy link
Member

The spot positions are for a scanned (rather than passively scattered) proton beam. I think that the enclosing rectangle sounds fine. Maybe increase it by the beam sigma, otherwise a single spot would show up as just a point. Otherwise you can try to create a circle for each spot (expanded by sigma) and make their union?

@MichaelColonel
Copy link
Collaborator

WIP

RTIonPlan_ControlPoints_Test

@cpinter I agree, it's not the best way to describe a problem, next time i will try be more accurate!

For testing i use https://discourse.slicer.org/t/beam-data-in-slicer-rt-not-loading/5718/10 data. Each control point point is loaded as a separate beam, some parameters for control points were taken from Plastimatch.

@gregsharp rectangle enclosing is enough in my case, and i will think about creating union of scanning spots, but number of scan spots can be several hundreds for each control point of modulated ion beam.

PS. There is a mention in code about beams group nodes. Is it a concept for the future?

//TODO: Multiple isocenters per plan is not yet supported. Will be part of the beams group nodes developed later
.

@gregsharp
Copy link
Member

@MichaelColonel First of all, this looks awesome. Outstanding work! Thank you so much for your contribution to the community.

For clinical beams, enclosing rectangle is perfectly great. Early adopters will be physicists for whom single spot plans are common, and yes, well, you know the rest.

Yes I agree, the mention in the code is future work.

@mdsainth
Copy link

mdsainth commented Jan 5, 2021

Warnings are fine. This looks good, thanks!

Next is to run Slicer in Debug mode with SlicerRT.

1. You'll need to add the three build directories of SlicerRT to the Additional module paths list in Application settings. For example: C:\d\_Extensions\SlicerRT_R\inner-build\lib\Slicer-4.11\qt-loadable-modules\Release, C:\d\_Extensions\SlicerRT_R\inner-build\lib\Slicer-4.11\qt-scripted-modules, C:\d\_Extensions\SlicerRT_R\inner-build\lib\Slicer-4.11\cli-modules\Release

2. Start Visual Studio with SlicerRT environment to enable debugging in SlicerRT if necessary, for example: .\S4D\Slicer-build\Slicer.exe --VisualStudio --launcher-no-splash

@cpinter I got to this point (finally). So I was able to build and run 3D slicer. exe and building now the slicerRT extension in visual studio. But I am not sure how point 1 needs to be executed. What do you mean with the additional module paths? Do I need to copy it inside the folder of my slicer.exe?

Thanks for your response!

@cpinter
Copy link
Member Author

cpinter commented Jan 7, 2021

You need to add the fodlers in Application Settings / Additional module paths, either by clicking Add or drag&drop.

@mdsainth
Copy link

mdsainth commented Jan 7, 2021

Thanks you very much for your reply.
I added folders in module paths but I am encountering errors when opening Slicer the following comment occurs

When loading module "BatchStructureSetConversion" , the dependency "DicomRtImportExport" failed to be loaded.
When loading module "DvhComparison" , the dependency "DoseVolumeHistogram" failed to be loaded.
When loading module "IGRTWorkflow_SelfTest" , the dependency "DicomRtImportExport" failed to be loaded.
Algorithm vtkCurveGenerator(000002012B7D51B0) returned failure for request: vtkInformation (0000020120878C70)
Debug: Off
Modified Time: 190963
Reference Count: 1
Registered Events: (none)
Request: REQUEST_DATA
FORWARD_DIRECTION: 0
ALGORITHM_AFTER_FORWARD: 1
FROM_OUTPUT_PORT: 0
Switch to module: "Welcome"

@cpinter
Copy link
Member Author

cpinter commented Jan 7, 2021

I have some ideas what the problem could be but I'm missing the context and would like to make sure your question is resolved in the right place. Is this related to loading RT ion plans in some way? Am I forgetting something? If this is a new issue then I suggest opening a new topic on the https://discourse.slicer.org/ forum.

@mdsainth
Copy link

mdsainth commented Jan 7, 2021

Thanks for your prompt reply.
Yes I would like to load RT ion plans (I did not succeed using SlicerRT and then I read and followed all suggestions in this topic). In the end (I think) i succeeded in building Slicer.exe and opening it worked fine. Then I refered to the module path (which I built according to the Build SlicerRT instructions) and as you pointed out in the previous comment. Not sure now why I get this error (PS: in Visual Studio I did not get any error when building SlicerRT).
In attachment you can see some screenshots if that would be helpfull
Slicer_command
ModuleSetting_errors

@cpinter
Copy link
Member Author

cpinter commented Jan 7, 2021

This issue here is about implementing the feature for loading ion plans. Until it is closed it is not available in the SlicerRT release. Please either give it a bit more time until we close the issue, or build the topic branch instead of SlicerRT master. For using a manually built extension please ask on the forum so that here we can focus on the development of the feature.

@cpinter
Copy link
Member Author

cpinter commented Jan 7, 2021

@mdsainth Update: Sorry, I just realilized that the comments and commits were one year older than I thought - the typical new year confusion :)
So this feature should be in the SlicerRT release. Pleas install the latest Slicer preview version, install SlicerRT from the extension manager, and try.

In any case, about questions please use the forum. Here on GitHub we mainly manage the development. Thanks!

@mdsainth
Copy link

mdsainth commented Jan 7, 2021

Thanks! Works perfectly 👍

@MichaelColonel
Copy link
Collaborator

The spot positions are for a scanned (rather than passively scattered) proton beam. I think that the enclosing rectangle sounds fine. Maybe increase it by the beam sigma, otherwise a single spot would show up as just a point. Otherwise you can try to create a circle for each spot (expanded by sigma) and make their union?

I'm making a better visualization of the scanning beam, and i have a question about how to do better.

Here is a screenshot of HIT test data where scan spot position map has more than one segment (an eye and a smile). Now i use vtkAppendPolyData filter to show all single spots. Do you know any way to unite correctly spots from each segment? The vtkBooleanOperationPolyDataFilter will unite all the spots into the one big blob.

image

@lassoan
Copy link
Member

lassoan commented Mar 1, 2021

vtkBooleanOperationPolyDataFilter often fails randomly for simple, completely valid inputs. I would not rely on it.

vtkbool library can be used as an alternative. While it is not perfect, it works much better than vtkBooleanOperationPolyDataFilter and it has an active, dedicated maintainer, so there is someone to report errors to or ask advice from.

We have not yet integrated vtkbool into Slicer core, but initial tests look promising, so if VTK9 upgrade in Slicer will be complete then we will make it available in the Slicer core. For now, it is built as part of Sandbox extension. See some more details here: https://discourse.slicer.org/t/new-experimental-feature-boolean-operations-union-intersection-difference-on-meshes/16048/7

@cpinter
Copy link
Member Author

cpinter commented Oct 14, 2022

Ion plan loading is implemented. Improvements and bugs can be discussed in new tickets as needed.

@cpinter cpinter closed this as completed Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants