Skip to content

Commit

Permalink
ENH: Add SnapShotWriter Python Wrapper Outline
Browse files Browse the repository at this point in the history
  • Loading branch information
reginakim authored and hjmjohnson committed Nov 7, 2012
1 parent 943be09 commit 97cd0bd
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
41 changes: 41 additions & 0 deletions AutoWorkup/BRAINSTools/BRAINSSnapShotWriter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from nipype.interfaces.base import CommandLine, CommandLineInputSpec, TraitedSpec, File, Directory, traits, isdefined, InputMultiPath, OutputMultiPath
import os
from nipype.interfaces.slicer.base import SlicerCommandLine


class BRAINSSnapShotWriterInputSpec(CommandLineInputSpec):
inputVolumes = File(desc="Images to be captured", exists=True, argstr="--inputVolumes %s") ## check how to set multiple input
inputBinaryVolumes = File(desc="Binary images to be overlapped on top of inputVolumes", exists=False, argstr="--inputBinaryVolumes %s") ## check how to set multiple input
inputPlaneDirection = InputMultiPath(traits.Int, desc="Plane to display. In general, 0=saggital, 1=coronal, and 2=axial plane. (default: 0,1,2)", argstr="inputPlaneDirection %s")
inputSliceToExtractInPercent = InputMultiPath(traits.Int, desc="2D slice number of input images. Percentage input from 0%-100%. (default: 50,50,50)", argstr="inputSliceToExtractInPercent %s")
inputSliceToExtractInIndex = InputMultiPath(traits.Int, desc="2D slice number of input images. For autoWorkUp output, which AC-PC aligned, 0,0,0 will be the center.", argstr="inputSliceToExtractInIndex %s")
inputSliceToExtractInPhysicalPoint = = InputMultiPath(traits.Float, desc="Input mask (binary) volume list to be extracted as 2D image. Multiple input is possible.", argstr="inputSliceToExtractInPhysicalPoint %s")

class BRAINSSnapShotWriterOutputSpec(TraitedSpec):
outputFilename = File(desc="Resulting screen shots (*png)", exists=True)


class BRAINSSnapShotWriter(SlicerCommandLine):
"""title: Snap Shot Writer (BRAINS)
category: Utilities
description:
version: 1.0.0
documentation-url: http://www.slicer.org/slicerWiki/index.php/Documentation/4.1/Modules/BRAINSSnapShotWriter
license: https://www.nitrc.org/svn/brains/BuildScripts/trunk/License.txt
contributor: This tool was developed by Eun Young (Regina) Kim
acknowledgements: The development of this tool was supported by funding from grants NS050568 and NS40068 from the National Institute of Neurological Disorders and Stroke and grants MH31593, MH40856, from the National Institute of Mental Health.
"""

input_spec = BRAINSSnapShotWriterInputSpec
output_spec = BRAINSSnapShotWriterOutputSpec
_cmd = " BRAINSSnapShotWriter "
_outputs_filenames = {'outputImage':'outputImage.png'}
30 changes: 30 additions & 0 deletions AutoWorkup/WorkupT1T2.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,36 @@ def WorkupT1T2(subjectid,mountPrefix,ExperimentBaseDirectoryCache, ExperimentBas
baw200.connect(myLocalSegWF[sessionid], 'outputspec.outputBinaryRightGlobus',SEGMENTATION_DataSink[sessionid], 'Segmentations.@outputBinaryRightGlobus')
baw200.connect(myLocalSegWF[sessionid], 'outputspec.outputLabelImageName', SEGMENTATION_DataSink[sessionid],'Segmentations.@outputLabelImageName')
baw200.connect(myLocalSegWF[sessionid], 'outputspec.outputCSVFileName', SEGMENTATION_DataSink[sessionid],'Segmentations.@outputCSVFileName')

## SnapShotWriter for Segmented result checking:
SnapShotWriter=pe.Node( interface=BRAINSSnapShotWriter(), name="SnapShotWriter")

## output specification
SnapShotWriter.inputs.outputFilename = 'snapShot.png'

## neccessary parameters (FIXED)
SnapShotWriter.inputs.inputPlaneDirection = "2,1,1,1,1,0,0"
SnapShotWriter.inputs.inputSliceToExtractInPhysicalPoint = "-3,-7,-3,5,7,22,-22"

## connect SnapShotWriter to the baw200
baw200.connect( PHASE_2_oneSubjWorkflow[sessionid], 'outputspec.t1_average', SnapShotWriter, 'inputVolumes')
baw200.connect( PHASE_2_oneSubjWorkflow[sessionid], 'outputspec.t2_average', SnapShotWriter, 'inputVolumes')

baw200.connect(SEGMENTATION_DataSink[sessionid], 'Segmentations.@outputBinaryLeftAccumben', SnapShotWriter, 'inputBinaryVolumes')
baw200.connect(SEGMENTATION_DataSink[sessionid], 'Segmentations.@outputBinaryLeftCaudate', SnapShotWriter, 'inputBinaryVolumes')
baw200.connect(SEGMENTATION_DataSink[sessionid], 'Segmentations.@outputBinaryLeftPutamen', SnapShotWriter, 'inputBinaryVolumes')
baw200.connect(SEGMENTATION_DataSink[sessionid], 'Segmentations.@outputBinaryLeftGlobus', SnapShotWriter, 'inputBinaryVolumes')
baw200.connect(SEGMENTATION_DataSink[sessionid], 'Segmentations.@outputBinaryLeftThalamus', SnapShotWriter, 'inputBinaryVolumes')
baw200.connect(SEGMENTATION_DataSink[sessionid], 'Segmentations.@outputBinaryLeftHippocampus', SnapShotWriter, 'inputBinaryVolumes')

baw200.connect(SEGMENTATION_DataSink[sessionid], 'Segmentations.@outputBinaryRightAccumben', SnapShotWriter, 'inputBinaryVolumes')
baw200.connect(SEGMENTATION_DataSink[sessionid], 'Segmentations.@outputBinaryRightCaudate', SnapShotWriter, 'inputBinaryVolumes')
baw200.connect(SEGMENTATION_DataSink[sessionid], 'Segmentations.@outputBinaryRightPutamen', SnapShotWriter, 'inputBinaryVolumes')
baw200.connect(SEGMENTATION_DataSink[sessionid], 'Segmentations.@outputBinaryRightGlobus', SnapShotWriter, 'inputBinaryVolumes')
baw200.connect(SEGMENTATION_DataSink[sessionid], 'Segmentations.@outputBinaryRightThalamus', SnapShotWriter, 'inputBinaryVolumes')
baw200.connect(SEGMENTATION_DataSink[sessionid], 'Segmentations.@outputBinaryRightHippocampus', SnapShotWriter, 'inputBinaryVolumes')


else:
print("SKIPPING SEGMENTATION PHASE FOR {0} {1} {2}, lenT2s {3}".format(projectid, subjectid, sessionid, len(global_AllT2s) ))

Expand Down

0 comments on commit 97cd0bd

Please sign in to comment.