In [1]:
## Boiler plate code common to many notebooks.  See the TestFilesCommonCode.ipynb for details
from __future__ import print_function
%run TestFilesCommonCode.ipynb


SimpleITK Version: 0.9.0.dev2151-g2a716
Compiled: Dec 23 2014 21:10:53


In [2]:
import os
import glob
import sys

#\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
#####################################################################################
#     Prepend the shell environment search paths
PROGRAM_PATHS = '/scratch/NAMICExternalProjects/release/bin'
PROGRAM_PATHS = PROGRAM_PATHS.split(':')
PROGRAM_PATHS.extend(os.environ['PATH'].split(':'))
os.environ['PATH'] = ':'.join(PROGRAM_PATHS)

CUSTOM_ENVIRONMENT=dict()

# Platform specific information
#     Prepend the python search paths
PYTHON_AUX_PATHS = '/scratch/NAMICExternalProjects/release/BRAINSTools/AutoWorkup'
PYTHON_AUX_PATHS = PYTHON_AUX_PATHS.split(':')
PYTHON_AUX_PATHS.extend(sys.path)
sys.path = PYTHON_AUX_PATHS

import SimpleITK as sitk
import nipype
from nipype.interfaces import ants
from nipype.interfaces.base import CommandLine, CommandLineInputSpec, TraitedSpec, File, Directory
from nipype.interfaces.base import traits, isdefined, BaseInterface
from nipype.interfaces.utility import Merge, Split, Function, Rename, IdentityInterface
import nipype.interfaces.io as nio   # Data i/oS
import nipype.pipeline.engine as pe  # pypeline engine
from nipype.interfaces.freesurfer import ReconAll
from SEMTools import *

In [8]:
DWI_scan = '/scratch/BS/release/BRAINSTools-build/ExternalData/TestData/DWI_test1.nrrd'
DWI=sitk.ReadImage(DWI_scan)

base_dir= '/scratch/TESTS/IpythonNotebook/5RotationTestsFor_gtractResampleDWIInPlace'

In [4]:
DTIEstim=dtiestim()
DTIEstim.inputs.method = 'wls'
DTIEstim.inputs.tensor_output = os.path.join(base_dir,'original_DTI.nrrd')
DTIEstim.inputs.dwi_image = DWI_scan
DTIEstim.run()


Out[4]:
<nipype.interfaces.base.InterfaceResult at 0x10b286950>

In [44]:
transName=os.path.join(base_dir,'rigTx_45z.h5')
rotatedDWI=os.path.join(base_dir,'rotatedDWI_45z.nrrd')
tesorImage=os.path.join(base_dir,'rotatedDTI_45z.nrrd')

In [45]:
rigTx = sitk.VersorRigid3DTransform()
rigTx.SetRotation([0,0,1],0.785)
sitk.WriteTransform(rigTx, transName)
#print(rigTx)

In [46]:
gtRIP=gtractResampleDWIInPlace()
gtRIP.inputs.inputVolume = DWI_scan
gtRIP.inputs.inputTransform = transName
gtRIP.inputs.outputVolume = rotatedDWI
gtRIP.run()


INFO:interface:stdout 2015-01-09T13:57:45.739508:=====================================================
INFO:interface:stdout 2015-01-09T13:57:45.739508:DWI Image: /scratch/BS/release/BRAINSTools-build/ExternalData/TestData/DWI_test1.nrrd
INFO:interface:stdout 2015-01-09T13:57:45.739508:Input Transform: /scratch/TESTS/IpythonNotebook/5RotationTestsFor_gtractResampleDWIInPlace/rigTx_45z.h5
INFO:interface:stdout 2015-01-09T13:57:45.739508:warpDWI Transform: 
INFO:interface:stdout 2015-01-09T13:57:45.739508:Output Image: /scratch/TESTS/IpythonNotebook/5RotationTestsFor_gtractResampleDWIInPlace/rotatedDWI_45z.nrrd
INFO:interface:stdout 2015-01-09T13:57:45.739508:Debug Level: 0
INFO:interface:stdout 2015-01-09T13:57:45.739508:Image Output Size: 0,0,0
INFO:interface:stdout 2015-01-09T13:57:45.739508:=====================================================
INFO:interface:stdout 2015-01-09T13:57:46.338678:Read Image
INFO:interface:stdout 2015-01-09T13:57:46.339550:Read ITK transform from file: /scratch/TESTS/IpythonNotebook/5RotationTestsFor_gtractResampleDWIInPlace/rigTx_45z.h5
INFO:interface:stdout 2015-01-09T13:57:46.346071:HACK: 0  VersorRigid3DTransform
INFO:interface:stdout 2015-01-09T13:57:46.346539:Input DWI image measurement frame: 1 0 0
INFO:interface:stdout 2015-01-09T13:57:46.346539:0 1 0
INFO:interface:stdout 2015-01-09T13:57:46.346539:0 0 1
INFO:interface:stdout 2015-01-09T13:57:46.346539:
INFO:interface:stdout 2015-01-09T13:57:46.346539:Input DWI image vector length: 41
INFO:interface:stdout 2015-01-09T13:57:46.380111:Rigid transform matrix: 0.707388 -0.706825 0
INFO:interface:stdout 2015-01-09T13:57:46.380111:0.706825 0.707388 0
INFO:interface:stdout 2015-01-09T13:57:46.380111:0 0 1
INFO:interface:stdout 2015-01-09T13:57:46.380111:
INFO:interface:stdout 2015-01-09T13:57:46.382148:Input DWI Image Origin: ( -158.401, 22.5643, -65 )
INFO:interface:stdout 2015-01-09T13:57:46.382148:Input DWI Image Size: 128 96 65
INFO:interface:stdout 2015-01-09T13:57:46.382148: 
INFO:interface:stdout 2015-01-09T13:57:46.382148:Output DWI Image Origin: ( -158.401, 22.5643, -65 )
INFO:interface:stdout 2015-01-09T13:57:46.382148:Output DWI Image Size: 128 96 65
Out[46]:
<nipype.interfaces.base.InterfaceResult at 0x11fb1a810>

In [47]:
DTIEstim2=dtiestim()
DTIEstim2.inputs.method = 'wls'
DTIEstim2.inputs.tensor_output = tesorImage
DTIEstim2.inputs.dwi_image = gtRIP.inputs.outputVolume
DTIEstim2.run()


Out[47]:
<nipype.interfaces.base.InterfaceResult at 0x11fb1aa50>

In [ ]: