Skip to content

Commit 2cd0deb

Browse files
committed
Update brainsuite interface with changes to SVREG, BDP, ThicknessPVC
1 parent cb072a7 commit 2cd0deb

File tree

2 files changed

+66
-45
lines changed

2 files changed

+66
-45
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from .brainsuite import (Bse, Bfc, Pvc, Cerebro, Cortex, Scrubmask, Tca,
22
Dewisp, Dfs, Pialmesh, Skullfinder, Hemisplit,
3-
SVReg, BDP)
3+
SVReg, BDP, ThicknessPVC)

nipype/interfaces/brainsuite/brainsuite.py

Lines changed: 65 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""This script provides interfaces for BrainSuite command line tools.
2+
Please see brainsuite.org for more information.
3+
4+
Author: Jason Wong
5+
"""
6+
17
import os
28
import re as regex
39

@@ -85,18 +91,12 @@ def _gen_filename(self, name):
8591
if isdefined(inputs[name]):
8692
return os.path.abspath(inputs[name])
8793

88-
genfiles = {'outputMRIVolume' : '.bse.nii.gz',
94+
fileToSuffixMap = {'outputMRIVolume' : '.bse.nii.gz',
8995
'outputMaskFile' : '.mask.nii.gz'
9096
}
9197

92-
if name in genfiles:
93-
return getFileName(self.inputs.inputMRIFile, genfiles[name])
94-
95-
'''if name == 'outputMRIVolume':
96-
return getFileName(self.inputs.inputMRIFile, name, '.nii.gz')
97-
if name == 'outputMaskFile':
98-
return getFileName(self.inputs.inputMRIFile, name, '.nii.gz')
99-
'''
98+
if name in fileToSuffixMap:
99+
return getFileName(self.inputs.inputMRIFile, fileToSuffixMap[name])
100100

101101
return None
102102

@@ -201,13 +201,9 @@ def _gen_filename(self, name):
201201
if isdefined(inputs[name]):
202202
return os.path.abspath(inputs[name])
203203

204-
genfiles = {'outputMRIVolume': '.bfc.nii.gz'}
205-
if name in genfiles:
206-
return getFileName(self.inputs.inputMRIFile, genfiles[name])
207-
208-
'''if name == 'outputMRIVolume':
209-
return getFileName(self.inputs.inputMRIFile, name, '.nii.gz')
210-
'''
204+
fileToSuffixMap = {'outputMRIVolume': '.bfc.nii.gz'}
205+
if name in fileToSuffixMap:
206+
return getFileName(self.inputs.inputMRIFile, fileToSuffixMap[name])
211207

212208
return None
213209

@@ -271,14 +267,11 @@ def _gen_filename(self, name):
271267
if isdefined(inputs[name]):
272268
return os.path.abspath(inputs[name])
273269

274-
genfiles = {'outputLabelFile' : '.pvc.label.nii.gz',
270+
fileToSuffixMap = {'outputLabelFile' : '.pvc.label.nii.gz',
275271
'outputTissueFractionFile' : '.pvc.frac.nii.gz'
276272
}
277-
if name in genfiles:
278-
return getFileName(self.inputs.inputMRIFile, genfiles[name])
279-
'''
280-
if name == 'outputLabelFile' or name == 'outputTissueFractionFile':
281-
return getFileName(self.inputs.inputMRIFile, name, '.nii.gz')'''
273+
if name in fileToSuffixMap:
274+
return getFileName(self.inputs.inputMRIFile, fileToSuffixMap[name])
282275

283276
return None
284277

@@ -359,16 +352,13 @@ def _gen_filename(self, name):
359352
if isdefined(inputs[name]):
360353
return os.path.abspath(inputs[name])
361354

362-
genfiles = {'outputCerebrumMaskFile' : '.cerebrum.mask.nii.gz',
355+
fileToSuffixMap = {'outputCerebrumMaskFile' : '.cerebrum.mask.nii.gz',
363356
'outputLabelVolumeFile' : '.hemi.label.nii.gz',
364357
'outputWarpTransformFile' : '.warp',
365358
'outputAffineTransformFile' : '.air'
366359
}
367-
if name in genfiles:
368-
return getFileName(self.inputs.inputMRIFile, genfiles[name])
369-
'''
370-
if name == 'outputCerebrumMaskFile' or name == 'outputLabelVolumeFile':
371-
return getFileName(self.inputs.inputMRIFile, name, '.nii.gz')'''
360+
if name in fileToSuffixMap:
361+
return getFileName(self.inputs.inputMRIFile, fileToSuffixMap[name])
372362

373363
return None
374364

@@ -811,20 +801,14 @@ def _gen_filename(self, name):
811801
if isdefined(inputs[name]):
812802
return os.path.abspath(inputs[name])
813803

814-
genfiles = {
804+
fileToSuffixMap = {
815805
'outputLeftHemisphere' : '.left.inner.cortex.dfs',
816806
'outputLeftPialHemisphere' : '.left.pial.cortex.dfs',
817807
'outputRightHemisphere' : '.right.inner.cortex.dfs',
818808
'outputRightPialHemisphere' : '.right.pial.cortex.dfs'
819809
}
820-
if name in genfiles:
821-
return getFileName(self.inputs.inputSurfaceFile, genfiles[name])
822-
'''
823-
if (name == 'outputLeftHemisphere'
824-
or name == 'outputRightHemisphere'
825-
or name == 'outputLeftPialHemisphere'
826-
or name == 'outputRightPialHemisphere'):
827-
return getFileName(self.inputs.inputSurfaceFile, name, '.dfs')'''
810+
if name in fileToSuffixMap:
811+
return getFileName(self.inputs.inputSurfaceFile, fileToSuffixMap[name])
828812

829813
return None
830814

@@ -1010,6 +994,10 @@ class SVRegInputSpec(CommandLineInputSpec):
1010994
desc='If multiple CPUs are present on the system, the code will try to use '
1011995
'multithreading to make the execution fast.'
1012996
)
997+
useSingleThreading = traits.Bool(
998+
argstr='\'-U\'',
999+
desc='Use single threaded mode.'
1000+
)
10131001

10141002
class SVReg(CommandLine):
10151003
"""
@@ -1031,6 +1019,7 @@ class SVReg(CommandLine):
10311019
>>> svreg.inputs. keepIntermediates = True
10321020
>>> svreg.inputs.verbosity2 = True
10331021
>>> svreg.inputs.displayTimestamps = True
1022+
>>> svreg.inputs.useSingleThreading = True
10341023
>>> results = svreg.run() #doctest: +SKIP
10351024
10361025
@@ -1040,6 +1029,8 @@ class SVReg(CommandLine):
10401029
_cmd = 'svreg.sh'
10411030

