Slicer3:UIDesign:WorkingProblems:BCAnalysis:Dynamic

From Slicer Wiki
Jump to: navigation, search
Home < Slicer3:UIDesign:WorkingProblems:BCAnalysis:Dynamic

Back to Project Overview

Perfusion Analysis for Breast Cancer

Goal

Goal is to accommodate basic RECIST assessment for breast cancer (Response Evaluation Criteria In Solid Tumors). (RECIST is a set of published rules that define when cancer patients improve ("respond"), stay the same ("stable") or worsen ("progression") during treatments).

  • Determine features that currently exist in Slicer
  • Develop features that don't
  • Provide a framework that knits features together in a comfortable workflow.

Perfusion Analysis Workflow

  • Visualize the dataset dynamically
  • Specify an ROI that includes tumor and apply to all timepoints Question: ROI or VOI? (either -- if slice, must be same slice)
  • Plot contrast dilution curve
    • show time to peak in tumor
  • Specify an ROI that includes blood pool and apply to all timepoints Question: again, ROI or VOI?
  • Plot contrast dilution curve for this (on same graph)
    • show time to peak in blood pool
  • show transit time (distance between peaks in each plot)
  • save out timepoints ( Intensity(t) for each ROI -- include multiple tumors if desired)

First experiment

Below is a screenshot of first perfusion dataset. The dataset contains upward of 900 volumes. Loading the original DICOM images took a very long time; Junichi converted these images to nrrd format, but the loading still takes prohibitively long, and interacting is also very slow.


08/20/2009 meeting with Ron: Jeff will provide:

  • indication (screen shot) of the blood pool VOI to use
  • indication of the mapping between dicom files and slice, timepoint, channel to use during the load experiments
  • paper describing kinetic curve fitting, based on Toft's model extracellular volume fraction and permeability used by Kasia Macura at JHU.

building 4DImage and 4DAnalysis modules:

From Jeff -- first dataset contains 15 timepoints, each 256x256x63 -- so we've found a bug in either:

  • the timeseries loader in Slicer (probably in the thing that parses dicom header), or
  • we have a malformed DICOM header.

This is causing Slicer to load 63x15 volumes containing a single 256x256 slice. I'll dig in to this today and see what's going on. Shouldn't be too hard to find. Junichi has given me a DCE dataset that loads properly for comparison.

  • Fixed with changes to automatic parsing of DICOM data. Will stub out, check into svn today, and ask Junichi to test it on his datasets -- make sure it works for all cases before exposing in the repository.

The 4D Image analysis package is required for plotting -- need to expose this in Slicer3/Modules/CMakelists.txt file. Discussed with Junichi about possibility of having both 4DImage and 4DImageAnalysis modules exposed in the trunk for the demo; he sees no problem in this *without* the Scipy modeling part exposed. Too challenging now to build python/numpy/scipy by default.

CHANGES TO CODE & BUILD INFRASTRUCTURE to get FourDImage and FourDAnalysis to compile

  • Exposed FourDImage and FourDAnalysis modules in Slicer3/Modules/CMakelists.txt
  • Changed the code in vtkKWPlotGraph.cxx: replaced finite() function is replaced code that conforms to ISO C++/2003 so it would compile on win32
  • Changed some code in vtkFourDAnalysisLogic.cxx because there is no equivalent to the isnormal() function. Instead, just used the same def for finite()... but this will not test for subnormal floats.
  • Had to move pyconfig.h to Slicer3-lib/python-build/Include so FourDAnalysis module could compile (couldn't find this file, included by <Python.h> for some reason (maybe something wrong with my python install on win32.
  • Building in Debug mode rather than release creates python25_d.dll. The compile in genlib only builds python in release mode. Try changing the mode to ::$VTK_BUILD_TYPE and copy the python25_d.dll (as well as python25.dll to the python-build/Lib dir) in genlib.tcl...
      • Something still looking to link with python25.dll (?) compiling python in debug mode does not generate the release libarary. So, next thing to try is running the python build twice, once in release, once in debug. Sloppy, but then we have both. made this change in genlib.tcl, and did the file copy of both the dlls.
      • then, in subsequent call in getbuildtest.tcl, had to put a catch around the python lib file copy -- and add a copy of the debug library too. I think the result is that both debug and release python libs will be present; the particular slicer build will just link with the required python lib. There's certainly a better way, but I'll leave that to experts to improve if this appears to work.
      • FourDAnalysis module still couldn't ind python25_d.lib. in Slicer_variables.tcl changed the way PYTHON_LIB is set:
       set ::PYTHON_TEST_FILE $::PYTHON_BIN_DIR/PCbuild/python.exe
       if { $::VTK_BUILD_TYPE == "Release" }  {
           set ::PYTHON_LIB $::PYTHON_BIN_DIR/PCbuild/python25.lib
       } elseif { $::VTK_BUILD_TYPE == "Debug" } {
           set ::PYTHON_LIB $::PYTHON_BIN_DIR/PCbuild/python25_d.lib
       } elseif { $::VTK_BUILD_TYPE == "RelWithDebInfo" } {
           set ::PYTHON_LIB $::PYTHON_BIN_DIR/PCbuild/python25.lib
       } else {
           puts stderr "Could not match build type to set python lib \"$::VTK_BUILD_TYPE\"."
       }
       puts "Set python lib = $::PYTHON_LIB"
       set ::PYTHON_INCLUDE $::PYTHON_BIN_DIR/include

SCIPY for Slicer and python2.5 on win32

  • Had to include scipy binary -- downloaded from here. Installed this library in my non-slicer python installation (the installer didn't give me option to put it anywhere else). Then did a copy of files to Slicer installation. This will take some debugging I think.
    • C:/Python25/Lib/site-packages/scipy --> (path to slicer)/Slicer3-lib/python-build/Lib/site-packages/.
    • C:/Python25/Lib/site-packages/README.txt --> (path to slicer)/Slicer3-lib/python-build/Lib/site-packages/.
    • C:/Python25/Lib/site-packages/scipy-0.6.0-py2.5.egg-info --> (path to slicer)/Slicer3-lib/python-build/Lib/site-packages/.
    • new files in C:/Python25/Lib/ --> (path to slicer)/Slicer3-lib/python-build/Lib/.
    • new files in C:/Python25/Lib/encodings --> (path to slicer)/Slicer3-lib/python-build/Lib/encodings/.

now let's see how that works.

Started slicer, opened python console, typed import scipy and got the following error:

Traceback (most recent call last):
 File "<console>", line 1, in <module>
 File "C:\Python25\Lib\site-packages\scipy\__init__.py", line 25, in <module>
   from numpy import show_config as show_numpy_config
ImportError: No module named numpy

Looks like numpy didn't install correctly for me using the genlib.tcl script.

NUMPY for Slicer and python2.5 on win32

So let's try grabbing the precompiled binary for numpy... from here.

    • C:/Python25/Scripts/* --> (path to slicer)/Slicer3-lib/python-build/Lib/. (not sure about this one...)
    • C:/Python25/Lib/site-packages/numpy --> (path to slicer)/Slicer3-lib/python-build/Lib/site-packages/.
    • C:/Python25/Lib/site-packages/numpy-1.3.0-pyp2.5.egg-info --> (path to slicer)/Slicer3-lib/python-build/Lib/site-packages/.

Started slicer, opened python console, typed import numpy and import scipy and seemed to get the right behavior.

First experiment

  • Load pre-treatment perfusion.
  • Save scene PreTreatmentPerfusion.mrml
  • Reload & see if volumeBundleNode reloads properly.
    • BUG: looks like timeseries bundles did not get saved; FourDAnalysis module requires user to select a timeseries Bundle for plotting; none exists in the reloaded scene. Looks like FourDImage contains methods to serialize the mrml node, so maybe save was not good. Try again.
  • Segment tumor & bloodpool
    • in editor, select either Volname_Display0 or Volname_Display1 as src volume for label map -- Select Volname_Display1 (some label map out of range error occurs with Volname_Display0 for some reason... or maybe it's just an error enocuntered for the first label map created. don't know)
    • do not use white as a label (plotting can't display white, so displays black label for white label (can be confusing)
  • Save scene PreTreatmentPerfusionWithSegmentation.mrml
  • Load just post-treatment perfusion
  • Segment tumor & bloodpool
  • Save scene PostTreatmentPerfusionWithSegmentation.mrml
  • Reload PreTreatmentPerfusionWithSegmentation.mrml
  • Perform plotting on pre-treatment
    • in FourDAnalysis, Mask = label map
  • Perform Tofts Kinetic Model analysis on pre-treatment
    • Select Tofts2 script (ignores plasma volume parameter, simpler than tofts)
    • for AIF (c) arterial input function value (in multicolumn list), select the LUT number of the color of the blood pool
    • for curve fitting, specify the color of the tumor label.

Wind up with a crash here; null pointer v:

PyObject *
PyInt_FromLong(long ival)
{ register PyIntObject *v;
#if NSMALLNEGINTS + NSMALLPOSINTS > 0
if (-NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS) {
 v = small_ints[ival + NSMALLNEGINTS];
 Py_INCREF(v);

The call stack is as follows:

python25_d.dll!PyInt_FromLong(long ival=2)  Line 89 + 0x12	C
python25_d.dll!symtable_add_def(symtable * st=0x1911c3e0, _object * name=0x1911c108, int flag=2)  Line 811 + 0x9	C
python25_d.dll!symtable_visit_expr(symtable * st=0x1911c3e0, _expr * e=0x1169d0a8)  Line 1201 + 0x24	C
python25_d.dll!symtable_visit_stmt(symtable * st=0x1911c3e0, _stmt * s=0x1169d108)  Line 978 + 0x5d	C
python25_d.dll!PySymtable_Build(_mod * mod=0x1169e530, const char * filename=0x1252b314, PyFutureFeatures * future=0x19113cd0)  Line 238 + 0x14	C
python25_d.dll!PyAST_Compile(_mod * mod=0x1169e530, const char * filename=0x1252b314, PyCompilerFlags * flags=0x00dd0700, _arena * arena=0x17f1bc10)  Line 287 + 0x11	C
python25_d.dll!Py_CompileStringFlags(const char * str=0x17dd6ad8, const char * filename=0x1252b314, int start=257, PyCompilerFlags * flags=0x00000000)  Line 1330 + 0x15	C
FourDAnalysis.dll!vtkCurveAnalysisPythonInterface::GenerateFittingScript()  Line 337 + 0x2a	C++