Difference between revisions of "User talk:Haehn"

From NAMIC Wiki
Jump to: navigation, search
Line 43: Line 43:
 
${INPUT}=$const(/Volumes/DATA2/dhaehn/cutted/Image${FILE}_${TYPE}.nrrd)
 
${INPUT}=$const(/Volumes/DATA2/dhaehn/cutted/Image${FILE}_${TYPE}.nrrd)
 
${VESSELNESS_NAME}=$const(${FILE}-${TYPE}/${FILE}-${TYPE}-out-${SIGMA_MIN}-${SIGMA_MAX}-N${SIGMA_STEPS}-${ALPHA}-${BETA}-${GAMMA})
 
${VESSELNESS_NAME}=$const(${FILE}-${TYPE}/${FILE}-${TYPE}-out-${SIGMA_MIN}-${SIGMA_MAX}-N${SIGMA_STEPS}-${ALPHA}-${BETA}-${GAMMA})
${INPUT_VESSELNESS}=$const(/Volumes/DATA2/dhaehn/gwe-results/${VESSELNESS_NAME}.nrrd)
+
${INPUT_VESSELNESS}=$const(/Volumes/DATA2/dhaehn/gwe-results/${VESSELNESS_NAME}*.nrrd)
 
${SEED_X}=$const(1)
 
${SEED_X}=$const(1)
 
${SEED_Y}=$const(1)
 
${SEED_Y}=$const(1)
Line 53: Line 53:
 
${ADVECTION}=$const(100)
 
${ADVECTION}=$const(100)
 
${ITERATIONS}=$const(10)
 
${ITERATIONS}=$const(10)
${OUTPUT}=$const(/Volumes/DATA2/dhaehn/gwe-results-polydata/${VESSELNESS_NAME}-FM-${LOW_THRESHOLD}-${HIGH_THRESHOLD}-GAC-${PROPAGATION}-${CURVATURE}-${ADVECTION}-N${ITERATIONS}.vtk)
+
${OUTPUT_A}=$const(/Volumes/DATA2/dhaehn/gwe-results-polydata/${VESSELNESS_NAME}-FM-${LOW_THRESHOLD}-${HIGH_THRESHOLD}--)
 +
${OUTPUT_B}=$const(-GAC-${PROPAGATION}-${CURVATURE}-${ADVECTION}-N${ITERATIONS}--)
  
 
{SLICER_HOME}/Slicer3 --no_splash --evalpython "import sys; from Slicer import slicer;  
 
{SLICER_HOME}/Slicer3 --no_splash --evalpython "import sys; from Slicer import slicer;  
Line 68: Line 69:
  
 
volNode=slicer.VolumesGUI.GetLogic().AddArchetypeVolume('${INPUT}','Originals',0);
 
volNode=slicer.VolumesGUI.GetLogic().AddArchetypeVolume('${INPUT}','Originals',0);
vesselnessNode=slicer.VolumesGUI.GetLogic().AddArchetypeVolume('${INPUT_VESSELNESS}','Vessels',0);
+
 
 +
import glob;
 +
 
 +
vesselnessFile=glob.glob('${INPUT_VESSELNESS}');
 +
vesselnessNode=slicer.VolumesGUI.GetLogic().AddArchetypeVolume(vesselnessFile[0],'Vessels',0);
  
 
matrix = slicer.vtkMatrix4x4(); volNode.GetIJKToRASMatrix(matrix);
 
matrix = slicer.vtkMatrix4x4(); volNode.GetIJKToRASMatrix(matrix);
Line 82: Line 87:
 
seedList.InsertNextId(vesselImage.ComputePointId(int(ijkSeedPt[0]),int(ijkSeedPt[1]),int(ijkSeedPt[2])));
 
seedList.InsertNextId(vesselImage.ComputePointId(int(ijkSeedPt[0]),int(ijkSeedPt[1]),int(ijkSeedPt[2])));
  
 +
from datetime import *;
 +
 +
fm_s = datetime.now();
 
fm = levelset.ExecuteFM(vesselImage,${LOW_THRESHOLD},${HIGH_THRESHOLD},seedList,targetList);
 
fm = levelset.ExecuteFM(vesselImage,${LOW_THRESHOLD},${HIGH_THRESHOLD},seedList,targetList);
 +
fm_e = datetime.now();
 +
delta_fm=fm_e-fm_s;
 +
gac_s=datetime.now();
 
gac = levelset.ExecuteGAC(image,fm,${ITERATIONS},${PROPAGATION},${CURVATURE},${ADVECTION},'geodesic');
 
gac = levelset.ExecuteGAC(image,fm,${ITERATIONS},${PROPAGATION},${CURVATURE},${ADVECTION},'geodesic');
 +