10421031
def _format_arg(self, name, spec, value):
1032+
if name == 'subjectFilePrefix' or name == 'atlasFilePrefix' or name == 'curveMatchingInstructions':
1033+
return spec.argstr % os.path.expanduser(value)
10431034
if name == 'dataSinkDelay':
10441035
return spec.argstr % ''
10451036
return super(SVReg, self)._format_arg(name, spec, value)
@@ -1156,10 +1147,9 @@ class BDPInputSpec(CommandLineInputSpec):
11561147
'The derived generalized-FA (GFA) maps are also saved in the output '
11571148
'directory. '
11581149
)
1159-
estimateODF_Both = traits.Bool(
1160-
argstr='--odf',
1161-
desc='Same as setting both estimateODF_FRT and estimateODF_FRACT to true. Estimates ODFs using both '
1162-
'FRT and FRACT. '
1150+
estimateODF_3DShore = traits.Float(
1151+
argstr='--3dshore --diffusion_time_ms %f',
1152+
desc='Estimates ODFs using 3Dshore. Pass in diffusion time, in ms'
11631153
)
11641154
odfLambta = traits.Bool(
11651155
argstr='--odf-lambda <L>',
@@ -1529,8 +1519,8 @@ class BDP(CommandLine):
15291519
BrainSuite Diffusion Pipeline (BDP) enables fusion of diffusion and
15301520
structural MRI information for advanced image and connectivity analysis.
15311521
It provides various methods for distortion correction, co-registration,
1532-
diffusion modeling (DTI and ODF) and basic ROI-wise statistic. BDP is
1533-
lexible and diverse tool which supports wide variety of diffusion
1522+
diffusion modeling (DTI and ODF) and basic ROI-wise statistic. BDP is a
1523+
flexible and diverse tool which supports wide variety of diffusion
15341524
datasets.
15351525
For more information, please see:
15361526
@@ -1559,7 +1549,38 @@ def _format_arg(self, name, spec, value):
15591549
return spec.argstr % ''
15601550
return super(BDP, self)._format_arg(name, spec, value)
15611551

1552+
1553+
class ThicknessPVCInputSpec(CommandLineInputSpec):
1554+
subjectFilePrefix = traits.Str(
1555+
argstr='%s', mandatory=True,
1556+
desc='Absolute path and filename prefix of the subject data'
1557+
)
15621558

1559+
class ThicknessPVC(CommandLine):
1560+
"""
1561+
ThicknessPVC computes cortical thickness using partial tissue fractions.
1562+
This thickness measure is then transferred to the atlas surface to
1563+
facilitate population studies. It also stores the computed thickness into
1564+
separate hemisphere files and subject thickness mapped to the atlas
1565+
hemisphere surfaces. ThicknessPVC is not run through the main SVReg
1566+
sequence, and should be used after executing the BrainSuite and SVReg
1567+
sequence.
1568+
For more informaction, please see:
1569+
1570+
http://brainsuite.org/processing/svreg/svreg_modules/
1571+
1572+
Examples
1573+
--------
1574+
1575+
>>> from nipype.interfaces import brainsuite
1576+
>>> thicknessPVC = brainsuite.ThicknessPVC()
1577+
>>> thicknessPVC.inputs.subjectFilePrefix = 'home/user/btestsubject/testsubject'
1578+
>>> results = thicknessPVC.run() #doctest: +SKIP
1579+
1580+
"""
1581+
1582+
input_spec = ThicknessPVCInputSpec
1583+
_cmd = 'thicknessPVC.sh'
15631584

15641585

15651586
# used to generate file names for outputs
@@ -1579,4 +1600,4 @@ def l_outputs(self):
15791600
if not name is None:
15801601
outputs[key] = name
15811602

1582-
return outputs
1603+
return outputs

0 commit comments

Comments
 (0)