gac_e=datetime.now();
 +
delta_gac=gac_e-gac_s;
 +
mc_s=datetime.now();
 
mc = levelset.MarchingCubes(gac,matrix,0.0);
 
mc = levelset.MarchingCubes(gac,matrix,0.0);
 +
mc_e=datetime.now();
 +
delta_mc=mc_e-mc_s;
  
 
outputNode=slicer.MRMLScene.CreateNodeByClass('vtkMRMLModelNode');  
 
outputNode=slicer.MRMLScene.CreateNodeByClass('vtkMRMLModelNode');  
Line 90: Line 106:
 
modelNode.SetAndObservePolyData(mc); modelNode.SetModifiedSinceRead(1);  
 
modelNode.SetAndObservePolyData(mc); modelNode.SetModifiedSinceRead(1);  
  
slicer.ModelsGUI.GetLogic().SaveModel('${OUTPUT}',modelNode);"
+
slicer.ModelsGUI.GetLogic().SaveModel('${OUTPUT_A}'+str(delta_fm).replace(':','-')+'${OUTPUT_B}'+str(delta_gac).replace(':','-')+'-MC--'+str(delta_mc).replace(':','-')+'.vtk',modelNode);"
 
</pre>
 
</pre>

Revision as of 12:48, 22 January 2010

Home < User talk:Haehn

my notes..

  • this code works locally:

"import sys; from Slicer import slicer; volNode=slicer.VolumesGUI.GetLogic().AddArchetypeVolume('/home/haehn/data/Image00_LCA.nrrd','Liver',0); matrix = slicer.vtkMatrix4x4(); volNode.GetIJKToRASMatrix(matrix);

outputNode=slicer.MRMLScene.CreateNodeByClass('vtkMRMLScalarVolumeNode'); volumeNode=slicer.MRMLScene.AddNode(outputNode); volumeNode.SetAndObserveImageData(volNode.GetImageData()); volumeNode.SetIJKToRASMatrix(matrix); volumeNode.SetModifiedSinceRead(1); slicer.VolumesGUI.GetLogic().SaveArchetypeVolume('/home/haehn/data/test.nrrd',volumeNode);"

  • remote Frangi:
${SIGMA_MIN}=$const(1.0)
${SIGMA_MAX}=$const(5.0)
${SIGMA_STEPS}=$const(10)
${ALPHA}=$range(0.1,0.5,0.1)
${BETA}=$range(500.0,1500.0,500.0)
${GAMMA}=$range(300.0,1000.0,100.0)
${FILE}=$const(00)
${TYPE}=$const(RCA)
${INPUT}=$const(/Volumes/DATA2/dhaehn/cutted/Image${FILE}_${TYPE}.nrrd)
${OUTPUT}=$const(/Volumes/DATA2/dhaehn/gwe-results/${FILE}-${TYPE}/${FILE}-${TYPE}-out-${SIGMA_MIN}-${SIGMA_MAX}-N${SIGMA_STEPS}-${ALPHA}-${BETA}-${GAMMA})

${SLICER_HOME}/Slicer3 --no_splash --evalpython "import sys; from Slicer import slicer; sys.path.append(str(slicer.Application.GetExtensionsInstallPath())+'/'+str(slicer.Application.GetSvnRevision())+'/VMTKVesselEnhancement/VMTKVesselEnhancement'); from SlicerVMTKVesselEnhancementGUI import *; hiddengui = VMTKVesselEnhancement(); from SlicerVMTKVesselEnhancementLogic import *; vesselness=SlicerVMTKVesselEnhancementLogic(hiddengui); volNode=slicer.VolumesGUI.GetLogic().AddArchetypeVolume('${INPUT}','Vessels',0); matrix = slicer.vtkMatrix4x4(); volNode.GetIJKToRASMatrix(matrix); from datetime import *; s=datetime.now(); outVolumeData = vesselness.ApplyFrangiVesselness(volNode.GetImageData(),${SIGMA_MIN},${SIGMA_MAX},${SIGMA_STEPS},${ALPHA},${BETA},${GAMMA}); e=datetime.now(); delta=e-s; outputNode=slicer.MRMLScene.CreateNodeByClass('vtkMRMLScalarVolumeNode'); volumeNode=slicer.MRMLScene.AddNode(outputNode); volumeNode.SetAndObserveImageData(outVolumeData); volumeNode.SetIJKToRASMatrix(matrix); volumeNode.SetModifiedSinceRead(1); slicer.VolumesGUI.GetLogic().SaveArchetypeVolume('${OUTPUT}--'+str(delta).replace(':','-')+'.nrrd',volumeNode);Slicer.tk.eval('exit 0');"
  • remote levelset:
${SIGMA_MIN}=$const(1.0)
${SIGMA_MAX}=$const(5.0)
${SIGMA_STEPS}=$const(10)
${ALPHA}=$range(0.1,0.5,0.1)
${BETA}=$range(500.0,1500.0,500.0)
${GAMMA}=$range(300.0,1000.0,100.0)
${FILE}=$const(00)
${TYPE}=$const(RCA)
${INPUT}=$const(/Volumes/DATA2/dhaehn/cutted/Image${FILE}_${TYPE}.nrrd)
${VESSELNESS_NAME}=$const(${FILE}-${TYPE}/${FILE}-${TYPE}-out-${SIGMA_MIN}-${SIGMA_MAX}-N${SIGMA_STEPS}-${ALPHA}-${BETA}-${GAMMA})
${INPUT_VESSELNESS}=$const(/Volumes/DATA2/dhaehn/gwe-results/${VESSELNESS_NAME}*.nrrd)
${SEED_X}=$const(1)
${SEED_Y}=$const(1)
${SEED_Z}=$const(1)
${LOW_THRESHOLD}=$const(0.1)
${HIGH_THRESHOLD}=$const(1.0)
${PROPAGATION}=$const(0)
${CURVATURE}=$const(70)
${ADVECTION}=$const(100)
${ITERATIONS}=$const(10)
${OUTPUT_A}=$const(/Volumes/DATA2/dhaehn/gwe-results-polydata/${VESSELNESS_NAME}-FM-${LOW_THRESHOLD}-${HIGH_THRESHOLD}--)
${OUTPUT_B}=$const(-GAC-${PROPAGATION}-${CURVATURE}-${ADVECTION}-N${ITERATIONS}--)

{SLICER_HOME}/Slicer3 --no_splash --evalpython "import sys; from Slicer import slicer; 

sys.path.append(str(slicer.Application.GetExtensionsInstallPath())+'/'+str(slicer.Application.GetSvnRevision())+'/VMTKEasyLevelSetSegmentation/VMTKEasyLevelSetSegmentation'); 

from VMTKEasyLevelSetSegmentationGUI import *; 

hiddengui = VMTKEasyLevelSetSegmentationGUI(); 

from VMTKEasyLevelSetSegmentationLogic import *; 

levelset = VMTKEasyLevelSetSegmentationLogic(hiddengui);

volNode=slicer.VolumesGUI.GetLogic().AddArchetypeVolume('${INPUT}','Originals',0);

import glob;

vesselnessFile=glob.glob('${INPUT_VESSELNESS}');
vesselnessNode=slicer.VolumesGUI.GetLogic().AddArchetypeVolume(vesselnessFile[0],'Vessels',0);

matrix = slicer.vtkMatrix4x4(); volNode.GetIJKToRASMatrix(matrix);
rasMatrix = slicer.vtkMatrix4x4(); volNode.GetRASToIJKMatrix(rasMatrix);
image = volNode.GetImageData();
vesselImage = vesselnessNode.GetImageData();

seedList = slicer.vtkIdList();
targetList = slicer.vtkIdList();
seedPt = [${SEED_X},${SEED_Y},${SEED_Z},1];

ijkSeedPt = rasMatrix.MultiplyPoint(*seedPt);
seedList.InsertNextId(vesselImage.ComputePointId(int(ijkSeedPt[0]),int(ijkSeedPt[1]),int(ijkSeedPt[2])));

from datetime import *;

fm_s = datetime.now();
fm = levelset.ExecuteFM(vesselImage,${LOW_THRESHOLD},${HIGH_THRESHOLD},seedList,targetList);
fm_e = datetime.now();
delta_fm=fm_e-fm_s;
gac_s=datetime.now();
gac = levelset.ExecuteGAC(image,fm,${ITERATIONS},${PROPAGATION},${CURVATURE},${ADVECTION},'geodesic');
gac_e=datetime.now();
delta_gac=gac_e-gac_s;
mc_s=datetime.now();
mc = levelset.MarchingCubes(gac,matrix,0.0);
mc_e=datetime.now();
delta_mc=mc_e-mc_s;

outputNode=slicer.MRMLScene.CreateNodeByClass('vtkMRMLModelNode'); 
modelNode=slicer.MRMLScene.AddNode(outputNode); 
modelNode.SetAndObservePolyData(mc); modelNode.SetModifiedSinceRead(1); 

slicer.ModelsGUI.GetLogic().SaveModel('${OUTPUT_A}'+str(delta_fm).replace(':','-')+'${OUTPUT_B}'+str(delta_gac).replace(':','-')+'-MC--'+str(delta_mc).replace(':','-')+'.vtk',modelNode);"